component

package
v0.54.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func NewComponents(
	components []Component,
	hk *hook.Hooks,
) *Components

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL