Documentation ¶
Index ¶
- func NewRouter(localRouter *LocalRouter, clusterRouter *clusterrouter.Router, ...) router.C2SRouter
- type ListenerConfig
- type ListenersConfig
- type LocalRouter
- func (r *LocalRouter) Bind(id stream.C2SID) (stream.C2S, error)
- func (r *LocalRouter) Disconnect(username, resource string, streamErr *streamerror.Error) error
- func (r *LocalRouter) Register(stm stream.C2S) error
- func (r *LocalRouter) Route(stanza stravaganza.Stanza, username, resource string) error
- func (r *LocalRouter) Start(_ context.Context) error
- func (r *LocalRouter) Stop(ctx context.Context) error
- func (r *LocalRouter) Stream(username, resource string) stream.C2S
- func (r *LocalRouter) Unregister(stm stream.C2S) error
- type SocketListener
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRouter ¶
func NewRouter( localRouter *LocalRouter, clusterRouter *clusterrouter.Router, resMng resourcemanager.Manager, rep repository.Repository, hk *hook.Hooks, logger kitlog.Logger, ) router.C2SRouter
NewRouter creates and returns an initialized C2S router.
Types ¶
type ListenerConfig ¶ added in v0.55.0
type ListenerConfig struct { // BindAddr defines listener incoming connections address. BindAddr string `fig:"bind_addr"` // Port defines listener incoming connections port. Port int `fig:"port" default:"5222"` // Transport specifies the type of transport used for incoming connections. Transport string `fig:"transport" default:"socket"` // DirectTLS, if true, tls.Listen will be used as network listener. DirectTLS bool `fig:"direct_tls"` // SASL contains authentication related configuration. SASL struct { // Mechanisms contains enabled SASL mechanisms. Mechanisms []string `fig:"mechanisms" default:"[scram_sha_1, scram_sha_256, scram_sha_512, scram_sha3_512]"` // External contains external authenticator configuration. External struct { Address string `fig:"address"` IsSecure bool `fig:"is_secure"` } `fig:"external"` } `fig:"sasl"` // CompressionLevel is the compression level that may be applied to the stream. // Valid values are 'default', 'best', 'speed' and 'no_compression'. CompressionLevel string `fig:"compression_level" default:"default"` // ResourceConflict defines the which rule should be applied in a resource conflict is detected. // Valid values are `override`, `disallow` and `terminate_old`. ResourceConflict string `fig:"resource_conflict" default:"terminate_old"` // MaxStanzaSize is the maximum size a listener incoming stanza may have. MaxStanzaSize int `fig:"max_stanza_size" default:"524288"` // ConnectTimeout defines connection timeout. ConnectTimeout time.Duration `fig:"conn_timeout" default:"3s"` // AuthenticateTimeout defines authentication timeout. AuthenticateTimeout time.Duration `fig:"auth_timeout" default:"10s"` // KeepAliveTimeout defines the maximum amount of time that an inactive connection // would be considered alive. KeepAliveTimeout time.Duration `fig:"keep_alive_timeout" default:"3m"` // RequestTimeout defines C2S stream request timeout. RequestTimeout time.Duration `fig:"req_timeout" default:"15s"` }
ListenerConfig contains a C2S listener configuration.
type ListenersConfig ¶ added in v0.55.0
type ListenersConfig []ListenerConfig
ListenersConfig defines a set of C2S listener configurations.
type LocalRouter ¶
type LocalRouter struct {
// contains filtered or unexported fields
}
LocalRouter represents a cluster local router.
func NewLocalRouter ¶
func NewLocalRouter(hosts *host.Hosts) *LocalRouter
NewLocalRouter returns a new initialized local router.
func (*LocalRouter) Disconnect ¶
func (r *LocalRouter) Disconnect(username, resource string, streamErr *streamerror.Error) error
Disconnect performs disconnection over a local router resource.
func (*LocalRouter) Register ¶
func (r *LocalRouter) Register(stm stream.C2S) error
Register registers a local router stream.
func (*LocalRouter) Route ¶
func (r *LocalRouter) Route(stanza stravaganza.Stanza, username, resource string) error
Route routes a stanza to a local router resource.
func (*LocalRouter) Start ¶
func (r *LocalRouter) Start(_ context.Context) error
Start starts local router.
func (*LocalRouter) Stop ¶
func (r *LocalRouter) Stop(ctx context.Context) error
Stop stops local router.
func (*LocalRouter) Stream ¶
func (r *LocalRouter) Stream(username, resource string) stream.C2S
Stream returns stream identified by username and resource.
func (*LocalRouter) Unregister ¶
func (r *LocalRouter) Unregister(stm stream.C2S) error
Unregister unregisters a local router resource.
type SocketListener ¶
type SocketListener struct {
// contains filtered or unexported fields
}
SocketListener represents a C2S socket listener type.
func NewListeners ¶ added in v0.55.0
func NewListeners( cfg ListenersConfig, hosts *host.Hosts, router router.Router, comps *component.Components, mods *module.Modules, resMng resourcemanager.Manager, rep repository.Repository, peppers *pepper.Keys, shapers shaper.Shapers, hk *hook.Hooks, logger kitlog.Logger, ) []*SocketListener
NewListeners creates and initializes a set of C2S listeners based of cfg configuration.