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 ¶
type Components struct {
// contains filtered or unexported fields
}
Components is the global component hub.
func NewComponents ¶
NewComponents returns a new initialized Components instance.
func (*Components) AllComponents ¶
func (c *Components) AllComponents() []Component
AllComponents returns all registered components.
func (*Components) Component ¶
func (c *Components) Component(cHost string) Component
Component returns the component associated to cHost.
func (*Components) IsComponentHost ¶
func (c *Components) IsComponentHost(cHost string) bool
IsComponentHost tells whether cHost corresponds to some registered component.
func (*Components) ProcessStanza ¶
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 ¶
func (c *Components) RegisterComponent(ctx context.Context, comp Component) error
RegisterComponent registers a new component.
func (*Components) Start ¶
func (c *Components) Start(ctx context.Context) error
Start starts components.
func (*Components) Stop ¶
func (c *Components) Stop(ctx context.Context) error
Stop stops components.
func (*Components) UnregisterComponent ¶
func (c *Components) UnregisterComponent(ctx context.Context, cHost string) error
UnregisterComponent unregisters a previously registered component.