Documentation ¶
Index ¶
- type ClientConfigPatcher
- type Config
- type ConfigFilter
- type ConfigList
- type ConfigPatcher
- type ConfigStore
- type Conn
- type ConnTrack
- type Server
- func (s *Server) Close()
- func (s *Server) DeleteConfig(id string)
- func (s *Server) GetConfigChannel() chan Config
- 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) 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) RemoveClient(id string)
- func (s *Server) Start(ctx context.Context) error
- func (s *Server) UpdateConfig(newConfigs []Config) error
- func (s *Server) UpsertConfig(id string, c *stnrv1.StunnerConfig)
- func (s *Server) WSUpgradeMiddleware(next api.StrictHandlerFunc, operationID string) api.StrictHandlerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientConfigPatcher ¶ added in v0.17.1
type ClientConfigPatcher func(conf *stnrv1.StunnerConfig) (*stnrv1.StunnerConfig, error)
type Config ¶
type Config struct { Id string Config *stnrv1.StunnerConfig }
type ConfigFilter ¶ added in v0.17.1
ConfigFilter is a callback to filter config updates for a client.
type ConfigList ¶
type ConfigList = api.V1ConfigList
type ConfigPatcher ¶ added in v0.17.1
type ConfigPatcher func(conf *stnrv1.StunnerConfig, node string) (*stnrv1.StunnerConfig, error)
ConfigPatcher is a callback to patch config updates for a client.
type ConfigStore ¶
type ConfigStore struct {
// contains filtered or unexported fields
}
func NewConfigStore ¶
func NewConfigStore() *ConfigStore
func (*ConfigStore) Delete ¶
func (t *ConfigStore) Delete(id string)
func (*ConfigStore) Get ¶
func (t *ConfigStore) Get(id string) *stnrv1.StunnerConfig
func (*ConfigStore) Snapshot ¶
func (t *ConfigStore) Snapshot() []Config
func (*ConfigStore) Upsert ¶
func (t *ConfigStore) Upsert(id string, c *stnrv1.StunnerConfig)
type Conn ¶
type Conn struct { *websocket.Conn Filter ConfigFilter // contains filtered or unexported fields }
Conn represents a client WebSocket connection.
func NewConn ¶
func NewConn(conn *websocket.Conn, filter ConfigFilter, patch ClientConfigPatcher) *Conn
NewConn wraps a WebSocket connection.
func (*Conn) ReadMessage ¶
ReadMessage reads a message from the client connection with proper locking.
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 Server ¶
Server is a generic config discovery server implementation.
func New ¶
func New(addr string, patch ConfigPatcher, 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 should remove a config from the client. Theoretically, this would be done by sending the client a zero-config. However, 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 it, currently we suppress the config update.
func (*Server) GetConfigChannel ¶
GetConfigChannel returns the channel that can be used to add configs to the server's config store. Use Update to specify more configs at once.
func (*Server) GetConfigStore ¶
func (s *Server) GetConfigStore() *ConfigStore
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) 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) 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) UpsertConfig ¶
func (s *Server) UpsertConfig(id string, c *stnrv1.StunnerConfig)
UpsertConfig upserts a single config in the server.
func (*Server) WSUpgradeMiddleware ¶ added in v0.17.1
func (s *Server) WSUpgradeMiddleware(next api.StrictHandlerFunc, operationID string) api.StrictHandlerFunc