Skip to content

Rework Update<ResourceType> in storage layer #763

Closed

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, actorRef,  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.

Activity

  1. added
    kind/cleanup
    on Aug 5, 2026
  2. thockin commented on Aug 9, 2026

    @thockin
    Collaborator

    I think we need to let the storage layer be atomic. To my eyes that looks something like:

    RPC layer UpdateActor(newActor)
    Create a callback
    Call storage layer UpdateActor(newActor, callback)
    Open txn
    Get current value from DB
    Call callback(new, old)
    6a) Check UID precondition IFF it was specified
    6b) Check version IFF it was specified
    6c) Apply changes to in-memory state
    Commit

  3. laoj2 commented on Aug 18, 2026

    @laoj2
    Collaborator

    Closing this issue. The remaining PR (#1014) is more closely related to #954

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area/api-machinerykind/cleanup

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions