remoterelations

package
v0.0.0-...-a0d7459 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2017 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application interface {
	// Name is the name of the application.
	Name() string

	// Life returns the lifecycle state of the application.
	Life() state.Life

	// Endpoints returns the application's currently available relation endpoints.
	Endpoints() ([]state.Endpoint, error)
}

Application represents the state of a application hosted in the local model.

type Relation

type Relation interface {
	// Destroy ensures that the relation will be removed at some point; if
	// no units are currently in scope, it will be removed immediately.
	Destroy() error

	// Id returns the integer internal relation key.
	Id() int

	// Tag returns the relation's tag.
	Tag() names.Tag

	// Life returns the relation's current life state.
	Life() state.Life

	// Endpoints returns the endpoints that constitute the relation.
	Endpoints() []state.Endpoint

	// RemoteUnit returns a RelationUnit for the remote application unit
	// with the supplied ID.
	RemoteUnit(unitId string) (RelationUnit, error)

	// Unit returns a RelationUnit for the unit with the supplied ID.
	Unit(unitId string) (RelationUnit, error)

	// WatchUnits returns a watcher that notifies of changes to the units of the
	// specified application in the relation.
	WatchUnits(applicationName string) (state.RelationUnitsWatcher, error)
}

Relation provides access a relation in global state.

type RelationUnit

type RelationUnit interface {
	// EnterScope ensures that the unit has entered its scope in the
	// relation. When the unit has already entered its scope, EnterScope
	// will report success but make no changes to state.
	EnterScope(settings map[string]interface{}) error

	// InScope returns whether the relation unit has entered scope and
	// not left it.
	InScope() (bool, error)

	// LeaveScope signals that the unit has left its scope in the relation.
	// After the unit has left its relation scope, it is no longer a member
	// of the relation; if the relation is dying when its last member unit
	// leaves, it is removed immediately. It is not an error to leave a
	// scope that the unit is not, or never was, a member of.
	LeaveScope() error

	// ReplaceSettings replaces the relation unit's settings within the
	// relation.
	ReplaceSettings(map[string]interface{}) error

	// Settings returns the relation unit's settings within the relation.
	Settings() (map[string]interface{}, error)
}

RelationUnit provides access to the settings of a single unit in a relation, and methods for modifying the unit's involvement in the relation.

type RemoteApplication

type RemoteApplication interface {
	// Name returns the name of the remote application.
	Name() string

	// OfferName returns the name the offering side has given to the remote application..
	OfferName() string

	// Tag returns the remote applications's tag.
	Tag() names.Tag

	// SourceModel returns the tag of the model hosting the remote application.
	SourceModel() names.ModelTag

	// IsConsumerProxy returns whether application is created
	// from a registration operation by a consuming model.
	IsConsumerProxy() bool

	// URL returns the remote application URL, at which it is offered.
	URL() (string, bool)

	// Life returns the lifecycle state of the application.
	Life() state.Life

	// Status returns the status of the remote application.
	Status() (status.StatusInfo, error)

	// Destroy ensures that this remote application reference and all its relations
	// will be removed at some point; if no relation involving the
	// application has any units in scope, they are all removed immediately.
	Destroy() error
}

RemoteApplication represents the state of an application hosted in an external (remote) model.

type RemoteRelationsAPI

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

RemoteRelationsAPI provides access to the Provisioner API facade.

func NewRemoteRelationsAPI

func NewRemoteRelationsAPI(
	st RemoteRelationsState,
	pool StatePool,
	resources facade.Resources,
	authorizer facade.Authorizer,
) (*RemoteRelationsAPI, error)

NewRemoteRelationsAPI returns a new server-side RemoteRelationsAPI facade.

func NewStateRemoteRelationsAPI

func NewStateRemoteRelationsAPI(ctx facade.Context) (*RemoteRelationsAPI, error)

NewRemoteRelationsAPI creates a new server-side RemoteRelationsAPI facade backed by global state.

func (*RemoteRelationsAPI) ExportEntities

func (api *RemoteRelationsAPI) ExportEntities(entities params.Entities) (params.RemoteEntityIdResults, error)

ExportEntities allocates unique, remote entity IDs for the given entities in the local model.

func (*RemoteRelationsAPI) GetTokens

GetToken returns the token associated with the entity with the given tag for the current model.

func (*RemoteRelationsAPI) ImportRemoteEntities

func (api *RemoteRelationsAPI) ImportRemoteEntities(args params.RemoteEntityArgs) (params.ErrorResults, error)

ImportRemoteEntities adds entities to the remote entities collection with the specified opaque tokens.

func (*RemoteRelationsAPI) PublishLocalRelationChange

func (api *RemoteRelationsAPI) PublishLocalRelationChange(
	changes params.RemoteRelationsChanges,
) (params.ErrorResults, error)

PublishLocalRelationChange publishes local relations changes to the remote side offering those relations.

func (*RemoteRelationsAPI) RegisterRemoteRelations

func (api *RemoteRelationsAPI) RegisterRemoteRelations(
	relations params.RegisterRemoteRelations,
) (params.RemoteEntityIdResults, error)

RegisterRemoteRelations sets up the local model to participate in the specified relations. This operation is idempotent.

func (*RemoteRelationsAPI) RelationUnitSettings

func (api *RemoteRelationsAPI) RelationUnitSettings(relationUnits params.RelationUnits) (params.SettingsResults, error)

RelationUnitSettings returns the relation unit settings for the given relation units in the local model.

func (*RemoteRelationsAPI) Relations

Relations returns information about the cross-model relations with the specified keys in the local model.

func (*RemoteRelationsAPI) RemoteApplications

func (api *RemoteRelationsAPI) RemoteApplications(entities params.Entities) (params.RemoteApplicationResults, error)

RemoteApplications returns the current state of the remote applications with the specified names in the local model.

func (*RemoteRelationsAPI) RemoveRemoteEntities

func (api *RemoteRelationsAPI) RemoveRemoteEntities(args params.RemoteEntityArgs) (params.ErrorResults, error)

RemoveRemoteEntities removes the specified entities from the remote entities collection.

func (*RemoteRelationsAPI) WatchLocalRelationUnits

func (api *RemoteRelationsAPI) WatchLocalRelationUnits(args params.Entities) (params.RelationUnitsWatchResults, error)

WatchLocalRelationUnits starts a RelationUnitsWatcher for watching the local relation units involved in each specified relation in the local model, and returns the watcher IDs and initial values, or an error if the relation units could not be watched.

func (*RemoteRelationsAPI) WatchRemoteApplicationRelations

func (api *RemoteRelationsAPI) WatchRemoteApplicationRelations(args params.Entities) (params.StringsWatchResults, 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 services' relations could not be watched.

func (*RemoteRelationsAPI) WatchRemoteApplications

func (api *RemoteRelationsAPI) WatchRemoteApplications() (params.StringsWatchResult, error)

WatchRemoteApplications starts a strings watcher that notifies of the addition, removal, and lifecycle changes of remote applications in the model; and returns the watcher ID and initial IDs of remote applications, or an error if watching failed.

func (*RemoteRelationsAPI) WatchRemoteRelations

func (api *RemoteRelationsAPI) WatchRemoteRelations() (params.StringsWatchResult, error)

WatchRemoteRelations starts a strings watcher that notifies of the addition, removal, and lifecycle changes of remote relations in the model; and returns the watcher ID and initial IDs of remote relations, or an error if watching failed.

type RemoteRelationsState

type RemoteRelationsState interface {
	// ModelUUID returns the model UUID for the model
	// controlled by this state instance.
	ModelUUID() string

	// KeyRelation returns the existing relation with the given key (which can
	// be derived unambiguously from the relation's endpoints).
	KeyRelation(string) (Relation, error)

	// AddRelation adds a relation between the specified endpoints and returns the relation info.
	AddRelation(...state.Endpoint) (Relation, error)

	// EndpointsRelation returns the existing relation with the given endpoints.
	EndpointsRelation(...state.Endpoint) (Relation, error)

	// Relation returns the existing relation with the given id.
	Relation(int) (Relation, error)

	// AddRemoteApplication creates a new remote application record, having the supplied relation endpoints,
	// with the supplied name (which must be unique across all applications, local and remote).
	AddRemoteApplication(state.AddRemoteApplicationParams) (RemoteApplication, error)

	// RemoteApplication returns a remote application by name.
	RemoteApplication(string) (RemoteApplication, error)

	// Application returns a local application by name.
	Application(string) (Application, error)

	// WatchRemoteApplications returns a StringsWatcher that notifies of changes to
	// the lifecycles of the remote applications in the model.
	WatchRemoteApplications() state.StringsWatcher

	// WatchRemoteApplicationRelations returns a StringsWatcher that notifies of
	// changes to the lifecycles of relations involving the specified remote
	// application.
	WatchRemoteApplicationRelations(applicationName string) (state.StringsWatcher, error)

	// WatchRemoteRelations returns a StringsWatcher that notifies of changes to
	// the lifecycles of remote relations in the model.
	WatchRemoteRelations() state.StringsWatcher

	// ExportLocalEntity adds an entity to the remote entities collection,
	// returning an opaque token that uniquely identifies the entity within
	// the model.
	ExportLocalEntity(names.Tag) (string, error)

	// GetRemoteEntity returns the tag of the entity associated with the given
	// token and model.
	GetRemoteEntity(names.ModelTag, string) (names.Tag, error)

	// ImportRemoteEntity adds an entity to the remote entities collection
	// with the specified opaque token.
	ImportRemoteEntity(sourceModel names.ModelTag, entity names.Tag, token string) error

	// RemoveRemoteEntity removes the specified entity from the remote entities collection.
	RemoveRemoteEntity(sourceModel names.ModelTag, entity names.Tag) error

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

	// ListOffers returns the application offers matching any one of the filter terms.
	ListOffers(filter ...crossmodel.ApplicationOfferFilter) ([]crossmodel.ApplicationOffer, error)
}

RemoteRelationState provides the subset of global state required by the remote relations facade.

type StatePool

type StatePool interface {
	// Get returns a State for a given model from the pool.
	Get(modelUUID string) (RemoteRelationsState, func(), error)
}

StatePool provides the subset of a state pool required by the remote relations facade.

Jump to

Keyboard shortcuts

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