session

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2025 License: Apache-2.0 Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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