idmap

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package idmap maps gateway-assigned request IDs to backend server request IDs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithEntryTTL added in v0.6.0

func WithEntryTTL(ttl time.Duration) func(*mapConfig)

WithEntryTTL sets the safety-net TTL for Redis-backed entries. Only applies when a Redis client is configured.

func WithRedisClient added in v0.6.0

func WithRedisClient(client *redis.Client) func(*mapConfig)

WithRedisClient configures the Map to use an existing Redis client.

Types

type Entry

type Entry struct {
	BackendID        any    `json:"backendID"` // per mcp spec, the ID can be string, int64, or float64
	ServerName       string `json:"serverName"`
	SessionID        string `json:"sessionID"`
	GatewaySessionID string `json:"gatewaySessionID"`
}

Entry holds a backend request ID and its associated server/session info.

type Map

type Map interface {
	// Store a new id mapping, returning the downstream gateway id
	Store(ctx context.Context, backendID any, serverName string, sessionID string, gatewaySessionID string) (string, error)
	// Lookup gets an entry for a gateway id without removing it.
	// Callers must call Remove explicitly after successful processing.
	Lookup(ctx context.Context, gatewayID string) (Entry, bool, error)
	// Remove is explicit best-effort removal for a gateway id
	Remove(ctx context.Context, gatewayID string)
}

Map stores and retrieves request ID mappings.

func New

func New(opts ...func(*mapConfig)) (Map, error)

New returns an initialized Map. Pass WithRedisClient to use a Redis-backed store; otherwise an in-memory store is returned.

Jump to

Keyboard shortcuts

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