manager

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGetEndpoint

func NewGetEndpoint(m *Manager) endpoint.Endpoint

NewGetEndpoint returns the endpoint for /norns/{id} handler.

func NewGetEndpointDecode

func NewGetEndpointDecode() kithttp.DecodeRequestFunc

NewGetEndpointDecode returns DecodeRequestFunc wrapper from the /norns/{id} endpoint.

Types

type Filterer added in v0.2.0

type Filterer interface {
	// Start begins pulling from the filter queue to deliver events.
	Start(context.Context) error

	// Filter checks if the event's deviceID matches deviceID of norn
	// and queue it accordingly.
	Filter(deviceID string, event *wrp.Message)

	// Update will update the time a norn expires.
	Update(norn model.Norn)

	// Stop closes the filter queue and resets its metric.
	Stop(context.Context) error
}

Filterer is used to filter events by deviceID.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager is in charge of fanning out events to its respective dispatcher (HTTP or Sqs). It keeps track of all recent Filterers and Dispatchers part of its map and is responsible for updating or removing them.

func NewManager

func NewManager(sc dispatch.SenderConfig, transport http.RoundTripper, logger log.Logger, measures dispatch.Measures) (*Manager, error)

NewManager constructs a Manager from the provided configs.

func Provide

func Provide(in ManagerIn) (*Manager, error)

Provide is an uber/fx style provider for this package's components

func (*Manager) Send

func (m *Manager) Send(deviceID string, event *wrp.Message)

Send will send the message to Filter for it to be checked if norn's deviceID matches the event's.

func (*Manager) Update

func (m *Manager) Update(items chrysom.Items)

Update is the argus chrysom client listener. For every recent item that is provided by argus, Update will check if the dispatcher and filter for an item already exists as part of the manager's local cache (idFilter and urlDispatcher maps) and update cache with the recent norn retrieved from item. If the norn is brand new, a new dispatcher and filter is created for it and added to local cache. Any old dispatchers and filters is also removed part of Update.

type ManagerIn

type ManagerIn struct {
	fx.In

	DispatcherConfig dispatch.SenderConfig
	// FilterConfig     dispatch.FilterConfig
	Logger    log.Logger
	Measures  dispatch.Measures
	Transport http.RoundTripper
}

ManagerIn is the set of dependencies for this package's components

Jump to

Keyboard shortcuts

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