Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var HEADER_SPARK_SESSION_ID string = "x-spark-connect-session-id"
Functions ¶
func CreateRouter ¶
func CreateRouter(service *SparkConnectProxy) proxy.StreamDirector
Types ¶
type MaxSessionsPolicy ¶
type MaxSessionsPolicy struct {
// contains filtered or unexported fields
}
MaxSessionsPolicy is a policy that limits the number of sessions that can be associated with a single backend. For that reason the policy has to track how many new sessions are associated with a single backend.
func (*MaxSessionsPolicy) Release ¶
func (p *MaxSessionsPolicy) Release(id string) error
func (*MaxSessionsPolicy) SetLogger ¶
func (p *MaxSessionsPolicy) SetLogger(logger *slog.Logger)
type OneToOnePolicy ¶
type OneToOnePolicy struct {
// contains filtered or unexported fields
}
OneToOnePolicy is a policy that assigns a single backend to each session.
func (*OneToOnePolicy) Release ¶
func (p *OneToOnePolicy) Release(id string) error
func (*OneToOnePolicy) SetLogger ¶
func (p *OneToOnePolicy) SetLogger(logger *slog.Logger)
type ProxyState ¶
type ProxyState struct {
// contains filtered or unexported fields
}
ProxyState represents the state of the proxy. It captures the list of konwn backends and the mapping of sessions to backends. These members are protected by a mutex to make the state thread-safe.
To register a new session in the state, the caller has to call StartSession. Removing a session from the state is done by calling StopSession.
Backends can always be added, but they can only be removed when no sessions are assigned to them.
func NewProxyState ¶
func NewProxyState(bp connect.BackendProvider, loadPolicy connect.LoadPolicy, logger *slog.Logger) *ProxyState
NewProxyState creates a new proxy state.
func (*ProxyState) GetBackendForSession ¶
func (p *ProxyState) GetBackendForSession(sessionID string) (proxy.Backend, error)
func (*ProxyState) SetLogger ¶
func (p *ProxyState) SetLogger(logger *slog.Logger)
SetLogger sets the logger for the proxy state and propagates it to the backend provider and load policy
func (*ProxyState) StartSession ¶
func (p *ProxyState) StartSession() (string, error)
StartSession assigns a backend to a new session and returns the session ID. The backend for the session is mapped randomly across all available backends.
func (*ProxyState) StopSession ¶
func (p *ProxyState) StopSession(id string) error
StopSession removes a session from the proxy state.
type RoundRobinPolicy ¶
type RoundRobinPolicy struct {
// contains filtered or unexported fields
}
RoundRobinPolicy is a policy that selects backends in a round-robin fashion.
func (*RoundRobinPolicy) Release ¶
func (p *RoundRobinPolicy) Release(id string) error
func (*RoundRobinPolicy) SetLogger ¶
func (p *RoundRobinPolicy) SetLogger(logger *slog.Logger)
type SparkConnectProxy ¶
type SparkConnectProxy struct {
// contains filtered or unexported fields
}
func NewSparkConnectProxy ¶
func NewSparkConnectProxy(bp connect.BackendProvider, lp config.LoadPolicyConfig, logger *slog.Logger) *SparkConnectProxy
NewSparkConnectProxy sets up our proxy with an empty routing table and a metrics registry.
func (*SparkConnectProxy) CreateStreamHandler ¶
func (p *SparkConnectProxy) CreateStreamHandler() grpc.StreamHandler
func (*SparkConnectProxy) State ¶
func (p *SparkConnectProxy) State() *ProxyState