Goal:

Reduce complexity in the coordinating state between layers of a data transfer.

Why:

This is a super low hanging fruit- we have a LOT of glue code that simply maps IDs between layers of data transfer, or passes duplicated state between layers because only some layers know how to persist state. Also, we have state persistence code at multiple layers. This could all be MUCH simpler.

Principles:

Strawman Interface:

type State interface{}
type LayerType string
type LocalID interface
type UUID string

type DataTransferState interface {
	UUID() UUID
	AddLayer(LayerType, LocalID)
  GetState(LayerType) (State, error)
	SetState(LayerType, State) error
  GetLocalID(LayerType, LocalID)
}

// The stack state is directly accessible from context, so each layer can derive 
// it from the the passed in context in the initiation call -- still need to
// work out receiving side
func GetOrCreateDataTransferState(ctx context.Context) 
  (context.Context, DataTransferState)