Documentation
¶
Index ¶
- Variables
- func NamespacedName(id string) (string, string, bool)
- type ClientFilter
- type Config
- type ConfigList
- type ConfigNodePatcher
- type ConfigStore
- func (cs *ConfigStore[T]) Delete(namespace, name string, stnrConfig *stnrv1.StunnerConfig)
- func (cs *ConfigStore[_]) Get(namespace, name string) (*Config, bool)
- func (cs *ConfigStore[T]) Push(arg T)
- func (cs *ConfigStore[_]) Snapshot() []*Config
- func (cs *ConfigStore[T]) SubscribeAll(filter ClientFilter[T], patcher PatchFunc) chan *Config
- func (cs *ConfigStore[T]) SubscribeConfig(namespace, name string, filter ClientFilter[T], patcher PatchFunc) chan *Config
- func (cs *ConfigStore[T]) SubscribeNamespace(namespace string, filter ClientFilter[T], patcher PatchFunc) chan *Config
- func (cs *ConfigStore[_]) Unsubscribe(ch chan *Config)
- func (cs *ConfigStore[T]) UnsubscribeAll()
- func (cs *ConfigStore[T]) Upsert(namespace, name string, stnrConfig *stnrv1.StunnerConfig)
- type Conn
- type ConnTrack
- type FilterFunc
- type LicenseStore
- type PatchFunc
- type Server
- func (s *Server) Close()
- func (s *Server) DeleteConfig(id string)
- func (s *Server) GetConfigStore() *ConfigStore[string]
- func (s *Server) GetConnTrack() *ConnTrack
- func (s *Server) GetV1ConfigNamespaceName(ctx context.Context, request api.GetV1ConfigNamespaceNameRequestObject) (api.GetV1ConfigNamespaceNameResponseObject, error)
- func (s *Server) GetV1LicenseStatus(ctx context.Context, request api.GetV1LicenseStatusRequestObject) (api.GetV1LicenseStatusResponseObject, error)
- func (s *Server) ListV1Configs(ctx context.Context, request api.ListV1ConfigsRequestObject) (api.ListV1ConfigsResponseObject, error)
- func (s *Server) ListV1ConfigsNamespace(ctx context.Context, request api.ListV1ConfigsNamespaceRequestObject) (api.ListV1ConfigsNamespaceResponseObject, error)
- func (s *Server) PushNodeConfig(node string)
- func (s *Server) RemoveClient(id string)
- func (s *Server) Start(ctx context.Context) error
- func (s *Server) UpdateConfig(newConfigs []Config) error
- func (s *Server) UpdateLicenseStatus(status stnrv1.LicenseStatus)
- func (s *Server) UpsertConfig(id string, c *stnrv1.StunnerConfig)
- func (s *Server) WSUpgradeMiddleware(next api.StrictHandlerFunc, operationID string) api.StrictHandlerFunc
- type Subscription
Constants ¶
This section is empty.
Variables ¶
var ( // SuppressConfigDeletion allows the server to suppress config deletions all together. Used // mostly for testing. SuppressConfigDeletion = false )
Functions ¶
Types ¶
type ClientFilter ¶ added in v1.1.0
type ClientFilter[T comparable] func(expectedValue T) bool
ClientFilter lets a client to filter push notifications.
type Config ¶
type Config struct {
Namespace, Name string
Config *stnrv1.StunnerConfig
}
type ConfigList ¶
type ConfigList = api.V1ConfigList
type ConfigNodePatcher ¶ added in v1.1.0
type ConfigNodePatcher func(conf *stnrv1.StunnerConfig, node string) *stnrv1.StunnerConfig
ConfigNodePatcher is a callback to patch config updates per node name.
type ConfigStore ¶
type ConfigStore[T comparable] struct { // contains filtered or unexported fields }
func NewConfigStore ¶
func NewConfigStore[T comparable]() *ConfigStore[T]
func (*ConfigStore[T]) Delete ¶
func (cs *ConfigStore[T]) Delete(namespace, name string, stnrConfig *stnrv1.StunnerConfig)
Delete removes the config from the store and optionally sends the supplied config (usually a zero-config) to affected clients.
func (*ConfigStore[_]) Get ¶
func (cs *ConfigStore[_]) Get(namespace, name string) (*Config, bool)
Get retrieves a config
func (*ConfigStore[T]) Push ¶ added in v1.1.0
func (cs *ConfigStore[T]) Push(arg T)
Push will re-broadcast configs to interested clients.
func (*ConfigStore[_]) Snapshot ¶
func (cs *ConfigStore[_]) Snapshot() []*Config
Snapshot copies out all configs.
func (*ConfigStore[T]) SubscribeAll ¶ added in v1.1.0
func (cs *ConfigStore[T]) SubscribeAll(filter ClientFilter[T], patcher PatchFunc) chan *Config
SubscribeAll subscribes to all config changes
func (*ConfigStore[T]) SubscribeConfig ¶ added in v1.1.0
func (cs *ConfigStore[T]) SubscribeConfig(namespace, name string, filter ClientFilter[T], patcher PatchFunc) chan *Config
SubscribeConfig subscribes to changes for a specific config
func (*ConfigStore[T]) SubscribeNamespace ¶ added in v1.1.0
func (cs *ConfigStore[T]) SubscribeNamespace(namespace string, filter ClientFilter[T], patcher PatchFunc) chan *Config
SubscribeNamespace subscribes to all config changes in a specific namespace
func (*ConfigStore[_]) Unsubscribe ¶ added in v1.1.0
func (cs *ConfigStore[_]) Unsubscribe(ch chan *Config)
Unsubscribe removes a subscription
func (*ConfigStore[T]) UnsubscribeAll ¶ added in v1.1.0
func (cs *ConfigStore[T]) UnsubscribeAll()
Unsubscribe removes a subscription
func (*ConfigStore[T]) Upsert ¶
func (cs *ConfigStore[T]) Upsert(namespace, name string, stnrConfig *stnrv1.StunnerConfig)
Upsert sets or updates a config and notifies subscribers.
type Conn ¶
Conn represents a client WebSocket connection.
type ConnTrack ¶
type ConnTrack struct {
// contains filtered or unexported fields
}
ConnTrack represents the server's connection tracking table.
func NewConnTrack ¶
func NewConnTrack() *ConnTrack
NewConnTrack creates a new connection tracking table.
type FilterFunc ¶ added in v1.1.0
FilterFunc allows clients to filter configs.
type LicenseStore ¶ added in v1.1.0
type LicenseStore struct {
// contains filtered or unexported fields
}
func NewLicenseStore ¶ added in v1.1.0
func NewLicenseStore() *LicenseStore
func (*LicenseStore) Get ¶ added in v1.1.0
func (t *LicenseStore) Get() stnrv1.LicenseStatus
func (*LicenseStore) Upsert ¶ added in v1.1.0
func (t *LicenseStore) Upsert(s stnrv1.LicenseStatus)
type PatchFunc ¶ added in v1.1.0
type PatchFunc func(conf *stnrv1.StunnerConfig) *stnrv1.StunnerConfig
PatchFunc is a callback to patch config updates for a client.
type Server ¶
Server is a generic config discovery server implementation.
func New ¶
func New(addr string, patch ConfigNodePatcher, logger logr.Logger) *Server
New creates a new config discovery server instance for the specified address.
func (*Server) Close ¶
func (s *Server) Close()
Close closes the server and drops all active connections.
func (*Server) DeleteConfig ¶
DeleteConfig removes a config from clients by sending a zero-config. Clients may decide to ignore the delete operation by (1) using client.IsConfigDeleted() to identify whether a config is being deleted and (2) selectively ignoring config delete updates based on the result. This is needed, e.g., in stunnerd, in order to avoid that a client being removed and entering the graceful shutdown cycle receive a zeroconfig and abruprly kill all listeners with all active connections allocated to them.
func (*Server) GetConfigStore ¶
func (s *Server) GetConfigStore() *ConfigStore[string]
GetConfigStore returns the dataplane configs stores in the server.
func (*Server) GetConnTrack ¶
GetConnTrack returns the client connection tracking table of the server.
func (*Server) GetV1ConfigNamespaceName ¶
func (s *Server) GetV1ConfigNamespaceName(ctx context.Context, request api.GetV1ConfigNamespaceNameRequestObject) (api.GetV1ConfigNamespaceNameResponseObject, error)
(GET /api/v1/configs/{namespace}/{name})
func (*Server) GetV1LicenseStatus ¶ added in v1.1.0
func (s *Server) GetV1LicenseStatus(ctx context.Context, request api.GetV1LicenseStatusRequestObject) (api.GetV1LicenseStatusResponseObject, error)
(GET /api/v1/license)
func (*Server) ListV1Configs ¶
func (s *Server) ListV1Configs(ctx context.Context, request api.ListV1ConfigsRequestObject) (api.ListV1ConfigsResponseObject, error)
(GET /api/v1/configs)
func (*Server) ListV1ConfigsNamespace ¶
func (s *Server) ListV1ConfigsNamespace(ctx context.Context, request api.ListV1ConfigsNamespaceRequestObject) (api.ListV1ConfigsNamespaceResponseObject, error)
(GET /api/v1/configs/{namespace})
func (*Server) PushNodeConfig ¶ added in v1.1.0
PusNodeConfig updates the config at each known client that is subscribed for updates on a given node. This is useful for force pushing a new config when some node address changes.
func (*Server) RemoveClient ¶
RemoveClient forcefully closes a client connection. This is used mainly for testing.
func (*Server) UpdateConfig ¶
UpdateConfig receives a set of ids and newConfigs that represent the state-of-the-world at a particular instance of time and generates an update per each change.
func (*Server) UpdateLicenseStatus ¶ added in v1.1.0
func (s *Server) UpdateLicenseStatus(status stnrv1.LicenseStatus)
UpdateLicenseStatus updates the licensing status that is served by the server.
func (*Server) UpsertConfig ¶
func (s *Server) UpsertConfig(id string, c *stnrv1.StunnerConfig)
func (*Server) WSUpgradeMiddleware ¶ added in v0.17.1
func (s *Server) WSUpgradeMiddleware(next api.StrictHandlerFunc, operationID string) api.StrictHandlerFunc
type Subscription ¶ added in v1.1.0
type Subscription[T comparable] struct { // contains filtered or unexported fields }