state

package
v0.0.0-...-2608902 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2016 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Persistence

type Persistence interface {
	// contains filtered or unexported methods
}

Persistence is the state persistence functionality needed for resources.

type RawState

type RawState interface {

	// Persistence exposes the state data persistence needed for resources.
	Persistence() Persistence

	// Storage exposes the state blob storage needed for resources.
	Storage() Storage
	// contains filtered or unexported methods
}

RawState defines the functionality needed from state.State for resources.

type StagedResource

type StagedResource interface {
	// Unstage ensures that the resource is removed
	// from the staging area. If it isn't in the staging area
	// then this is a noop.
	Unstage() error

	// Activate makes the staged resource the active resource.
	Activate() error
}

StagedResource represents resource info that has been added to the "staging" area of the persistence layer.

A separate staging area is necessary because we are dealing with the DB and storage at the same time for the same resource in some operations (e.g. SetResource). Resources are staged in the DB, added to storage, and then finalized in the DB.

type State

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

State exposes the state functionality needed for resources.

func NewState

func NewState(raw RawState) *State

NewState returns a new State for the given raw Juju state.

func (State) AddPendingResource

func (st State) AddPendingResource(serviceID, userID string, chRes charmresource.Resource, r io.Reader) (pendingID string, err error)

AddPendingResource stores the resource in the Juju model.

func (State) GetPendingResource

func (st State) GetPendingResource(serviceID, name, pendingID string) (resource.Resource, error)

GetPendingResource returns the resource data for the identified resource.

func (State) GetResource

func (st State) GetResource(serviceID, name string) (resource.Resource, error)

GetResource returns the resource data for the identified resource.

func (State) ListResources

func (st State) ListResources(serviceID string) (resource.ServiceResources, error)

ListResources returns the resource data for the given service ID.

func (State) NewResolvePendingResourcesOps

func (st State) NewResolvePendingResourcesOps(serviceID string, pendingIDs map[string]string) ([]txn.Op, error)

NewResolvePendingResourcesOps generates mongo transaction operations to set the identified resources as active.

Leaking mongo details (transaction ops) is a necessary evil since we do not have any machinery to facilitate transactions between different components.

func (State) OpenResource

func (st State) OpenResource(serviceID, name string) (resource.Resource, io.ReadCloser, error)

OpenResource returns metadata about the resource, and a reader for the resource.

func (State) OpenResourceForUniter

func (st State) OpenResourceForUniter(unit resource.Unit, name string) (resource.Resource, io.ReadCloser, error)

OpenResourceForUniter returns metadata about the resource and a reader for the resource. The resource is associated with the unit once the reader is completely exhausted.

func (State) SetCharmStoreResources

func (st State) SetCharmStoreResources(serviceID string, info []charmresource.Resource, lastPolled time.Time) error

SetCharmStoreResources sets the "polled" resources for the service to the provided values.

func (State) SetResource

func (st State) SetResource(serviceID, userID string, chRes charmresource.Resource, r io.Reader) (resource.Resource, error)

SetResource stores the resource in the Juju model.

func (State) UpdatePendingResource

func (st State) UpdatePendingResource(serviceID, pendingID, userID string, chRes charmresource.Resource, r io.Reader) (resource.Resource, error)

UpdatePendingResource stores the resource in the Juju model.

type Storage

type Storage interface {
	// contains filtered or unexported methods
}

Storage is the state storage functionality needed for resources.

Jump to

Keyboard shortcuts

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