Documentation
¶
Index ¶
- Variables
- type Manager
- func (m *Manager) ActiveCount() int
- func (m *Manager) Create(ctx context.Context) (*Session, error)
- func (m *Manager) Delete(sessionID string)
- func (m *Manager) Get(sessionID string) (*Session, bool)
- func (m *Manager) IncrementRequestCount(sessionID string) int
- func (m *Manager) List() []*Session
- func (m *Manager) Start(ctx context.Context)
- func (m *Manager) Stop()
- func (m *Manager) TotalCreated() int64
- type ManagerConfig
- type Session
- func (s *Session) Age() time.Duration
- func (s *Session) Close()
- func (s *Session) Context() context.Context
- func (s *Session) GetRequestCount() int
- func (s *Session) IdleTime() time.Duration
- func (s *Session) IncrementRequestCount() int
- func (s *Session) IsClosed() bool
- func (s *Session) SendMessage(msg []byte) bool
- func (s *Session) SetAgent(agentID, agentName string, capabilities []string)
- func (s *Session) SetClientInfo(sourceIP, userAgent string)
- func (s *Session) SetIdentity(verified bool, did string)
- type SessionError
Constants ¶
This section is empty.
Variables ¶
var ( ErrMaxSessionsReached = &SessionError{Message: "maximum sessions limit reached"} ErrSessionNotFound = &SessionError{Message: "session not found"} )
Errors
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles session lifecycle and storage.
func NewManager ¶
func NewManager(cfg ManagerConfig) *Manager
NewManager creates a new session manager.
func (*Manager) ActiveCount ¶
ActiveCount returns the number of active sessions.
func (*Manager) IncrementRequestCount ¶
IncrementRequestCount increments the request count for a session.
func (*Manager) TotalCreated ¶
TotalCreated returns the total number of sessions created.
type ManagerConfig ¶
type ManagerConfig struct {
SessionTTL time.Duration
CleanupInterval time.Duration
MaxSessions int
}
ManagerConfig holds session manager configuration.
func DefaultManagerConfig ¶
func DefaultManagerConfig() ManagerConfig
DefaultManagerConfig returns sensible defaults.
type Session ¶
type Session struct {
// ID is the unique session identifier
ID string `json:"id"`
// CreatedAt is when the session was established
CreatedAt time.Time `json:"created_at"`
// LastActivityAt is the time of the last request
LastActivityAt time.Time `json:"last_activity_at"`
// RequestCount is the total number of requests in this session
RequestCount int `json:"request_count"`
// AgentID is the identifier of the connected agent (from config or AgentFacts)
AgentID string `json:"agent_id"`
// AgentName is the human-readable agent name
AgentName string `json:"agent_name,omitempty"`
// Capabilities are the agent's granted capabilities
Capabilities []string `json:"capabilities,omitempty"`
// IdentityVerified indicates if AgentFacts token was verified
IdentityVerified bool `json:"identity_verified"`
// DID is the agent's decentralized identifier (if verified)
DID string `json:"did,omitempty"`
// SourceIP is the client's IP address
SourceIP string `json:"source_ip,omitempty"`
// UserAgent is the client's user agent string
UserAgent string `json:"user_agent,omitempty"`
// MessageChan is used to send SSE messages back to the client
MessageChan chan []byte `json:"-"`
// Done is closed when the session is terminated
Done chan struct{} `json:"-"`
// contains filtered or unexported fields
}
Session represents an active client connection session.
func NewSession ¶
NewSession creates a new session with the given ID.
func (*Session) GetRequestCount ¶
GetRequestCount returns the current request count.
func (*Session) IncrementRequestCount ¶
IncrementRequestCount atomically increments the request counter and returns the new value.
func (*Session) SendMessage ¶
SendMessage sends a message to the client via the message channel. Returns false if the session is closed or the channel is full.
func (*Session) SetClientInfo ¶
SetClientInfo sets the client connection information.
func (*Session) SetIdentity ¶
SetIdentity sets the verified identity information.
type SessionError ¶
type SessionError struct {
Message string
}
SessionError represents a session-related error.
func (*SessionError) Error ¶
func (e *SessionError) Error() string