routing

package
v1.0.38 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ValkeyChannelRoutingEvents is the pub/sub channel for route broadcasts.
	ValkeyChannelRoutingEvents = "carbon-panel:routing:events"
	// ValkeyRouteKeyPrefix is the key prefix for stored routes.
	ValkeyRouteKeyPrefix = "carbon-panel:routes:"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MockValkeyClient

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

MockValkeyClient provides an in-memory client for testing or standalone execution.

func NewMockValkeyClient

func NewMockValkeyClient() *MockValkeyClient

NewMockValkeyClient returns an in-memory Valkey client.

func (*MockValkeyClient) Close

func (m *MockValkeyClient) Close() error

Close marks the mock client closed.

func (*MockValkeyClient) DeleteRoute

func (m *MockValkeyClient) DeleteRoute(ctx context.Context, hostname string) error

DeleteRoute removes a route from memory.

func (*MockValkeyClient) GetRoute

func (m *MockValkeyClient) GetRoute(ctx context.Context, hostname string) (*RouteInfo, error)

GetRoute loads a route from memory.

func (*MockValkeyClient) Ping

func (m *MockValkeyClient) Ping(ctx context.Context) error

Ping reports whether the mock client is still open.

func (*MockValkeyClient) Publish

func (m *MockValkeyClient) Publish(ctx context.Context, channel string, message string) error

Publish delivers a message to in-memory subscribers.

func (*MockValkeyClient) SetRoute

func (m *MockValkeyClient) SetRoute(ctx context.Context, hostname string, route *RouteInfo) error

SetRoute stores a route in memory.

func (*MockValkeyClient) Subscribe

func (m *MockValkeyClient) Subscribe(ctx context.Context, channel string, onMessage func(channel, message string)) error

Subscribe registers an in-memory callback.

type RespClient

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

RespClient implements a lightweight Go-native Redis RESP protocol client.

func NewRespClient

func NewRespClient(addr string, password ...string) *RespClient

NewRespClient creates a new RESP client for Valkey or Dragonfly.

func (*RespClient) Close

func (c *RespClient) Close() error

Close shuts down command and subscription connections.

func (*RespClient) DeleteRoute

func (c *RespClient) DeleteRoute(ctx context.Context, hostname string) error

DeleteRoute removes a stored route.

func (*RespClient) GetRoute

func (c *RespClient) GetRoute(ctx context.Context, hostname string) (*RouteInfo, error)

GetRoute loads a stored route.

func (*RespClient) Ping

func (c *RespClient) Ping(ctx context.Context) error

Ping checks the Valkey connection.

func (*RespClient) Publish

func (c *RespClient) Publish(ctx context.Context, channel string, message string) error

Publish sends a pub/sub message.

func (*RespClient) SetRoute

func (c *RespClient) SetRoute(ctx context.Context, hostname string, route *RouteInfo) error

SetRoute stores a route under the shared key prefix.

func (*RespClient) Subscribe

func (c *RespClient) Subscribe(ctx context.Context, channel string, onMessage func(channel, message string)) error

Subscribe listens on a channel until ctx is canceled or the client is closed.

type RouteInfo

type RouteInfo struct {
	ServerID    string `json:"server_id"`
	Hostname    string `json:"hostname"`
	BackendHost string `json:"backend_host"`
	BackendPort int    `json:"backend_port"`
	ProxyPort   int    `json:"proxy_port"`
	UpdatedAt   int64  `json:"updated_at"`
}

RouteInfo holds stored route details in Valkey / Dragonfly KV.

type ValkeyClient

type ValkeyClient interface {
	Ping(ctx context.Context) error
	SetRoute(ctx context.Context, hostname string, route *RouteInfo) error
	GetRoute(ctx context.Context, hostname string) (*RouteInfo, error)
	DeleteRoute(ctx context.Context, hostname string) error
	Publish(ctx context.Context, channel string, message string) error
	Subscribe(ctx context.Context, channel string, onMessage func(channel, message string)) error
	Close() error
}

ValkeyClient is the Valkey/Dragonfly KV and pub/sub surface Cloud and the panel proxy share.

Jump to

Keyboard shortcuts

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