service

package
v0.0.0-...-756137a Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: AGPL-3.0 Imports: 10 Imported by: 1

Documentation

Overview

Package service provides the service methods for the relation domain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service provides the API for working with relations.

func NewService

func NewService(
	st State,
	logger logger.Logger,
) *Service

NewService returns a new service reference wrapping the input state.

func (*Service) AddRelation

func (s *Service) AddRelation(ctx context.Context, eps []relation.Endpoint) error

AddRelation adds a relation between the two provided endpoints.

func (*Service) AllRelations

func (s *Service) AllRelations(ctx context.Context) ([]corerelation.UUID, error)

AllRelations Note: AllRelations replaces client.AllRelations for status. This needs to be investigated further.

func (*Service) ApplicationRelationEndpointNames

func (s *Service) ApplicationRelationEndpointNames(ctx context.Context, id application.ID) ([]string, error)

ApplicationRelationEndpointNames returns a slice of names of the given application's relation endpoints. Note: Replaces the functionality in CharmRelations method of the application facade.

func (*Service) ApplicationRelations

func (s *Service) ApplicationRelations(ctx context.Context, id application.ID) (
	[]corerelation.UUID, error)

ApplicationRelations returns relation UUIDs for the given application ID.

func (*Service) ApplicationRelationsInfo

func (s *Service) ApplicationRelationsInfo(
	ctx context.Context,
	applicationID application.ID,
) ([]relation.EndpointRelationData, error)

ApplicationRelationsInfo returns all EndpointRelationData for an application. Note: Replaces the functionality of the relationData method in the application facade. Used for UnitInfo call.

func (*Service) EnterScope

func (s *Service) EnterScope(ctx context.Context, relationID corerelation.UnitUUID) error

EnterScope updates the given relation to indicate it is in scope.

func (*Service) GetRelatedEndpoints

func (s *Service) GetRelatedEndpoints(
	ctx context.Context,
	relationUUID corerelation.UUID,
	applicationName string,
) ([]internalrelation.Endpoint, error)

GetRelatedEndpoints returns the endpoints of the relation with which units of the named application will establish relations.

func (*Service) GetRelationApplicationSettings

func (s *Service) GetRelationApplicationSettings(
	ctx context.Context,
	relationUUID corerelation.UUID,
	applicationID application.ID,
) (map[string]string, error)

GetRelationApplicationSettings returns the application settings for the given application and relation identifier combination.

func (*Service) GetRelationEndpoint

func (s *Service) GetRelationEndpoint(
	ctx context.Context,
	relationUUID corerelation.UUID,
	applicationID application.ID,
) (internalrelation.Endpoint, error)

GetRelationEndpoint returns the endpoint for the given application and relation identifier combination.

func (*Service) GetRelationEndpoints

func (s *Service) GetRelationEndpoints(ctx context.Context, id application.ID) ([]internalrelation.Endpoint, error)

GetRelationEndpoints returns all endpoints for the given application identifier.

func (*Service) GetRelationID

func (s *Service) GetRelationID(ctx context.Context, relationUUID corerelation.UUID) int

GetRelationID returns the relation ID for the given relation UUID.

func (*Service) GetRelationStatus

func (s *Service) GetRelationStatus(
	ctx context.Context,
	relationID corerelation.UUID,
) (corestatus.StatusInfo, error)

GetRelationStatus returns the status of the given relation.

func (*Service) GetRelationString

func (s *Service) GetRelationString(ctx context.Context, relationUUID corerelation.UUID) string

RelationString returns a key identifier for the given relation UUID. The key describes the relation defined by endpoints in sorted order. Note: See the state.relationKey() function.

func (*Service) GetRelationTag

func (s *Service) GetRelationTag(ctx context.Context, relationUUID corerelation.UUID) names.Tag

RelationTag returns the tag for the given relation UUID.

func (*Service) GetRelationUnit

func (s *Service) GetRelationUnit(
	ctx context.Context,
	relationUUID corerelation.UUID,
	unitName string,
) (corerelation.UnitUUID, error)

GetRelationUnit returns the relation unit UUID for the given unit for the given relation.

func (*Service) GetRelationUnitSettings

func (s *Service) GetRelationUnitSettings(
	ctx context.Context,
	relationUnitUUID corerelation.UnitUUID,
) (map[string]string, error)

GetRelationApplicationSettings returns the application settings for the given unit and relation identifier combination.

func (*Service) IsRelationSuspended

func (s *Service) IsRelationSuspended(ctx context.Context, relationUUID corerelation.UUID) bool

IsRelationSuspended returns a boolean to indicate if the given relation UUID is suspended.

func (*Service) LeaveScope

func (s *Service) LeaveScope(ctx context.Context, relationID corerelation.UnitUUID) error

LeaveScope updates the given relation to indicate it is not in scope.

func (Service) ReestablishRelation

func (s Service) ReestablishRelation(ctx context.Context, relationUUID corerelation.UUID) error

ReestablishRelation brings the given relation back to normal after suspension, any reason given for the suspension is cleared.

func (*Service) RelationSuspendedReason

func (s *Service) RelationSuspendedReason(ctx context.Context, relationUUID corerelation.UUID) string

RelationSuspendedReason returns the reason a relation was suspended if provided by the user.

func (*Service) RelationUnitEndpointName

func (s *Service) RelationUnitEndpointName(
	ctx context.Context,
	relationUnitUUID corerelation.UnitUUID,
) (string, error)

RelationUnitEndpointName returns the name of the endpoint for the given relation unit. Note: replaces calls to relUnit.Endpoint().Name in the uniter facade.

func (*Service) RelationUnitInScope

func (s *Service) RelationUnitInScope(ctx context.Context, relationUnitUUID corerelation.UnitUUID) (bool, error)

RelationUnitInScope returns a boolean to indicate whether the given relation unit is in scope.

func (*Service) RelationUnitValid

func (s *Service) RelationUnitValid(ctx context.Context, relationUnitUUID corerelation.UnitUUID) (bool, error)

RelationUnitInScope returns a boolean to indicate whether the given relation unit is in scope.

func (*Service) SetRelationApplicationSettings

func (s *Service) SetRelationApplicationSettings(
	ctx context.Context,
	relationUUID corerelation.UUID,
	applicationID application.ID,
	settings map[string]string,
) error

func (*Service) SetRelationStatus

func (s *Service) SetRelationStatus(
	ctx context.Context,
	relationID int,
	info corestatus.StatusInfo,
) error

SetRelationStatus sets the status of the relation to the status provided.

func (*Service) SetRelationSuspended

func (s *Service) SetRelationSuspended(
	ctx context.Context,
	relationUUID corerelation.UUID,
	reason string,
) error

SetRelationSuspended marks the given relation as suspended. Providing a reason is optional.

func (*Service) SetRelationUnitSettings

func (s *Service) SetRelationUnitSettings(
	ctx context.Context,
	relationUnitUUID corerelation.UnitUUID,
	settings map[string]string,
) error

type State

type State interface{}

State describes retrieval and persistence methods for relations.

type WatchableService

type WatchableService struct {
	*Service
	// contains filtered or unexported fields
}

WatchableService provides the API for working with applications and the ability to create watchers.

func NewWatchableService

func NewWatchableService(
	st State,
	watcherFactory WatcherFactory,
	logger logger.Logger,
) *WatchableService

NewWatchableService returns a new watchable service reference wrapping the input state.

func (*WatchableService) WatchApplicationSettings

func (s *WatchableService) WatchApplicationSettings(
	ctx context.Context,
	relationUUID corerelation.UUID,
	applicationID application.ID,
) (watcher.NotifyWatcher, error)

WatchApplicationSettings returns a notify watcher that will signal whenever the specified application's relation settings are changed.

func (*WatchableService) WatchLifeSuspendedStatus

func (s *WatchableService) WatchLifeSuspendedStatus(
	ctx context.Context,
	relationUUID corerelation.UUID,
) (watcher.StringsWatcher, error)

WatchLifeSuspendedStatus returns a watcher that notifies of changes to the life or suspended status of the relation.

func (*WatchableService) WatchUnitRelations

func (s *WatchableService) WatchUnitRelations(
	ctx context.Context,
	relationUnit corerelation.UnitUUID,
) (relation.RelationUnitsWatcher, error)

WatchUnitRelations returns a watcher that notifies of changes to counterpart units in the relation.

func (*WatchableService) WatchUnitScopes

func (s *WatchableService) WatchUnitScopes(
	ctx context.Context,
	relationUnit corerelation.UnitUUID,
) (relation.RelationScopeWatcher, error)

WatchUnitScopes returns a watcher which notifies of counterpart units entering and leaving the unit's scope.

type WatcherFactory

type WatcherFactory interface {
}

WatcherFactory instances return watchers for a given namespace and UUID.

Jump to

Keyboard shortcuts

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