backends

package
v1.9.9 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TextMessage   = 1
	BinaryMessage = 2
	CloseMessage  = 8
	PingMessage   = 9
	PongMessage   = 10
)

MessageType constants for realtime connections (WebSocket compatible)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientBackend

type ClientBackend interface {
	// Send a raw JSON message (used for health checks and other simple operations)
	SendRawMessage(jsonString string, insecure bool) (string, error)

	// Send an RPC message with authentication
	SendMessage(method string, jsonString string, prvKey string, insecure bool, ctx context.Context) (string, error)

	// Check the health of the backend connection
	CheckHealth() error

	// Close the backend and clean up blueprints
	Close() error
}

ClientBackend defines the interface for different client transport implementations

type ClientBackendFactory

type ClientBackendFactory interface {
	CreateBackend(config *ClientConfig) (ClientBackend, error)
	GetBackendType() ClientBackendType
}

ClientBackendFactory creates backend-specific clients

type ClientBackendType

type ClientBackendType string

BackendType represents different client backend types

const (
	GinClientBackendType ClientBackendType = "gin"
)

func ParseClientBackendsFromEnv

func ParseClientBackendsFromEnv(backendsEnv string) []ClientBackendType

ParseClientBackendsFromEnv parses comma-separated backend types from environment variable e.g., "http" or "gin"

type ClientBackendWithRealtime

type ClientBackendWithRealtime interface {
	ClientBackend
	RealtimeBackend
}

ClientBackendWithRealtime extends ClientBackend with realtime capabilities

type ClientConfig

type ClientConfig struct {
	BackendType   ClientBackendType
	Host          string
	Port          int
	Insecure      bool
	SkipTLSVerify bool
}

ClientConfig holds configuration for client backends

func CreateDefaultClientConfig

func CreateDefaultClientConfig(host string, port int, insecure bool, skipTLSVerify bool) *ClientConfig

CreateDefaultClientConfig creates a default client config for HTTP/Gin backend

type MultiBackendClient

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

MultiBackendClient implements ClientBackend by trying multiple backends in order

func NewMultiBackendClient

func NewMultiBackendClient(configs []*ClientConfig, factories map[ClientBackendType]ClientBackendFactory) (*MultiBackendClient, error)

NewMultiBackendClient creates a client that tries multiple backends with fallback

func (*MultiBackendClient) CheckHealth

func (m *MultiBackendClient) CheckHealth() error

CheckHealth checks health of all backends and returns error if all are unhealthy

func (*MultiBackendClient) Close

func (m *MultiBackendClient) Close() error

Close closes all backends

func (*MultiBackendClient) SendMessage

func (m *MultiBackendClient) SendMessage(method string, jsonString string, prvKey string, insecure bool, ctx context.Context) (string, error)

SendMessage tries each backend in order until one succeeds

func (*MultiBackendClient) SendRawMessage

func (m *MultiBackendClient) SendRawMessage(jsonString string, insecure bool) (string, error)

SendRawMessage tries each backend in order until one succeeds

type RealtimeBackend

type RealtimeBackend interface {
	// EstablishRealtimeConn establishes a realtime connection for real-time operations
	EstablishRealtimeConn(jsonString string) (RealtimeConnection, error)
}

RealtimeBackend defines the interface for establishing realtime connections

type RealtimeConnection

type RealtimeConnection interface {
	// WriteMessage writes a message to the realtime connection
	WriteMessage(messageType int, data []byte) error

	// ReadMessage reads a message from the realtime connection
	ReadMessage() (messageType int, data []byte, err error)

	// Close closes the realtime connection
	Close() error

	// SetReadLimit sets the maximum size for incoming messages
	SetReadLimit(limit int64)
}

RealtimeConnection represents a generic realtime connection interface Different backends can implement this using WebSockets.

Jump to

Keyboard shortcuts

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