PR feedback.

This commit is contained in:
Pat Gavlin 2017-10-23 10:11:09 -07:00
parent d22a42858f
commit cdbcc394dd
3 changed files with 19 additions and 5 deletions

View file

@ -49,7 +49,7 @@ type localStackMutation struct {
name tokens.QName
}
func (p localStackProvider) BeginMutation(name tokens.QName) (engine.Mutation, error) {
func (p localStackProvider) BeginMutation(name tokens.QName) (engine.SnapshotMutation, error) {
return localStackMutation{name: name}, nil
}

View file

@ -154,7 +154,7 @@ func (acts *deployActions) Run(step deploy.Step) (resource.Status, error) {
}
// Inform the snapshot service that we are about to perform a step.
var mutation Mutation
var mutation SnapshotMutation
if _, ismut := step.(deploy.MutatingStep); ismut {
m, err := acts.Engine.Snapshots.BeginMutation(acts.Target.Name)
if err != nil {

View file

@ -17,13 +17,27 @@ type TargetProvider interface {
GetTarget(name tokens.QName) (*deploy.Target, error)
}
// Mutation abstracts away managing changes to snapshots
type Mutation interface {
// SnapshotMutation abstracts away managing changes to snapshots
type SnapshotMutation interface {
// End indicates that the current mutation has completed and that its results (given by snapshot) should be persisted. See the comments
// on SnapshotProvider.BeginMutation for more details.
End(snapshot *deploy.Snapshot) error
}
// SnapshotProvider abstracts away retrieving and storing snapshots
type SnapshotProvider interface {
GetSnapshot(name tokens.QName) (*deploy.Snapshot, error)
BeginMutation(name tokens.QName) (Mutation, error)
// BeginMutation and SnapshotMutation.End allow a snapshot provider to be robust in the face of failures that occur between the points
// at which they are called. The semantics are as follows:
// 1. The engine calls `SnapshotProvider.Begin` to indicate that it is about to mutate the state of the resources tracked by the
// snapshot.
// 2. The engine mutates the state of the resoures tracked by the snapshot.
// 3. The engine calls `SnapshotMutation.End` with the new snapshot to indicate that the mutation(s) it was performing has/have
// finished.
// During (1), the snapshot provider should record the fact that any currently persisted snapshot is being mutated and cannot be
// assumed to represent the actual state of the system. This ensures that if the engine crashes during (2), then the current snapshot
// is known to be unreliable. During (3), the snapshot provider should persist the provided snapshot and record that it is known to be
// reliable.
BeginMutation(name tokens.QName) (SnapshotMutation, error)
}