The Update methods in the storage later take the resource and an expected version as parameters. For example:
UpdateActor(ctx context.Context, actor *Actor, expectedVersion int64) (*Actor, error)
The contract is that the mutable fields are copied over from actor iff the expectedVersion matches the value in the DB. This is checked within a single tx.
A much simpler (and expressive) API would be one that takes a mutate closure and performs a transactional read-modify-write. For example:
UpdateActor(ctx context.Context, update func(*Actor) error) (*Actor, error)
This would simplify callers (see discussion #742 (comment)).
This task is to convert all Update<Type> methods in the store Go API to this model.
The Update methods in the storage later take the resource and an expected version as parameters. For example:
The contract is that the mutable fields are copied over from
actoriff theexpectedVersionmatches the value in the DB. This is checked within a single tx.A much simpler (and expressive) API would be one that takes a mutate closure and performs a transactional read-modify-write. For example:
This would simplify callers (see discussion #742 (comment)).
This task is to convert all
Update<Type>methods in the store Go API to this model.