Documentation ¶
Index ¶
- func NewRouter(localRouter *LocalRouter, clusterRouter *clusterrouter.Router, ...) router.C2SRouter
- 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 Options
- 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) (*coremodel.Resource, error)
- func (m *ResourceManager) GetResources(ctx context.Context, username string) ([]coremodel.Resource, error)
- func (m *ResourceManager) PutResource(ctx context.Context, res *coremodel.Resource) error
- type SocketListener
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRouter ¶ added in v0.50.0
func NewRouter( localRouter *LocalRouter, clusterRouter *clusterrouter.Router, resMng *ResourceManager, rep repository.Repository, sn *sonar.Sonar, ) router.C2SRouter
NewRouter creates and returns an initialized C2S router.
Types ¶
type LocalRouter ¶ added in v0.52.0
type LocalRouter struct {
// contains filtered or unexported fields
}
LocalRouter represents a cluster local router.
func NewLocalRouter ¶ added in v0.52.0
func NewLocalRouter(hosts *host.Hosts, sonar *sonar.Sonar) *LocalRouter
NewLocalRouter returns a new initialized local router.
func (*LocalRouter) Disconnect ¶ added in v0.52.0
func (r *LocalRouter) Disconnect(username, resource string, streamErr *streamerror.Error) error
Disconnect performs disconnection over a local router resource.
func (*LocalRouter) Register ¶ added in v0.52.0
func (r *LocalRouter) Register(stm stream.C2S) error
Register registers a local router stream.
func (*LocalRouter) Route ¶ added in v0.52.0
func (r *LocalRouter) Route(stanza stravaganza.Stanza, username, resource string) error
Route routes a stanza to a local router resource.
func (*LocalRouter) Start ¶ added in v0.52.0
func (r *LocalRouter) Start(_ context.Context) error
Start starts local router.
func (*LocalRouter) Stop ¶ added in v0.52.0
func (r *LocalRouter) Stop(ctx context.Context) error
Stop stops local router.
func (*LocalRouter) Stream ¶ added in v0.52.0
func (r *LocalRouter) Stream(username, resource string) stream.C2S
Stream returns stream identified by username and resource.
func (*LocalRouter) Unregister ¶ added in v0.52.0
func (r *LocalRouter) Unregister(stm stream.C2S) error
Unregister unregisters a local router resource.
type Options ¶ added in v0.50.0
type Options struct { // ConnectTimeout defines connection timeout. ConnectTimeout 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 }
Options defines C2S connection options.
type ResourceConflict ¶ added in v0.50.0
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 ¶ added in v0.52.0
type ResourceManager struct {
// contains filtered or unexported fields
}
ResourceManager type is in charge of keeping track of all cluster resources.
func NewResourceManager ¶ added in v0.52.0
func NewResourceManager(kv kv.KV) *ResourceManager
NewResourceManager creates a new resource manager given a KV storage instance.
func (*ResourceManager) DelResource ¶ added in v0.52.0
func (m *ResourceManager) DelResource(ctx context.Context, username, resource string) error
DelResource removes a registered resource from the manager.
func (*ResourceManager) GetResource ¶ added in v0.52.0
func (m *ResourceManager) GetResource(ctx context.Context, username, resource string) (*coremodel.Resource, error)
GetResource returns a previously registered resource.
func (*ResourceManager) GetResources ¶ added in v0.52.0
func (m *ResourceManager) GetResources(ctx context.Context, username string) ([]coremodel.Resource, error)
GetResources returns all user registered resources.
func (*ResourceManager) PutResource ¶ added in v0.52.0
PutResource registers or updates a resource into the manager.
type SocketListener ¶ added in v0.50.0
type SocketListener struct {
// contains filtered or unexported fields
}
SocketListener represents a C2S socket listener type.
func NewSocketListener ¶ added in v0.50.0
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, sonar *sonar.Sonar, opts Options, ) *SocketListener
NewSocketListener returns a new C2S socket listener.