Avatar provider calls on runtime v2: outbox effects, never work done inside the store transaction.
On the routed runtime handlers/execute-avatar-effects makes the Yvatar HTTP calls
inline while the handler's result is still in hand. On v2 the handler runs inside a
store transaction (a row lock and a database connection), and a portrait render can
take tens of seconds, so the call has to happen after the commit. This namespace does
the three things that takes:
normalize-effect rewrites an avatar effect, which carries top-level fields and
bare-keyword callbacks, into the outbox's shape (:data, vector callbacks).executors runs each op against the configured provider and classifies the answer.callback-event-fn puts the outcome into the avatar/succeeded|failed callback,
which used to be built from the provider result in hand.DELIVERY. Reads and upsert are idempotent: an uncertain answer is retried. The rest
are not (a portrait costs a credit; publishing posts something live; a second accept
fails although the first applied), so they are AT-MOST-ONCE: an uncertain answer
becomes a definite unknown-outcome failure that marks the player's mirror :error,
and a call interrupted by a crash is not made again. A connection that was never
made (refused, unknown host, connect timeout) and a 429 applied nothing, so those
still retry. See game.gm.outbox.
Avatar provider calls on runtime v2: outbox effects, never work done inside the store transaction. On the routed runtime `handlers/execute-avatar-effects` makes the Yvatar HTTP calls inline while the handler's result is still in hand. On v2 the handler runs inside a store transaction (a row lock and a database connection), and a portrait render can take tens of seconds, so the call has to happen after the commit. This namespace does the three things that takes: - `normalize-effect` rewrites an avatar effect, which carries top-level fields and bare-keyword callbacks, into the outbox's shape (`:data`, vector callbacks). - `executors` runs each op against the configured provider and classifies the answer. - `callback-event-fn` puts the outcome into the `avatar/succeeded|failed` callback, which used to be built from the provider result in hand. DELIVERY. Reads and `upsert` are idempotent: an uncertain answer is retried. The rest are not (a portrait costs a credit; publishing posts something live; a second accept fails although the first applied), so they are AT-MOST-ONCE: an uncertain answer becomes a definite `unknown-outcome` failure that marks the player's mirror `:error`, and a call interrupted by a crash is not made again. A connection that was never made (refused, unknown host, connect timeout) and a 429 applied nothing, so those still retry. See game.gm.outbox.
(avatar-effect? effect)True for an effect whose type is in the avatar namespace, written as a keyword or a string (a protocol may write either, and a JSON round trip turns one into the other). Never throws: it runs over every effect of every protocol, and a type it does not recognise is simply not an avatar effect.
True for an effect whose type is in the avatar namespace, written as a keyword or a string (a protocol may write either, and a JSON round trip turns one into the other). Never throws: it runs over every effect of every protocol, and a type it does not recognise is simply not an avatar effect.
(callback-event-fn effect evt)The outbox's :callback-event-fn: the completed avatar effect's outcome goes into its
callback event, as :result (success) or :status/:error (failure). Other
effects' callbacks are left alone.
The outbox's `:callback-event-fn`: the completed avatar effect's outcome goes into its callback event, as `:result` (success) or `:status`/`:error` (failure). Other effects' callbacks are left alone.
(executors provider-fn){"avatar/<op>" executor} for the outbox. provider-fn returns the configured
AvatarProvider, or nil when avatars are disabled or unconfigured.
{"avatar/<op>" executor} for the outbox. `provider-fn` returns the configured
AvatarProvider, or nil when avatars are disabled or unconfigured.(normalize-avatar-effects provider-name result)A dispatch result with its avatar effects rewritten into outbox effects (see
normalize-effect). Pure, and does nothing to a result without avatar effects. A game's
dispatch fn uses this instead of calling the provider inline when runtime v2 is on, because
that dispatch runs inside the store transaction.
A dispatch result with its avatar effects rewritten into outbox effects (see `normalize-effect`). Pure, and does nothing to a result without avatar effects. A game's dispatch fn uses this instead of calling the provider inline when runtime v2 is on, because that dispatch runs inside the store transaction.
(normalize-effect provider-name effect)An avatar effect as the protocol emits it -> an outbox effect. provider-name is the
game name, which maps to Yvatar's external_provider.
An avatar effect as the protocol emits it -> an outbox effect. `provider-name` is the game name, which maps to Yvatar's external_provider.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |