Documentation
¶
Index ¶
- Constants
- Variables
- func NamespacedName(id string) (string, string, bool)
- type Config
- type ConfigList
- type ConfigStore
- func (cs *ConfigStore) Delete(namespace, name string, stnrConfig *stnrv2.StunnerConfig)
- func (cs *ConfigStore) Get(namespace, name string) (*Config, bool)
- func (cs *ConfigStore) Patch(config *Config, labels map[string]string) *Config
- func (cs *ConfigStore) Refresh()
- func (cs *ConfigStore) Snapshot() []*Config
- func (cs *ConfigStore) SubscribeAll() chan *Config
- func (cs *ConfigStore) SubscribeConfig(namespace, name string, labels map[string]string) chan *Config
- func (cs *ConfigStore) SubscribeNamespace(namespace string) chan *Config
- func (cs *ConfigStore) Unsubscribe(ch chan *Config)
- func (cs *ConfigStore) UnsubscribeAll()
- func (cs *ConfigStore) Upsert(namespace, name string, stnrConfig *stnrv2.StunnerConfig)
- type Conn
- type ConnTrack
- type LicenseStore
- type Patcher
- type Server
- func (s *Server) Close()
- func (s *Server) DeleteConfig(id string)
- func (s *Server) GetConfigStore() *ConfigStore
- 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) Refresh()
- 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 stnrv2.LicenseStatus)
- func (s *Server) UpsertConfig(id string, c *stnrv2.StunnerConfig)
- func (s *Server) WSUpgradeMiddleware(next api.StrictHandlerFunc, operationID string) api.StrictHandlerFunc
Constants ¶
const SubscribeChannelBufferSize = 256
SubscribeChannelBufferSize is the number of config updates a subscription can hold.
Variables ¶
var ( // SuppressConfigDeletion allows the server to suppress config deletions all together. Used // mostly for testing. SuppressConfigDeletion = false )
Functions ¶
Types ¶
type Config ¶
type Config struct {
Namespace, Name string
Config *stnrv2.StunnerConfig
}
type ConfigList ¶
type ConfigList = api.V1ConfigList
type ConfigStore ¶
type ConfigStore struct {
// contains filtered or unexported fields
}
ConfigStore holds the configs and pushes every subscriber the config it would get, patched for the subscriber, whenever that differs from what the subscriber was last sent.
func NewConfigStore ¶
func NewConfigStore(patcher Patcher) *ConfigStore
NewConfigStore creates a config store that patches the configs of its subscribers, nil for no patching.
func (*ConfigStore) Delete ¶
func (cs *ConfigStore) Delete(namespace, name string, stnrConfig *stnrv2.StunnerConfig)
Delete removes a config and pushes the supplied config, usually a zero-config, to the subscribers; nil pushes nothing.
func (*ConfigStore) Get ¶
func (cs *ConfigStore) Get(namespace, name string) (*Config, bool)
Get retrieves a config.
func (*ConfigStore) Patch ¶
func (cs *ConfigStore) Patch(config *Config, labels map[string]string) *Config
Patch returns a copy of a config patched for a client with labels.
func (*ConfigStore) Refresh ¶
func (cs *ConfigStore) Refresh()
Refresh patches every config again for every subscriber and pushes what changed: call it whenever what the patcher depends on may have changed.
func (*ConfigStore) Snapshot ¶
func (cs *ConfigStore) Snapshot() []*Config
Snapshot copies out all configs.
func (*ConfigStore) SubscribeAll ¶
func (cs *ConfigStore) SubscribeAll() chan *Config
SubscribeAll subscribes to all config changes, unpatched.
func (*ConfigStore) SubscribeConfig ¶
func (cs *ConfigStore) SubscribeConfig(namespace, name string, labels map[string]string) chan *Config
SubscribeConfig subscribes to the changes of a config, patched for a client with labels.
func (*ConfigStore) SubscribeNamespace ¶
func (cs *ConfigStore) SubscribeNamespace(namespace string) chan *Config
SubscribeNamespace subscribes to all config changes in a namespace, unpatched.
func (*ConfigStore) Unsubscribe ¶
func (cs *ConfigStore) Unsubscribe(ch chan *Config)
Unsubscribe removes a subscription and closes its channel.
func (*ConfigStore) UnsubscribeAll ¶
func (cs *ConfigStore) UnsubscribeAll()
UnsubscribeAll removes all subscriptions.
func (*ConfigStore) Upsert ¶
func (cs *ConfigStore) Upsert(namespace, name string, stnrConfig *stnrv2.StunnerConfig)
Upsert sets or updates a config and pushes it to the 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 LicenseStore ¶
type LicenseStore struct {
// contains filtered or unexported fields
}
func NewLicenseStore ¶
func NewLicenseStore() *LicenseStore
func (*LicenseStore) Get ¶
func (t *LicenseStore) Get() stnrv2.LicenseStatus
func (*LicenseStore) Upsert ¶
func (t *LicenseStore) Upsert(s stnrv2.LicenseStatus)
type Patcher ¶
type Patcher func(conf *stnrv2.StunnerConfig, id string, labels map[string]string) *stnrv2.StunnerConfig
Patcher rewrites the config the server serves a client, given the config id the client watches and the labels it describes itself with; the server interprets neither the labels nor the patch. It gets a copy of its own and may modify it.
type Server ¶
Server is a generic config discovery server implementation.
func New ¶
New creates a new config discovery server instance for the specified address, patching the config it serves each client with patcher; nil patches nothing.
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 abruptly kill all listeners with all active connections allocated to them.
func (*Server) GetConfigStore ¶
func (s *Server) GetConfigStore() *ConfigStore
GetConfigStore returns the dataplane config-store of 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 ¶
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) Refresh ¶
func (s *Server) Refresh()
Refresh patches every config again for every client and pushes those that changed: call it whenever what the patcher depends on may have changed.
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 ¶
func (s *Server) UpdateLicenseStatus(status stnrv2.LicenseStatus)
UpdateLicenseStatus updates the licensing status that is served by the server.
func (*Server) UpsertConfig ¶
func (s *Server) UpsertConfig(id string, c *stnrv2.StunnerConfig)
func (*Server) WSUpgradeMiddleware ¶
func (s *Server) WSUpgradeMiddleware(next api.StrictHandlerFunc, operationID string) api.StrictHandlerFunc