context

package
v0.0.0-...-b0bff92 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloudCallContext

type CloudCallContext struct {
	// This embedded context.Context instance allows this cloud call context to be
	// passed to any provider SDK calls which need a standard context.
	context.Context

	// InvalidateCredentialFunc is the actual callback function
	// that invalidates the credential used in the context of this call.
	InvalidateCredentialFunc func(string) error
}

CloudCallContext is a context intended to provide behaviors that are necessary to make a valid and lean call to an underlying substrate, for example cloud API.

For instance, when Juju makes a call to cloud API with an expired credential, we might not yet know that it is expired until cloud API rejects it. However, we do know in advance, before making the call, that we want to mark this credential as invalid if the cloud API rejects it. How credential will be found, where it is stored in Juju data model, what calls need to be done to mark it so, will be the responsibility of internal functions that are passed in to this context as this knowledge is specific to where the call was made *from* not on what object it was made.

func CallContext

CallContext creates a CloudCallContext for use when calling environ methods that may require invalidate a cloud credential.

func NewCloudCallContext

func NewCloudCallContext(ctx context.Context) *CloudCallContext

NewCloudCallContext creates a new CloudCallContext to be used a ProviderCallContext.

func NewEmptyCloudCallContext

func NewEmptyCloudCallContext() *CloudCallContext

NewEmptyCloudCallContext creates a new CloudCallContext to be used a ProviderCallContext in tests and other cases where an invalid credential func is not required.

func (*CloudCallContext) InvalidateCredential

func (c *CloudCallContext) InvalidateCredential(reason string) error

InvalidateCredential implements context.InvalidateCredentialCallback.

type Distributor

type Distributor interface {
	// DistributeInstances takes a set of clean, empty instances,
	// a distribution group, and list of zones to limit the consideration to.
	// If the input zone collection has no elements, then all availability
	// zones are considered when attempting distribution.
	// It returns the subset of candidates that the policy will allow to enter
	// the distribution group.
	//
	// The AssignClean and AssignCleanEmpty unit assignment policies will
	// attempt to assign a unit to each of the resulting instances until one is
	// successful. If no instances can be assigned to (e.g. because of
	// concurrent deployments), then a new machine will be allocated.
	DistributeInstances(
		ctx ProviderCallContext, candidates, distributionGroup []instance.Id, limitZones []string,
	) ([]instance.Id, error)
}

Distributor is an interface that may be used to distribute application units across instances for high availability.

type ModelCredentialInvalidator

type ModelCredentialInvalidator interface {

	// InvalidateModelCredential invalidate cloud credential for the model.
	InvalidateModelCredential(string) error
}

ModelCredentialInvalidator defines a point of use interface for invalidating a model credential.

type ProviderCallContext

type ProviderCallContext interface {
	context.Context

	// InvalidateCredential provides means to invalidate a credential
	// that is used to make a call.
	InvalidateCredential(string) error
}

ProviderCallContext exposes useful capabilities when making calls to an underlying cloud substrate.

Jump to

Keyboard shortcuts

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