session

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package session provides vMCP-specific session types that extend transport sessions with domain logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VMCPSessionFactory

func VMCPSessionFactory() transportsession.Factory

VMCPSessionFactory creates a factory function for the session manager.

Types

type VMCPSession

type VMCPSession struct {
	*transportsession.StreamableSession
	// contains filtered or unexported fields
}

VMCPSession extends StreamableSession with domain-specific routing data. This keeps routing table state in the application layer (pkg/vmcp/server) rather than polluting the transport layer (pkg/transport/session) with domain concerns.

Design Rationale:

  • Embeds StreamableSession to inherit Session interface and streamable HTTP behavior
  • Adds routing table for per-session capability routing
  • Maintains lifecycle synchronization with underlying transport session
  • Provides type-safe access to routing table (vs. interface{} casting)

Lifecycle:

  1. Created by VMCPSessionFactory during sessionIDAdapter.Generate()
  2. Routing table populated in AfterInitialize hook
  3. Retrieved by middleware on subsequent requests via type assertion
  4. Cleaned up automatically by session.Manager TTL worker

func GetVMCPSession

func GetVMCPSession(sessionID string, mgr *transportsession.Manager) (*VMCPSession, error)

GetVMCPSession retrieves and validates a VMCPSession from the session manager.

This helper abstracts the common pattern of:

  1. Retrieving a session from the manager
  2. Type-asserting to *VMCPSession
  3. Handling errors with clear messages

func NewVMCPSession

func NewVMCPSession(id string) *VMCPSession

NewVMCPSession creates a VMCPSession with initialized StreamableSession. The routing table is initially nil and will be populated during AfterInitialize hook.

This function panics if NewStreamableSession returns an unexpected type. This is intentional fail-fast behavior for programming errors that should be caught during development/testing. The type assertion should always succeed since NewStreamableSession is under our control and always returns *StreamableSession. A panic here indicates a bug in the transport layer that needs to be fixed, not a runtime condition to handle gracefully.

func (*VMCPSession) GetRoutingTable

func (s *VMCPSession) GetRoutingTable() *vmcp.RoutingTable

GetRoutingTable retrieves the routing table for this session. Returns nil if capabilities have not been initialized yet.

func (*VMCPSession) SetRoutingTable

func (s *VMCPSession) SetRoutingTable(rt *vmcp.RoutingTable)

SetRoutingTable sets the routing table for this session. Called during AfterInitialize hook after capability discovery.

func (*VMCPSession) Type

Type identifies this as a streamable vMCP session.

Jump to

Keyboard shortcuts

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