session

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package session provides a session manager with TTL cleanup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory func(id string) *ProxySession

Factory defines a function type for creating new sessions.

type Manager

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

Manager holds sessions with TTL cleanup.

func NewManager

func NewManager(ttl time.Duration, factory Factory) *Manager

NewManager creates a session manager with TTL and starts cleanup worker.

func (*Manager) AddWithID

func (m *Manager) AddWithID(id string) error

AddWithID creates (and adds) a new session with the provided ID. Returns error if ID is empty or already exists.

func (*Manager) Delete

func (m *Manager) Delete(id string)

Delete removes a session by ID.

func (*Manager) Get

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

Get retrieves a session by ID. Returns (session, true) if found, and also updates its UpdatedAt timestamp.

func (*Manager) Stop

func (m *Manager) Stop()

Stop stops the cleanup worker.

type ProxySession

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

ProxySession implements the Session interface for proxy sessions.

func NewProxySession

func NewProxySession(id string) *ProxySession

NewProxySession creates a new ProxySession with the given ID.

func (*ProxySession) CreatedAt

func (s *ProxySession) CreatedAt() time.Time

CreatedAt returns the creation time of the session.

func (*ProxySession) ID

func (s *ProxySession) ID() string

ID returns the session ID.

func (*ProxySession) Touch

func (s *ProxySession) Touch()

Touch updates the session's last updated time to the current time.

func (*ProxySession) UpdatedAt

func (s *ProxySession) UpdatedAt() time.Time

UpdatedAt returns the last updated time of the session.

type Session

type Session interface {
	ID() string
	CreatedAt() time.Time
	UpdatedAt() time.Time
	Touch()
}

Session interface

Jump to

Keyboard shortcuts

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