exchangers

package
v2.4.1 Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsEntityCollection

func AsEntityCollection(collection Collection) entity.Collection

AsEntityCollection transforms an exchanger collection into an entity collection.

func StartExchangers

func StartExchangers(collection Collection) error

StartExchangers starts the given exchangers.

func StopExchangers

func StopExchangers(collection Collection)

StopExchangers stops the given exchangers.

Types

type BaseExchanger

type BaseExchanger struct {
	Exchanger
	// contains filtered or unexported fields
}

BaseExchanger implements basic exchanger functionality common to all exchangers.

func (*BaseExchanger) Activate

func (exchanger *BaseExchanger) Activate(conf *config.Configuration, log *zerolog.Logger) error

Activate activates the exchanger.

func (*BaseExchanger) Config

func (exchanger *BaseExchanger) Config() *config.Configuration

Config returns the configuration object.

func (*BaseExchanger) EnabledConnectors

func (exchanger *BaseExchanger) EnabledConnectors() []string

EnabledConnectors returns the list of all enabled connectors for the exchanger.

func (*BaseExchanger) IsConnectorEnabled

func (exchanger *BaseExchanger) IsConnectorEnabled(id string) bool

IsConnectorEnabled checks if the given connector is enabled for the exchanger.

func (*BaseExchanger) Locker

func (exchanger *BaseExchanger) Locker() *sync.RWMutex

Locker returns the locking object.

func (*BaseExchanger) Log

func (exchanger *BaseExchanger) Log() *zerolog.Logger

Log returns the logger object.

func (*BaseExchanger) MeshData

func (exchanger *BaseExchanger) MeshData() *meshdata.MeshData

MeshData returns the stored mesh data. The returned data is cloned to prevent accidental data changes. Unauthorized sites are also removed if this exchanger doesn't allow them.

func (*BaseExchanger) SetEnabledConnectors

func (exchanger *BaseExchanger) SetEnabledConnectors(connectors []string)

SetEnabledConnectors sets the list of all enabled connectors for the exchanger.

func (*BaseExchanger) Start

func (exchanger *BaseExchanger) Start() error

Start starts the exchanger; only exchangers which perform periodical background tasks should do something here.

func (*BaseExchanger) Stop

func (exchanger *BaseExchanger) Stop()

Stop stops any running background activities of the exchanger.

func (*BaseExchanger) Update

func (exchanger *BaseExchanger) Update(meshDataSet meshdata.Map) error

Update is called whenever the mesh data set has changed to reflect these changes.

type BaseRequestExchanger

type BaseRequestExchanger struct {
	RequestExchanger
	// contains filtered or unexported fields
}

BaseRequestExchanger implements basic exporter functionality common to all request exporters.

func (*BaseRequestExchanger) Endpoint

func (exchanger *BaseRequestExchanger) Endpoint() string

Endpoint returns the (relative) endpoint of the exchanger.

func (*BaseRequestExchanger) HandleAction

func (exchanger *BaseRequestExchanger) HandleAction(meshData *meshdata.MeshData, body []byte, params url.Values, isExtended bool, conf *config.Configuration, log *zerolog.Logger) (meshdata.Vector, int, []byte, error)

HandleAction executes the registered handler for the specified action, if any.

func (*BaseRequestExchanger) HandleRequest

func (exchanger *BaseRequestExchanger) HandleRequest(resp http.ResponseWriter, req *http.Request, conf *config.Configuration, log *zerolog.Logger) error

HandleRequest handles the actual HTTP request.

func (*BaseRequestExchanger) IsProtectedEndpoint

func (exchanger *BaseRequestExchanger) IsProtectedEndpoint() bool

IsProtectedEndpoint returns true if the endpoint can only be accessed with authorization.

func (*BaseRequestExchanger) RegisterActionHandler

func (exchanger *BaseRequestExchanger) RegisterActionHandler(action string, callback queryCallback)

RegisterActionHandler registers a new handler for the specified action.

func (*BaseRequestExchanger) RegisterExtendedActionHandler

func (exchanger *BaseRequestExchanger) RegisterExtendedActionHandler(action string, callback extendedQueryCallback)

RegisterExtendedActionHandler registers a new handler for the specified extended action.

func (*BaseRequestExchanger) SetEndpoint

func (exchanger *BaseRequestExchanger) SetEndpoint(endpoint string, isProtected bool)

SetEndpoint sets the (relative) endpoint of the exchanger.

func (*BaseRequestExchanger) WantsRequest

func (exchanger *BaseRequestExchanger) WantsRequest(r *http.Request) bool

WantsRequest returns whether the exchanger wants to handle the incoming request.

type Collection

type Collection interface {
	entity.Collection

	// Exchangers returns a vector of exchangers within the collection.
	Exchangers() []Exchanger
}

Collection is an interface for exchanger collections.

type Exchanger

type Exchanger interface {
	entity.Entity

	// Start starts the exchanger; only exchangers which perform periodical background tasks should do something here.
	Start() error
	// Stop stops any running background activities of the exchanger.
	Stop()

	// MeshData returns the mesh data.
	MeshData() *meshdata.MeshData

	// Update is called whenever the mesh data set has changed to reflect these changes.
	Update(meshdata.Map) error
}

Exchanger is the base interface for importers and exporters.

type RequestExchanger

type RequestExchanger interface {
	// Endpoint returns the (relative) endpoint of the exchanger.
	Endpoint() string
	// IsProtectedEndpoint returns true if the endpoint can only be accessed with authorization.
	IsProtectedEndpoint() bool
	// WantsRequest returns whether the exchanger wants to handle the incoming request.
	WantsRequest(r *http.Request) bool
	// HandleRequest handles the actual HTTP request.
	HandleRequest(resp http.ResponseWriter, req *http.Request, conf *config.Configuration, log *zerolog.Logger)
}

RequestExchanger is the interface implemented by exchangers that offer an HTTP endpoint.

func GetRequestExchangers

func GetRequestExchangers(collection Collection) []RequestExchanger

GetRequestExchangers gets all exchangers from a vector that implement the RequestExchanger interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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