server

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Id     string
	Config *stnrv1.StunnerConfig
}

func (Config) String

func (e Config) String() string

type ConfigList

type ConfigList struct {
	Version string                  `json:"version"`
	Items   []*stnrv1.StunnerConfig `json:"items"`
}

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 FilterConfig
	// contains filtered or unexported fields
}

Conn represents a client WebSocket connection.

func NewConn

func NewConn(conn *websocket.Conn, filter FilterConfig) *Conn

NewConn wraps a WebSocket connection.

func (*Conn) Id

func (c *Conn) Id() string

Id returns the IP 5-tuple for a client connection.

func (*Conn) ReadMessage

func (c *Conn) ReadMessage() (int, []byte, error)

ReadMessage reads a message from the client connection with proper locking.

func (*Conn) WriteMessage

func (c *Conn) WriteMessage(messageType int, data []byte) error

WriteMessage writes a message to 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.

func (*ConnTrack) Delete

func (t *ConnTrack) Delete(conn *Conn)

Delete removes a client connection.

func (*ConnTrack) Get

func (t *ConnTrack) Get(cid string) *Conn

Get returns a client connection by the IP 5-tuple.

func (*ConnTrack) Snapshot

func (t *ConnTrack) Snapshot() []*Conn

Snapshot creates a snapshot of the connection tracking table.

func (*ConnTrack) Upsert

func (t *ConnTrack) Upsert(c *Conn)

Upsert insert a new client connection.

type Error

type Error struct {
	// Code Error code
	Code int32 `json:"code"`

	// Message Error message
	Message string `json:"message"`
}

Error defines model for Error.

func (Error) Error

func (e Error) Error() string

type FilterConfig

type FilterConfig func(confId string) bool

FilterConfig is a callback to filter config updates for a client.

type ResponseGen

type ResponseGen func() ([]byte, *Error)

ResponseGen is a callback to generate a response to a request (also used for sending the initial config dump for watches).

type Server

type Server struct {
	*http.Server
	// contains filtered or unexported fields
}

Server is a generic config discovery server implementation.

func New

func New(addr string, 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

func (s *Server) DeleteConfig(id string)

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

func (s *Server) GetConfigChannel() chan Config

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

func (s *Server) GetConnTrack() *ConnTrack

GetConnTrack returns the client connection tracking table of the server.

func (*Server) GetV1ConfigNamespaceName

func (s *Server) GetV1ConfigNamespaceName(w http.ResponseWriter, r *http.Request, namespace string, name string, params api.GetV1ConfigNamespaceNameParams)

(GET /api/v1/configs/{namespace}/{name})

func (*Server) ListV1Configs

func (s *Server) ListV1Configs(w http.ResponseWriter, r *http.Request, params api.ListV1ConfigsParams)

(GET /api/v1/configs)

func (*Server) ListV1ConfigsNamespace

func (s *Server) ListV1ConfigsNamespace(w http.ResponseWriter, r *http.Request, namespace string, params api.ListV1ConfigsNamespaceParams)

(GET /api/v1/configs/{namespace})

func (*Server) RemoveClient

func (s *Server) RemoveClient(id string)

RemoveClient forcefully closes a client connection. This is used mainly for testing.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start let the config discovery server listen to new client connections.

func (*Server) UpdateConfig

func (s *Server) UpdateConfig(newConfigs []Config) error

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.

Directories

Path Synopsis
Package api provides primitives to interact with the openapi HTTP API.
Package api provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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