Documentation ¶
Index ¶
- Variables
- type IQProcessor
- type Module
- type Modules
- func (m *Modules) InterceptStanza(ctx context.Context, stanza stravaganza.Stanza, incoming bool) (stravaganza.Stanza, error)
- func (m *Modules) IsEnabled(moduleName string) bool
- func (m *Modules) IsModuleIQ(iq *stravaganza.IQ) bool
- func (m *Modules) ProcessIQ(ctx context.Context, iq *stravaganza.IQ) error
- func (m *Modules) Start(ctx context.Context) error
- func (m *Modules) Stop(ctx context.Context) error
- func (m *Modules) StreamFeatures(ctx context.Context, domain string) ([]stravaganza.Element, error)
- type StanzaInterceptor
- type StanzaInterceptorProcessor
Constants ¶
This section is empty.
Variables ¶
var ErrInterceptStanzaInterrupted = errors.New("module: stanza interception interrupted")
ErrInterceptStanzaInterrupted will be returned by InterceptStanza to indicate that interception was interrupted.
Functions ¶
This section is empty.
Types ¶
type IQProcessor ¶ added in v0.52.0
type IQProcessor interface { Module // MatchesNamespace tells whether iq child namespace corresponds to this module. // The serverTarget parameter will be true in case iq target is a server entity. MatchesNamespace(namespace string, serverTarget bool) bool // ProcessIQ will be invoked whenever iq stanza should be processed by this module. ProcessIQ(ctx context.Context, iq *stravaganza.IQ) error }
IQProcessor represents an iq processor module type.
type Module ¶
type Module interface { // Name returns specific module name. Name() string // StreamFeature returns module stream feature element. StreamFeature(ctx context.Context, domain string) (stravaganza.Element, error) // ServerFeatures returns module server features. ServerFeatures(ctx context.Context) ([]string, error) // AccountFeatures returns module account features. AccountFeatures(ctx context.Context) ([]string, error) // Start starts module. Start(ctx context.Context) error // Stop stops module. Stop(ctx context.Context) error }
Module represents generic module interface.
type Modules ¶ added in v0.3.2
type Modules struct {
// contains filtered or unexported fields
}
Modules is the global module hub.
func NewModules ¶ added in v0.50.0
NewModules returns a new initialized Modules instance.
func (*Modules) InterceptStanza ¶ added in v0.52.2
func (m *Modules) InterceptStanza(ctx context.Context, stanza stravaganza.Stanza, incoming bool) (stravaganza.Stanza, error)
InterceptStanza performs module stanza transformation.
func (*Modules) IsEnabled ¶ added in v0.50.0
IsEnabled tells whether a specific module it's been registered.
func (*Modules) IsModuleIQ ¶ added in v0.50.0
IsModuleIQ returns true in case iq stanza should be handled by modules.
func (*Modules) ProcessIQ ¶ added in v0.3.4
ProcessIQ routes the iq to the corresponding iq handler module.
type StanzaInterceptor ¶ added in v0.52.2
type StanzaInterceptor struct { // ID is the interceptor identifier. Note this identifier is intended to discern which interceptor // is being invoked when calling InterceptStanza method, so it doesn't need to be unique across different modules. ID int // Incoming tells whether the interceptor should be invoked; either upon receiving a stanza or before sending it to the target. Incoming bool // Priority represents interceptor priority that's used to determine which interceptors should be invoked first. // The higher the number the more priority. Priority int }
StanzaInterceptor type allows to dynamically transform stanza content. Interceptors may be invoked upon receiving a stanza or before sending it to the target.
type StanzaInterceptorProcessor ¶ added in v0.52.2
type StanzaInterceptorProcessor interface { Module // Interceptors returns a set of all module interceptors. Interceptors() []StanzaInterceptor // InterceptStanza will be invoked to allow stanza transformation based on a StanzaInterceptor definition. // To interrupt interception ErrInterceptStanzaInterrupted should be returned. InterceptStanza(ctx context.Context, stanza stravaganza.Stanza, id int) (result stravaganza.Stanza, err error) }
StanzaInterceptorProcessor represents an stanza interceptor module type.