Documentation ¶
Index ¶
- func NewRouter(localRouter *LocalRouter, clusterRouter *clusterrouter.Router, ...) router.C2SRouter
- type Config
- 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 ResourceConflict
- type ResourceManager
- func (m *ResourceManager) DelResource(ctx context.Context, username, resource string) error
- func (m *ResourceManager) GetResource(ctx context.Context, username, resource string) (*c2smodel.Resource, error)
- func (m *ResourceManager) GetResources(ctx context.Context, username string) ([]c2smodel.Resource, error)
- func (m *ResourceManager) PutResource(ctx context.Context, res *c2smodel.Resource) 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, rep repository.Repository, hk *hook.Hooks, ) router.C2SRouter
NewRouter creates and returns an initialized C2S router.
Types ¶
type Config ¶
type Config struct { // ConnectTimeout defines connection timeout. ConnectTimeout time.Duration // AuthenticateTimeout defines authentication timeout. AuthenticateTimeout time.Duration // KeepAliveTimeout defines the maximum amount of time that an inactive connection // would be considered alive. KeepAliveTimeout time.Duration // RequestTimeout defines C2S stream request timeout. RequestTimeout time.Duration // MaxStanzaSize is the maximum size a listener incoming stanza may have. MaxStanzaSize int // CompressionLevel is the compression level that may be applied to the stream. // Valid values are 'default', 'best', 'speed' and 'no_compression'. CompressionLevel compress.Level // ResourceConflict defines the which rule should be applied in a resource conflict is detected. // Valid values are `override`, `disallow` and `terminate_old`. ResourceConflict ResourceConflict // UseTLS, if true, tls.Listen will be used as network listener. UseTLS bool // TLSConfig contains configuration to be used when TLS listener is enabled. TLSConfig *tls.Config }
Config defines C2S connection configuration.
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 ResourceConflict ¶
type ResourceConflict int8
ResourceConflict represents a resource conflict policy.
const ( // Override represents 'override' resource conflict policy. Override ResourceConflict = iota // Disallow represents 'disallow' resource conflict policy. Disallow // TerminateOld represents 'terminate_old' resource conflict policy. TerminateOld )
type ResourceManager ¶
type ResourceManager struct {
// contains filtered or unexported fields
}
ResourceManager type is in charge of keeping track of all cluster resources.
func NewResourceManager ¶
func NewResourceManager(kv kv.KV) *ResourceManager
NewResourceManager creates a new resource manager given a KV storage instance.
func (*ResourceManager) DelResource ¶
func (m *ResourceManager) DelResource(ctx context.Context, username, resource string) error
DelResource removes a registered resource from the manager.
func (*ResourceManager) GetResource ¶
func (m *ResourceManager) GetResource(ctx context.Context, username, resource string) (*c2smodel.Resource, error)
GetResource returns a previously registered resource.
func (*ResourceManager) GetResources ¶
func (m *ResourceManager) GetResources(ctx context.Context, username string) ([]c2smodel.Resource, error)
GetResources returns all user registered resources.
func (*ResourceManager) PutResource ¶
PutResource registers or updates a resource into the manager.
type SocketListener ¶
type SocketListener struct {
// contains filtered or unexported fields
}
SocketListener represents a C2S socket listener type.
func NewSocketListener ¶
func NewSocketListener( bindAddr string, port int, saslMechanisms []string, extAuth *auth.External, hosts *host.Hosts, router router.Router, comps *component.Components, mods *module.Modules, resMng *ResourceManager, rep repository.Repository, peppers *pepper.Keys, shapers shaper.Shapers, hk *hook.Hooks, cfg Config, ) *SocketListener
NewSocketListener returns a new C2S socket listener.