Documentation ¶
Index ¶
- Variables
- type Component
- type Components
- func (c *Components) AllComponents() []Component
- func (c *Components) Component(cHost string) Component
- func (c *Components) IsComponentHost(cHost string) bool
- func (c *Components) ProcessStanza(ctx context.Context, stanza stravaganza.Stanza) error
- func (c *Components) RegisterComponent(ctx context.Context, comp Component) error
- func (c *Components) Start(ctx context.Context) error
- func (c *Components) Stop(ctx context.Context) error
- func (c *Components) UnregisterComponent(ctx context.Context, cHost string) error
Constants ¶
This section is empty.
Variables ¶
var ErrComponentNotFound = errors.New("component: not found")
ErrComponentNotFound will be returned by ProcessStanza in case the receiver component is not registered.
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component interface { // Host returns component host address. Host() string // Name returns component name. Name() string // ProcessStanza will be called in case stanza is requested to processed by this component. ProcessStanza(ctx context.Context, stanza stravaganza.Stanza) error // Start starts component. Start(ctx context.Context) error // Stop stops component. Stop(ctx context.Context) error }
Component represents generic component interface.
type Components ¶ added in v0.3.4
type Components struct {
// contains filtered or unexported fields
}
Components is the global component hub.
func NewComponents ¶ added in v0.50.0
func NewComponents(components []Component) *Components
NewComponents returns a new initialized Components instance.
func (*Components) AllComponents ¶ added in v0.50.0
func (c *Components) AllComponents() []Component
AllComponents returns all registered components.
func (*Components) Component ¶ added in v0.50.0
func (c *Components) Component(cHost string) Component
Component returns the component associated to cHost.
func (*Components) IsComponentHost ¶ added in v0.50.0
func (c *Components) IsComponentHost(cHost string) bool
IsComponentHost tells whether cHost corresponds to some registered component.
func (*Components) ProcessStanza ¶ added in v0.50.0
func (c *Components) ProcessStanza(ctx context.Context, stanza stravaganza.Stanza) error
ProcessStanza will route stanza to proper component based on receiver JID address.
func (*Components) RegisterComponent ¶ added in v0.50.0
func (c *Components) RegisterComponent(ctx context.Context, comp Component) error
RegisterComponent registers a new component.
func (*Components) Start ¶ added in v0.50.0
func (c *Components) Start(ctx context.Context) error
Start starts components.
func (*Components) Stop ¶ added in v0.50.0
func (c *Components) Stop(ctx context.Context) error
Stop stops components.
func (*Components) UnregisterComponent ¶ added in v0.50.0
func (c *Components) UnregisterComponent(ctx context.Context, cHost string) error
UnregisterComponent unregisters a previously registered component.