Metadata
Metadata: what a command carries beside its payload that the domain doesn’t
decide on, such as the version of the software that ran it, the user who sent
it or the address it came from. It is a JSON object recorded on every event
the command writes, and projections, view models and history can read it.
Like Causation, it travels in the fiber’s context rather than in payloads.
A command records, key by key, from the lowest precedence:
- the metadata where its aggregate service was built, such as the software version provided once for the whole application with layer;
- the metadata where it runs, added with withMetadata;
- the
metadataof adispatchenvelope.
A view model or saga reacting to an event doesn’t inherit that event’s
metadata: its commands record their own. The causationId leads back to the
event, and from there to its metadata.
Type Aliases
Section titled “Type Aliases”Metadata
Section titled “Metadata”Metadata =
Schema.JsonObject
Defined in: src/Metadata.ts:24
A JSON object.
Variables
Section titled “Variables”CurrentMetadata
Section titled “CurrentMetadata”
constCurrentMetadata:Reference<JsonObject>
Defined in: src/Metadata.ts:29
The metadata commands run in this fiber record, {} outside any.
Metadata
Section titled “Metadata”Metadata:
Codec<JsonObject,JsonObject,never,never>
Defined in: src/Metadata.ts:24
withMetadata
Section titled “withMetadata”
constwithMetadata: {(metadata): <A,E,R>(effect) =>Effect<A,E,R>; <A,E,R>(effect,metadata):Effect<A,E,R>; }
Defined in: src/Metadata.ts:34
Runs an effect whose commands record this metadata on top of the current one.
Call Signature
Section titled “Call Signature”(
metadata): <A,E,R>(effect) =>Effect<A,E,R>
Parameters
Section titled “Parameters”metadata
Section titled “metadata”JsonObject
Returns
Section titled “Returns”<A, E, R>(effect) => Effect<A, E, R>
Call Signature
Section titled “Call Signature”<
A,E,R>(effect,metadata):Effect<A,E,R>
Type Parameters
Section titled “Type Parameters”A
E
R
Parameters
Section titled “Parameters”effect
Section titled “effect”Effect<A, E, R>
metadata
Section titled “metadata”JsonObject
Returns
Section titled “Returns”Effect<A, E, R>
Functions
Section titled “Functions”layer()
Section titled “layer()”layer(
metadata):Layer<never>
Defined in: src/Metadata.ts:54
Provides metadata to everything built on top of this layer, for values that hold for the whole process such as the software version:
AppLayer.pipe(Layer.provide(Metadata.layer({ appVersion: "1.4.0" })))Aggregate services remember it, so it is recorded even by commands run where the layer isn’t visible.
Parameters
Section titled “Parameters”metadata
Section titled “metadata”JsonObject
Returns
Section titled “Returns”Layer<never>