providers/session: Use usync.Monitor instead of usync.Locker
This commit is contained in:
parent
aebb4ac18b
commit
c4056bd63e
@ -24,7 +24,7 @@ type Provider struct {
|
|||||||
Lifetime time.Duration
|
Lifetime time.Duration
|
||||||
InsecureCookie bool
|
InsecureCookie bool
|
||||||
CookieDomain string
|
CookieDomain string
|
||||||
sessions usync.RWLocker[sessionMap]
|
sessions usync.RWMonitor[sessionMap]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Package fulfills the step.Provider interface.
|
// Package fulfills the step.Provider interface.
|
||||||
@ -33,7 +33,7 @@ func (this *Provider) Package () string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *Provider) Init () error {
|
func (this *Provider) Init () error {
|
||||||
this.sessions = usync.NewRWLocker(make(sessionMap))
|
this.sessions = usync.NewRWMonitor(make(sessionMap))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ func (this *Provider) FuncMapFor (document *step.Document) template.FuncMap {
|
|||||||
|
|
||||||
type state struct {
|
type state struct {
|
||||||
document *step.Document
|
document *step.Document
|
||||||
sessions *usync.RWLocker[sessionMap]
|
sessions *usync.RWMonitor[sessionMap]
|
||||||
lifetime time.Duration
|
lifetime time.Duration
|
||||||
insecureCookie bool
|
insecureCookie bool
|
||||||
cookieDomain string
|
cookieDomain string
|
||||||
@ -167,8 +167,8 @@ func (this *state) newSession (id uuid.UUID, expires time.Time) (*Session, error
|
|||||||
return &Session {
|
return &Session {
|
||||||
parent: this,
|
parent: this,
|
||||||
id: id,
|
id: id,
|
||||||
data: usync.NewRWLocker(make(map[string] any)),
|
data: usync.NewRWMonitor(make(map[string] any)),
|
||||||
expires: usync.NewRWLocker(expires),
|
expires: usync.NewRWMonitor(expires),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,8 +177,8 @@ type sessionMap map[uuid.UUID] *Session
|
|||||||
type Session struct {
|
type Session struct {
|
||||||
parent *state // immutable
|
parent *state // immutable
|
||||||
id uuid.UUID // immutable
|
id uuid.UUID // immutable
|
||||||
data usync.RWLocker[map[string] any] // mutable
|
data usync.RWMonitor[map[string] any] // mutable
|
||||||
expires usync.RWLocker[time.Time] // mutable
|
expires usync.RWMonitor[time.Time] // mutable
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Session) ID () uuid.UUID {
|
func (this *Session) ID () uuid.UUID {
|
||||||
|
Loading…
Reference in New Issue
Block a user