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