remoterelations

package
v0.0.0-...-004e4dd Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: AGPL-3.0 Imports: 26 Imported by: 2

Documentation

Overview

Package remoterelations defines workers which manage the operation of cross model relations.

  • `Worker`: Top level worker. Watches SaaS applications/proxies and creates a worker for each.
  • `remoteApplicationWorker`: Manages operations for a consumer or offer proxy. Consumes and publishes relation data and status changes.
  • `remoteRelationsWorker`: Runs on the consuming model to manage relations to the offer.
  • `relationUnitsWorker`: Runs on the consuming model to receive and publish changes to each relation unit data bag.

The consuming side pushes relation updates from the consumer application to the model containing the offer. It also polls the offered application to record relation changes from the offer into the consuming model.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Manifold

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold packages a Worker for use in a dependency.Engine.

func NewWorker

func NewWorker(config Config) (worker.Worker, error)

Types

type Config

type Config struct {
	ModelUUID                string
	RelationsFacade          RemoteRelationsFacade
	NewRemoteModelFacadeFunc newRemoteRelationsFacadeFunc
	Clock                    clock.Clock
	Logger                   Logger

	// Used for testing.
	Runner *worker.Runner
}

Config defines the operation of a Worker.

func (Config) Validate

func (config Config) Validate() error

Validate returns an error if config cannot drive a Worker.

type Logger

type Logger interface {
	Tracef(string, ...interface{})
	Debugf(string, ...interface{})
	Criticalf(string, ...interface{})
	Infof(string, ...interface{})
	Warningf(string, ...interface{})
	Errorf(string, ...interface{})
}

Logger represents the methods used by the worker to log details.

type ManifoldConfig

type ManifoldConfig struct {
	AgentName     string
	APICallerName string

	NewControllerConnection  apicaller.NewExternalControllerConnectionFunc
	NewRemoteRelationsFacade func(base.APICaller) RemoteRelationsFacade
	NewWorker                func(Config) (worker.Worker, error)
	Logger                   Logger
}

ManifoldConfig defines the names of the manifolds on which a Worker manifold will depend.

func (ManifoldConfig) Validate

func (config ManifoldConfig) Validate() error

Validate is called by start to check for bad configuration.

type RelationUnitChangeEvent

type RelationUnitChangeEvent struct {
	Tag names.RelationTag
	params.RemoteRelationChangeEvent
}

RelationUnitChangeEvent encapsulates a remote relation event, adding the tag of the relation which changed.

type RemoteModelRelationsFacade

type RemoteModelRelationsFacade interface {
	// RegisterRemoteRelations sets up the remote model to participate
	// in the specified relations.
	RegisterRemoteRelations(relations ...params.RegisterRemoteRelationArg) ([]params.RegisterRemoteRelationResult, error)

	// PublishRelationChange publishes relation changes to the
	// model hosting the remote application involved in the relation.
	PublishRelationChange(params.RemoteRelationChangeEvent) error

	// WatchRelationChanges returns a watcher that notifies of changes
	// to the units in the remote model for the relation with the
	// given remote token. We need to pass the application token for
	// the case where we're talking to a v1 API and the client needs
	// to convert RelationUnitsChanges into RemoteRelationChangeEvents
	// as they come in.
	WatchRelationChanges(relationToken, applicationToken string, macs macaroon.Slice) (apiwatcher.RemoteRelationWatcher, error)

	// WatchRelationSuspendedStatus starts a RelationStatusWatcher for watching the
	// relations of each specified application in the remote model.
	WatchRelationSuspendedStatus(arg params.RemoteEntityArg) (watcher.RelationStatusWatcher, error)

	// WatchOfferStatus starts an OfferStatusWatcher for watching the status
	// of the specified offer in the remote model.
	WatchOfferStatus(arg params.OfferArg) (watcher.OfferStatusWatcher, error)

	// WatchConsumedSecretsChanges starts a watcher for any changes to secrets
	// consumed by the specified application.
	WatchConsumedSecretsChanges(applicationToken, relationToken string, mac *macaroon.Macaroon) (watcher.SecretsRevisionWatcher, error)
}

RemoteModelRelationsFacade instances publish local relation changes to the model hosting the remote application involved in the relation, and also watches for remote relation changes which are then pushed to the local model.

type RemoteModelRelationsFacadeCloser

type RemoteModelRelationsFacadeCloser interface {
	io.Closer
	RemoteModelRelationsFacade
}

RemoteModelRelationsFacadeCloser implements RemoteModelRelationsFacade and add a Close() method.

type RemoteRelationsFacade

type RemoteRelationsFacade interface {
	// ImportRemoteEntity adds an entity to the remote entities collection
	// with the specified opaque token.
	ImportRemoteEntity(entity names.Tag, token string) error

	// SaveMacaroon saves the macaroon for the entity.
	SaveMacaroon(entity names.Tag, mac *macaroon.Macaroon) error

	// ExportEntities allocates unique, remote entity IDs for the
	// given entities in the local model.
	ExportEntities([]names.Tag) ([]params.TokenResult, error)

	// GetToken returns the token associated with the entity with the given tag.
	GetToken(names.Tag) (string, error)

	// Relations returns information about the relations
	// with the specified keys in the local model.
	Relations(keys []string) ([]params.RemoteRelationResult, error)

	// RemoteApplications returns the current state of the remote applications with
	// the specified names in the local model.
	RemoteApplications(names []string) ([]params.RemoteApplicationResult, error)

	// WatchLocalRelationChanges returns a watcher that notifies of changes to the
	// local units in the relation with the given key.
	WatchLocalRelationChanges(relationKey string) (apiwatcher.RemoteRelationWatcher, error)

	// WatchRemoteApplications watches for addition, removal and lifecycle
	// changes to remote applications known to the local model.
	WatchRemoteApplications() (watcher.StringsWatcher, error)

	// WatchRemoteApplicationRelations starts a StringsWatcher for watching the relations of
	// each specified application in the local model, and returns the watcher IDs
	// and initial values, or an error if the application's relations could not be
	// watched.
	WatchRemoteApplicationRelations(application string) (watcher.StringsWatcher, error)

	// ConsumeRemoteRelationChange consumes a change to settings originating
	// from the remote/offering side of a relation.
	ConsumeRemoteRelationChange(change params.RemoteRelationChangeEvent) error

	// ControllerAPIInfoForModel returns the controller api info for a model.
	ControllerAPIInfoForModel(modelUUID string) (*api.Info, error)

	// SetRemoteApplicationStatus sets the status for the specified remote application.
	SetRemoteApplicationStatus(applicationName string, status status.Status, message string) error

	// UpdateControllerForModel ensures that there is an external controller record
	// for the input info, associated with the input model ID.
	UpdateControllerForModel(controller crossmodel.ControllerInfo, modelUUID string) error

	// ConsumeRemoteSecretChanges updates the local model with secret revision  changes
	// originating from the remote/offering model.
	ConsumeRemoteSecretChanges(changes []watcher.SecretRevisionChange) error
}

RemoteRelationsFacade exposes remote relation functionality to a worker.

func NewRemoteRelationsFacade

func NewRemoteRelationsFacade(apiCaller base.APICaller) RemoteRelationsFacade

type Worker

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

Worker manages relations and associated settings where one end of the relation is a remote application.

func New

func New(config Config) (*Worker, error)

New returns a Worker backed by config, or an error.

func (*Worker) Kill

func (w *Worker) Kill()

Kill is defined on worker.Worker.

func (*Worker) Report

func (w *Worker) Report() map[string]interface{}

Report provides information for the engine report.

func (*Worker) Wait

func (w *Worker) Wait() error

Wait is defined on worker.Worker.

Jump to

Keyboard shortcuts

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