session

package
v0.7.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

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

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) Delete

func (m *Manager) Delete(ctx context.Context, sessionID string) error

Delete removes the session from the store.

func (*Manager) List

func (m *Manager) List(ctx context.Context) ([]string, error)

List delegates to the store.

func (*Manager) Load

func (m *Manager) Load(ctx context.Context, sessionID string) (*domain.State, error)

Load retrieves an existing session from the 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) Save

func (m *Manager) Save(ctx context.Context, sessionID string, state *domain.State) error

Save persists the session state.

func (*Manager) Store added in v0.7.0

func (m *Manager) Store() ports.StateStore

Store returns the underlying state store.

func (*Manager) WithLock

func (m *Manager) WithLock(ctx context.Context, sessionID string, fn func(context.Context) error) error

WithLock executes a function while holding the lock for the session.

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

func WithLogger(logger *slog.Logger) Option

WithLogger configures a logger for the Manager.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL