provider

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: MIT Imports: 3 Imported by: 1

Documentation

Overview

Package provider implements the basic bookeeping needed by most providers. It is meant to be embedded by provider implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultProvider

type DefaultProvider struct {
	Installations map[string]*connector.Installation
	Instances     []*connector.Instance
	// contains filtered or unexported fields
}

func New

func New() DefaultProvider

func (*DefaultProvider) ActionChannel

func (p *DefaultProvider) ActionChannel() <-chan PendingAction

UpdateChannel returns the action channel and allows the provider to listen for action events.

func (*DefaultProvider) ActionEvent

func (p *DefaultProvider) ActionEvent(action PendingAction)

ActionEvent publishes the action event on the action event channel. This can be used to implement asynchronous RequestAction() method in the provider.

func (*DefaultProvider) AddNewInstallations

func (p *DefaultProvider) AddNewInstallations()

AddNewInstallations will add all newly registered installations to p.Instances. The provider is expected to call this to be able to use newly registered installations.

func (*DefaultProvider) AddNewInstances

func (p *DefaultProvider) AddNewInstances()

AddNewInstances will add all newly registered instances. The provider is expected to call this to be able to use newly registered instances.

func (*DefaultProvider) RegisterInstallations

func (p *DefaultProvider) RegisterInstallations(installations ...*connector.Installation) error

RegisterInstallations allows the connector to register new installations with the provider. The provider needs access to the installation in order to use installation specific configuration parameters.

func (*DefaultProvider) RegisterInstances

func (p *DefaultProvider) RegisterInstances(instances ...*connector.Instance) error

RegisterInstances allows the connector to register instances with the provider. Each instance will be periodically updated its random component.

func (*DefaultProvider) RemoveInstallation

func (p *DefaultProvider) RemoveInstallation(installationId string) error

RemoveInstallation removes the installation with the given id from the provider.

func (*DefaultProvider) RemoveInstallations

func (p *DefaultProvider) RemoveInstallations()

RemoveInstallations removes all installations that are marked for removal. It ignores installations that are not found. The provider is expected to call this before using p.Installations.

func (*DefaultProvider) RemoveInstance

func (p *DefaultProvider) RemoveInstance(instanceId string) error

RemoveInstance marks the instance with the given id for removal. The instance will be removed before the next run of the periodic update. If it is not registered, RemoveInstance will return an error.

func (*DefaultProvider) RemoveInstances

func (p *DefaultProvider) RemoveInstances()

RemoveInstances removes all instances that are marked for removal. It ignores instances that are not found. The provider is expected to call this before using p.Instances

func (*DefaultProvider) RequestAction

func (p *DefaultProvider) RequestAction(ctx context.Context, instance *connector.Instance, actionRequest connector.ActionRequest) (connector.ActionRequestStatus, error)

RequestAction allows the connector to send a action request to the Giphy provider. All actions are executed asynchronously by sending it to the actions channel. The provider implementation is responsible for listening to that channel and sending an appropriate response to the connector using the updates channel. Synchronous actions can be implemented by overriding this method and returning a non pending action request status.

func (*DefaultProvider) Update

func (p *DefaultProvider) Update()

Update will add all newly registered installations and instances and will remove the installations and instances that are marked for removal.

func (*DefaultProvider) UpdateChannel

func (p *DefaultProvider) UpdateChannel() <-chan connector.UpdateEvent

UpdateChannel returns the update channel and allows the connector to listen for update events.

func (*DefaultProvider) UpdateEvent

func (p *DefaultProvider) UpdateEvent(update connector.UpdateEvent)

UpdateEvent publishes the update event on the update event channel.

type PendingAction

type PendingAction struct {
	connector.ActionRequest
	Instance *connector.Instance
}

Jump to

Keyboard shortcuts

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