Documentation
¶
Overview ¶
Package session implements session management and persistence orchestration.
It provides high-level abstractions for handling concurrent access to session states across multiple replicas, integrating local memory caches with distributed locking and long-term storage adapters.
Index ¶
- type Manager
- func (m *Manager) Delete(ctx context.Context, sessionID string) error
- func (m *Manager) List(ctx context.Context) ([]string, error)
- func (m *Manager) Load(ctx context.Context, sessionID string) (*domain.State, error)
- func (m *Manager) LoadOrStart(ctx context.Context, sessionID string, startNode string) (*domain.State, error)
- func (m *Manager) Save(ctx context.Context, sessionID string, state *domain.State) error
- func (m *Manager) Store() ports.StateStore
- func (m *Manager) WithLock(ctx context.Context, sessionID string, fn func(context.Context) error) error
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager orchestrates session access, ensuring safe concurrent operations. It uses Reference Counting to garbage collect unused locks.
func NewManager ¶
func NewManager(store ports.StateStore, opts ...Option) *Manager
NewManager creates a new Session Manager with the given persistence store.
func (*Manager) LoadOrStart ¶
func (m *Manager) LoadOrStart(ctx context.Context, sessionID string, startNode string) (*domain.State, error)
LoadOrStart tries to load a session. If not found, it initializes a new one.
func (*Manager) Store ¶ added in v0.7.0
func (m *Manager) Store() ports.StateStore
Store returns the underlying state store.
type Option ¶ added in v0.7.0
type Option func(*Manager)
Option configures the Manager.
func WithLocker ¶ added in v0.7.0
func WithLocker(locker ports.DistributedLocker) Option
WithLocker enables distributed locking.
func WithLogger ¶ added in v0.7.0
WithLogger configures a logger for the Manager.