Skip to content

Rework Update<ResourceType> in storage layer #763

Description

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.

Metadata

Metadata

Labels

area/api-machinerykind/cleanupSmall fixes that are not bugs, for example a typo in a code comment

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions