Documentation ¶
Index ¶
- Variables
- func MockCloser(id string)
- func MockEstablisher(id string, c net.Conn, ac auth.Controller) error
- type CloseFunc
- type Config
- type EstablishFunc
- type HTTPStats
- type Listener
- type Listeners
- func (l *Listeners) Add(val Listener)
- func (l *Listeners) Close(id string, closer CloseFunc)
- func (l *Listeners) CloseAll(closer CloseFunc)
- func (l *Listeners) Delete(id string)
- func (l *Listeners) Get(id string) (Listener, bool)
- func (l *Listeners) Len() int
- func (l *Listeners) Serve(id string, establisher EstablishFunc)
- func (l *Listeners) ServeAll(establisher EstablishFunc)
- type MockListener
- func (l *MockListener) Close(closer CloseFunc)
- func (l *MockListener) ID() string
- func (l *MockListener) IsListening() bool
- func (l *MockListener) IsServing() bool
- func (l *MockListener) Listen(s *system.Info) error
- func (l *MockListener) Serve(establisher EstablishFunc)
- func (l *MockListener) SetConfig(config *Config)
- type TCP
- type TLSdeprecated
- type Websocket
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidMessage indicates that a message payload was not valid. ErrInvalidMessage = errors.New("message type not binary") )
Functions ¶
func MockCloser ¶
func MockCloser(id string)
MockCloser is a function signature which can be used in testing.
func MockEstablisher ¶
MockEstablisher is a function signature which can be used in testing.
Types ¶
type CloseFunc ¶
type CloseFunc func(id string)
CloseFunc is a callback function for closing all listener clients.
type Config ¶
type Config struct { // Auth controller containing auth and ACL logic for // allowing or denying access to the server and topics. Auth auth.Controller // TLS certficates and settings for the connection. // // Deprecated: Prefer exposing the tls.Config directly for greater flexibility. // Please use TLSConfig instead. TLS *TLS // TLSConfig is a tls.Config configuration to be used with the listener. // See examples folder for basic and mutual-tls use. TLSConfig *tls.Config }
Config contains configuration values for a listener.
type EstablishFunc ¶
EstablishFunc is a callback function for establishing new clients.
type HTTPStats ¶
HTTPStats is a listener for presenting the server $SYS stats on a JSON http endpoint.
func NewHTTPStats ¶
NewHTTPStats initialises and returns a new HTTP listener, listening on an address.
func (*HTTPStats) Serve ¶
func (l *HTTPStats) Serve(establish EstablishFunc)
Serve starts listening for new connections and serving responses.
type Listener ¶
type Listener interface { SetConfig(*Config) // set the listener config. Listen(s *system.Info) error // open the network address. Serve(EstablishFunc) // starting actively listening for new connections. ID() string // return the id of the listener. Close(CloseFunc) // stop and close the listener. }
Listener is an interface for network listeners. A network listener listens for incoming client connections and adds them to the server.
type Listeners ¶
Listeners contains the network listeners for the broker.
func (*Listeners) Serve ¶
func (l *Listeners) Serve(id string, establisher EstablishFunc)
Serve starts a listener serving from the internal map.
func (*Listeners) ServeAll ¶
func (l *Listeners) ServeAll(establisher EstablishFunc)
ServeAll starts all listeners serving from the internal map.
type MockListener ¶
type MockListener struct { sync.RWMutex Config *Config // configuration for the listener. Serving bool // indicate the listener is serving. Listening bool // indiciate the listener is listening. ErrListen bool // throw an error on listen. // contains filtered or unexported fields }
MockListener is a mock listener for establishing client connections.
func NewMockListener ¶
func NewMockListener(id, address string) *MockListener
NewMockListener returns a new instance of MockListener
func (*MockListener) Close ¶
func (l *MockListener) Close(closer CloseFunc)
Close closes the mock listener.
func (*MockListener) ID ¶
func (l *MockListener) ID() string
ID returns the id of the mock listener.
func (*MockListener) IsListening ¶
func (l *MockListener) IsListening() bool
IsListening indicates whether the mock listener is listening.
func (*MockListener) IsServing ¶
func (l *MockListener) IsServing() bool
IsServing indicates whether the mock listener is serving.
func (*MockListener) Listen ¶
func (l *MockListener) Listen(s *system.Info) error
Listen begins listening for incoming traffic.
func (*MockListener) Serve ¶
func (l *MockListener) Serve(establisher EstablishFunc)
Serve serves the mock listener.
func (*MockListener) SetConfig ¶
func (l *MockListener) SetConfig(config *Config)
SetConfig sets the configuration values of the mock listener.
type TCP ¶
TCP is a listener for establishing client connections on basic TCP protocol.
func (*TCP) Serve ¶
func (l *TCP) Serve(establish EstablishFunc)
Serve starts waiting for new TCP connections, and calls the establish connection callback for any received.
type TLS
deprecated
type TLS struct { Certificate []byte // the body of a public certificate. PrivateKey []byte // the body of a private key. }
TLS contains the TLS certificates and settings for the listener connection.
Deprecated: Prefer exposing the tls.Config directly for greater flexibility. Please use TLSConfig instead.
type Websocket ¶
Websocket is a listener for establishing websocket connections.
func NewWebsocket ¶
NewWebsocket initialises and returns a new Websocket listener, listening on an address.
func (*Websocket) Serve ¶
func (l *Websocket) Serve(establish EstablishFunc)
Serve starts waiting for new Websocket connections, and calls the connection establishment callback for any received.