Skip to content

Instantly share code, notes, and snippets.

@ericl
Created December 30, 2019 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericl/ed1dce20d310b86c0dc5540ae991494b to your computer and use it in GitHub Desktop.
Save ericl/ed1dce20d310b86c0dc5540ae991494b to your computer and use it in GitHub Desktop.
Idempotent actor API example.
1. Actors go from PENDING -> CREATED -> [RECONSTRUCTING -> CREATED] -> DEAD
2. A single client may issue multiple updates, it is important these updates aren't re-ordered.
This can be handled by making the actor update calls idempotent.
Non-idempotent:
def AsyncUpdate(actor_id, actor_state)
Idempotent:
def SetActorPendingIfNotExists(actor_id)
def SetActorCreatedAtVersion(actor_id, actor_lifetime_version) # version is 0, 1, 2, 3 etc.
def SetActorDeadAtVersion(actor_id, actor_lifetime_version) # suppressed if version already past
The GCS server can simply ignore requests that are "overwritten" by more recent versions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment