Documentation ¶
Overview ¶
Package provider implements the basic bookeeping needed by most providers. It is meant to be embedded by provider implementations.
Index ¶
- type DefaultProvider
- func (p *DefaultProvider) ActionChannel() <-chan PendingAction
- func (p *DefaultProvider) ActionEvent(action PendingAction)
- func (p *DefaultProvider) AddNewInstallations()
- func (p *DefaultProvider) AddNewInstances()
- func (p *DefaultProvider) RegisterInstallations(installations ...*connector.Installation) error
- func (p *DefaultProvider) RegisterInstances(instances ...*connector.Instance) error
- func (p *DefaultProvider) RemoveInstallation(installationId string) error
- func (p *DefaultProvider) RemoveInstallations()
- func (p *DefaultProvider) RemoveInstance(instanceId string) error
- func (p *DefaultProvider) RemoveInstances()
- func (p *DefaultProvider) RequestAction(ctx context.Context, instance *connector.Instance, ...) (connector.ActionRequestStatus, error)
- func (p *DefaultProvider) Update()
- func (p *DefaultProvider) UpdateChannel() <-chan connector.UpdateEvent
- func (p *DefaultProvider) UpdateEvent(update connector.UpdateEvent)
- type PendingAction
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 }