Documentation ¶
Index ¶
- type Persistence
- type RawState
- type StagedResource
- type State
- func (st State) AddPendingResource(applicationID, userID string, chRes charmresource.Resource, r io.Reader) (pendingID string, err error)
- func (st State) GetPendingResource(applicationID, name, pendingID string) (resource.Resource, error)
- func (st State) GetResource(applicationID, name string) (resource.Resource, error)
- func (st State) ListResources(applicationID string) (resource.ServiceResources, error)
- func (st State) NewResolvePendingResourcesOps(applicationID string, pendingIDs map[string]string) ([]txn.Op, error)
- func (st State) OpenResource(applicationID, name string) (resource.Resource, io.ReadCloser, error)
- func (st State) OpenResourceForUniter(unit resource.Unit, name string) (resource.Resource, io.ReadCloser, error)
- func (st State) SetCharmStoreResources(applicationID string, info []charmresource.Resource, lastPolled time.Time) error
- func (st State) SetResource(applicationID, userID string, chRes charmresource.Resource, r io.Reader) (resource.Resource, error)
- func (st State) UpdatePendingResource(applicationID, pendingID, userID string, chRes charmresource.Resource, ...) (resource.Resource, error)
- type Storage
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 (State) AddPendingResource ¶
func (st State) AddPendingResource(applicationID, 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(applicationID, name, pendingID string) (resource.Resource, error)
GetPendingResource returns the resource data for the identified resource.
func (State) GetResource ¶
GetResource returns the resource data for the identified resource.
func (State) ListResources ¶
func (st State) ListResources(applicationID string) (resource.ServiceResources, error)
ListResources returns the resource data for the given application ID.
func (State) NewResolvePendingResourcesOps ¶
func (st State) NewResolvePendingResourcesOps(applicationID 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 ¶
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(applicationID string, info []charmresource.Resource, lastPolled time.Time) error
SetCharmStoreResources sets the "polled" resources for the application to the provided values.
func (State) SetResource ¶
func (st State) SetResource(applicationID, 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(applicationID, pendingID, userID string, chRes charmresource.Resource, r io.Reader) (resource.Resource, error)
UpdatePendingResource stores the resource in the Juju model.