session

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package session provides session management for client keys.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSessionNotFound = errors.New("session not found")
	ErrSessionExpired  = errors.New("session expired")
)

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager manages client sessions in memory. For production, replace with Redis-backed implementation.

func NewManager

func NewManager(maxTTL time.Duration) *Manager

NewManager creates a new session manager.

func (*Manager) Count

func (m *Manager) Count() int

Count returns the number of active sessions.

func (*Manager) Create

func (m *Manager) Create(publicKey []byte, requestedTTL time.Duration) (*Session, error)

Create creates a new session with the given public key.

func (*Manager) Delete

func (m *Manager) Delete(id string)

Delete removes a session.

func (*Manager) Get

func (m *Manager) Get(id string) (*Session, error)

Get retrieves a session by ID.

func (*Manager) GetPublicKey

func (m *Manager) GetPublicKey(id string) ([]byte, error)

GetPublicKey retrieves only the public key for a session.

func (*Manager) Refresh

func (m *Manager) Refresh(id string, ttl time.Duration) error

Refresh extends a session's TTL.

type Session

type Session struct {
	ID           string
	PublicKey    []byte
	CreatedAt    time.Time
	ExpiresAt    time.Time
	LastAccessAt time.Time
}

Session holds client session data

Jump to

Keyboard shortcuts

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