@cratis/pi 7.189.2 → 7.189.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package/corpus/harnesses/copilot/instructions/elixir.instructions.md +26 -4
- package/package/corpus/rules/elixir.md +26 -4
- package/package/corpus/skills/cratis-arc-elixir/SKILL.md +22 -12
- package/package/corpus/skills/cratis-arc-elixir/references/availability.md +14 -14
- package/package/corpus/skills/cratis-arc-elixir/references/commands-and-queries.md +8 -8
- package/package/corpus/skills/cratis-arc-elixir/references/event-model.md +79 -0
- package/package/corpus/skills/cratis-arc-elixir/references/hosting-and-testing.md +10 -10
- package/package/corpus/skills/cratis-arc-elixir/references/mongodb.md +9 -9
- package/package/corpus/skills/cratis-arc-elixir/references/observable-queries-and-hubs.md +5 -5
- package/package/corpus/skills/cratis-arc-elixir/references/pitfalls.md +13 -2
- package/package/corpus/skills/cratis-arc-elixir/references/product-sources.md +3 -2
- package/package/corpus/skills/cratis-arc-elixir/references/tenancy-and-identity.md +7 -7
- package/package/corpus/skills/cratis-arc-elixir/verification.json +14 -1
- package/package/corpus/skills/cratis-chronicle-client-elixir/SKILL.md +43 -43
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/append-api.md +4 -4
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/captures.md +5 -5
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/client-options.md +5 -5
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/compliance.md +6 -6
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/connections.md +3 -3
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/constraints.md +6 -6
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/decision-reads.md +12 -12
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/discovery-and-generations.md +10 -10
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/event-sources.md +7 -7
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/graphs.md +6 -6
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/idioms-and-inspection.md +5 -5
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/observability.md +2 -2
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/patterns.md +6 -6
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/pitfalls.md +4 -4
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/projections.md +4 -4
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/reactor-example.md +2 -2
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/read-models.md +7 -7
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/testing.md +15 -15
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/upgrading.md +19 -3
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/variants.md +9 -9
- package/package/corpus/skills/cratis-chronicle-client-elixir/verification.json +3 -3
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
# Event sources and streams
|
|
5
5
|
|
|
6
|
-
Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/chronicle/event_sources/event_source.ex`, `event_sources/routing.ex`, `event_sequences/definition_routing.ex`, and `Documentation/event-sources.md`.
|
|
6
|
+
Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/cratis/chronicle/event_sources/event_source.ex`, `event_sources/routing.ex`, `event_sequences/definition_routing.ex`, and `Documentation/event-sources.md`.
|
|
7
7
|
|
|
8
8
|
Requires `cratis_chronicle` 3.10.0 and Chronicle kernel 19.30.0 for definitions.
|
|
9
9
|
|
|
@@ -14,7 +14,7 @@ An event source definition gives appends a stable name, optional streams and def
|
|
|
14
14
|
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
15
15
|
|
|
16
16
|
defmodule MyApp.AccountEventSource do
|
|
17
|
-
use Chronicle.EventSources.EventSource,
|
|
17
|
+
use Cratis.Chronicle.EventSources.EventSource,
|
|
18
18
|
name: "Account",
|
|
19
19
|
description: "A bank account",
|
|
20
20
|
concurrency: [:event_source_id]
|
|
@@ -26,16 +26,16 @@ defmodule MyApp.AccountEventSource do
|
|
|
26
26
|
end
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
`:name` defaults to the last module segment without a trailing `EventSource`. Dimensions are `:event_source_id`, `:event_source_type`, `:event_stream_type`, `:event_stream_id`. A stream with no dimensions inherits its source's dimensions. Duplicate stream names fail compilation; duplicate source names raise `Chronicle.EventSources.DuplicateEventSourceName` at client startup.
|
|
29
|
+
`:name` defaults to the last module segment without a trailing `EventSource`. Dimensions are `:event_source_id`, `:event_source_type`, `:event_stream_type`, `:event_stream_id`. A stream with no dimensions inherits its source's dimensions. Duplicate stream names fail compilation; duplicate source names raise `Cratis.Chronicle.EventSources.DuplicateEventSourceName` at client startup.
|
|
30
30
|
|
|
31
31
|
## Register and append
|
|
32
32
|
|
|
33
|
-
Set `otp_app:` so discovery finds the definition, or pass `event_sources: [MyApp.AccountEventSource]` to `Chronicle.Client`. Definitions register after event types and before observers on every reconnect. Registration is an upsert; omitting a definition later does not delete it from the kernel.
|
|
33
|
+
Set `otp_app:` so discovery finds the definition, or pass `event_sources: [MyApp.AccountEventSource]` to `Cratis.Chronicle.Client`. Definitions register after event types and before observers on every reconnect. Registration is an upsert; omitting a definition later does not delete it from the kernel.
|
|
34
34
|
|
|
35
35
|
With the client registered and the `MyApp.Events.FundsDeposited` event from the skill declared:
|
|
36
36
|
|
|
37
37
|
```elixir
|
|
38
|
-
case Chronicle.append("account-1", %MyApp.Events.FundsDeposited{amount: 50},
|
|
38
|
+
case Cratis.Chronicle.append("account-1", %MyApp.Events.FundsDeposited{amount: 50},
|
|
39
39
|
event_source: MyApp.AccountEventSource,
|
|
40
40
|
event_stream: "Transactions",
|
|
41
41
|
event_stream_id: "2024-05"
|
|
@@ -47,7 +47,7 @@ end
|
|
|
47
47
|
|
|
48
48
|
The source name becomes the event source type and event `EventSource` metadata; the stream name becomes the event stream type. Sources can be modules or names. Without `:event_stream`, the stream type is `"All"`. `append_many/3` and units of work accept the same source/stream options.
|
|
49
49
|
|
|
50
|
-
Each `Chronicle.EventSequences.EventForEventSourceId` can carry `event_source` and `event_stream`. In `append_many_for_event_sources/2`, entry-level routing wins; batch defaults fill only entries with no source. A routing rejection prevents the whole batch from being sent.
|
|
50
|
+
Each `Cratis.Chronicle.EventSequences.EventForEventSourceId` can carry `event_source` and `event_stream`. In `append_many_for_event_sources/2`, entry-level routing wins; batch defaults fill only entries with no source. A routing rejection prevents the whole batch from being sent.
|
|
51
51
|
|
|
52
52
|
| Reason inside `{:error, reason}` | Cause |
|
|
53
53
|
| --- | --- |
|
|
@@ -59,7 +59,7 @@ Each `Chronicle.EventSequences.EventForEventSourceId` can carry `event_source` a
|
|
|
59
59
|
|
|
60
60
|
## Default concurrency is not an explicit decision guard
|
|
61
61
|
|
|
62
|
-
Without an explicit `:concurrency_scope`, the client reads the tail narrowed by the effective definition dimensions and uses that sequence number as a scope. With no dimensions, it sends no scope. Explicit scopes, including `Chronicle.Events.ConcurrencyScope.none()`, win and avoid that read. Do not disable a guard just to silence a rejection; choose a scope that protects the business decision's reads.
|
|
62
|
+
Without an explicit `:concurrency_scope`, the client reads the tail narrowed by the effective definition dimensions and uses that sequence number as a scope. With no dimensions, it sends no scope. Explicit scopes, including `Cratis.Chronicle.Events.ConcurrencyScope.none()`, win and avoid that read. Do not disable a guard just to silence a rejection; choose a scope that protects the business decision's reads.
|
|
63
63
|
|
|
64
64
|
The wire carries one scope per event source id. Guarded entries of that id must agree on dimensions and selected source type, stream type and stream id. Unguarded entries never suppress a later guarded entry. Incompatible derived guards fail before any tail read or append; use separate batches, or deliberately supply one explicit scope on an entry for that id.
|
|
65
65
|
|
|
@@ -13,22 +13,22 @@
|
|
|
13
13
|
|
|
14
14
|
```elixir
|
|
15
15
|
defmodule MyApp.Graphs.Person do
|
|
16
|
-
use Chronicle.Graphs.Node
|
|
16
|
+
use Cratis.Chronicle.Graphs.Node
|
|
17
17
|
defstruct person_id: "", name: ""
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
defmodule MyApp.Graphs.Group do
|
|
21
|
-
use Chronicle.Graphs.Node
|
|
21
|
+
use Cratis.Chronicle.Graphs.Node
|
|
22
22
|
defstruct group_id: "", name: ""
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
defmodule MyApp.Graphs.MemberOf do
|
|
26
|
-
use Chronicle.Graphs.Edge, type: "MEMBER_OF"
|
|
26
|
+
use Cratis.Chronicle.Graphs.Edge, type: "MEMBER_OF"
|
|
27
27
|
defstruct since: ""
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
defmodule MyApp.Graphs.Organization do
|
|
31
|
-
use Chronicle.Graphs.Graph, id: "Organization"
|
|
31
|
+
use Cratis.Chronicle.Graphs.Graph, id: "Organization"
|
|
32
32
|
|
|
33
33
|
node MyApp.Graphs.Person, key: :person_id do
|
|
34
34
|
from MyApp.Events.PersonRegistered, key: :person_id, set: [name: :name]
|
|
@@ -105,7 +105,7 @@ identity; or a mapped field, option or module is unknown.
|
|
|
105
105
|
## Registering and choosing the sink
|
|
106
106
|
|
|
107
107
|
```elixir
|
|
108
|
-
{Chronicle.Client,
|
|
108
|
+
{Cratis.Chronicle.Client,
|
|
109
109
|
connection_string: "chronicle://localhost:35000",
|
|
110
110
|
event_store: "my-store",
|
|
111
111
|
default_graph_sink_type_id: :in_memory_graph,
|
|
@@ -119,5 +119,5 @@ and tests. `:default_sink_type_id` still chooses the sink of document read model
|
|
|
119
119
|
|
|
120
120
|
## Not supported yet
|
|
121
121
|
|
|
122
|
-
The client does not read a graph (use the engine driver) and `Chronicle.Testing` has no
|
|
122
|
+
The client does not read a graph (use the engine driver) and `Cratis.Chronicle.Testing` has no
|
|
123
123
|
graph scenario, so test a graph by asserting the definition it registers.
|
package/package/corpus/skills/cratis-chronicle-client-elixir/references/idioms-and-inspection.md
CHANGED
|
@@ -4,12 +4,12 @@ This reference holds process-scoped context, discovery and formatter notes, watc
|
|
|
4
4
|
|
|
5
5
|
## Operational inspection
|
|
6
6
|
|
|
7
|
-
`Chronicle.Observers.get_all/1` lists namespace observers; `remove/2` removes an
|
|
7
|
+
`Cratis.Chronicle.Observers.get_all/1` lists namespace observers; `remove/2` removes an
|
|
8
8
|
orphaned observer across the store, refuses running/subscribed observers in any
|
|
9
9
|
namespace, and leaves read model data intact (`observers.ex`). Obtain
|
|
10
10
|
explicit authority before removal and inspect `RemovalResult.outcome` —
|
|
11
|
-
`{:ok, result}` alone does not mean removed. `Chronicle.FailedPartitions` and
|
|
12
|
-
`Chronicle.Jobs` provide failure/job inspection; `Jobs.get/2` lists then finds
|
|
11
|
+
`{:ok, result}` alone does not mean removed. `Cratis.Chronicle.FailedPartitions` and
|
|
12
|
+
`Cratis.Chronicle.Jobs` provide failure/job inspection; `Jobs.get/2` lists then finds
|
|
13
13
|
client-side. Observer types include `:reactor`, `:projection`, `:reducer`,
|
|
14
14
|
`:external`; states include `:active`, `:suspended`, `:replaying`, `:disconnected`,
|
|
15
15
|
`:quarantined` and `:unknown`.
|
|
@@ -17,9 +17,9 @@ client-side. Observer types include `:reactor`, `:projection`, `:reducer`,
|
|
|
17
17
|
## Idioms worth knowing
|
|
18
18
|
|
|
19
19
|
- **Process-scoped context.** Correlation id, identity, and causation are held per
|
|
20
|
-
process: `Chronicle.current_correlation_id/0`, `set_correlation_id/1`,
|
|
20
|
+
process: `Cratis.Chronicle.current_correlation_id/0`, `set_correlation_id/1`,
|
|
21
21
|
`clear_correlation_id/0`; `current_identity/0`, `set_identity/1`,
|
|
22
|
-
`clear_identity/0`; `Chronicle.Auditing.CausationManager`. They are picked up
|
|
22
|
+
`clear_identity/0`; `Cratis.Chronicle.Auditing.CausationManager`. They are picked up
|
|
23
23
|
automatically on append. **A `Task` is a different process** and does not
|
|
24
24
|
inherit them.
|
|
25
25
|
- **Discovery is compile-time reflection.** The `use` macros generate
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
# Observability: OpenTelemetry and `:telemetry`
|
|
5
5
|
|
|
6
|
-
Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/chronicle/diagnostics/tracing.ex`, `connections/trace_propagation_interceptor.ex`, and `Documentation/observability.md`.
|
|
6
|
+
Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/cratis/chronicle/diagnostics/tracing.ex`, `connections/trace_propagation_interceptor.ex`, and `Documentation/observability.md`.
|
|
7
7
|
|
|
8
8
|
Requires `cratis_chronicle` 3.13.0.
|
|
9
9
|
|
|
@@ -34,4 +34,4 @@ The `:stop` metadata carries `error: true` when the operation returned `{:error,
|
|
|
34
34
|
|
|
35
35
|
## Trace propagation
|
|
36
36
|
|
|
37
|
-
Every outbound gRPC call carries W3C `traceparent`/`tracestate` for the span active in the **calling process**, injected by `Chronicle.Connections.TracePropagationInterceptor` (always installed). A trace continues into the kernel only when the append or query runs inside the active span (for example inside `OpenTelemetry.Tracer.with_span/2`); a `Task` is a different process. The kernel does not store trace context on events, so an observer's span is not linked to the append that caused it. OpenTelemetry metrics instruments are not emitted, only `:telemetry` events.
|
|
37
|
+
Every outbound gRPC call carries W3C `traceparent`/`tracestate` for the span active in the **calling process**, injected by `Cratis.Chronicle.Connections.TracePropagationInterceptor` (always installed). A trace continues into the kernel only when the append or query runs inside the active span (for example inside `OpenTelemetry.Tracer.with_span/2`); a `Task` is a different process. The kernel does not store trace context on events, so an observer's span is not linked to the append that caused it. OpenTelemetry metrics instruments are not emitted, only `:telemetry` events.
|
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
|
|
4
4
|
# Behavior patterns
|
|
5
5
|
|
|
6
|
-
Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/chronicle/patterns.ex` and `Documentation/patterns.md`.
|
|
6
|
+
Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/cratis/chronicle/patterns.ex` and `Documentation/patterns.md`.
|
|
7
7
|
|
|
8
8
|
Requires `cratis_chronicle` 3.13.0.
|
|
9
9
|
|
|
10
|
-
`Chronicle.Patterns` queries the recurring behavior (combinations of facets such as `Day`, `TimeBucket`, `CommandType`, `AggregateType`) that Chronicle mined from an event store's history for a scope, for example one user. **An empty result is an answer, not a failure**: the scope has no established behavior for that context. Treat it as "do not claim to know".
|
|
10
|
+
`Cratis.Chronicle.Patterns` queries the recurring behavior (combinations of facets such as `Day`, `TimeBucket`, `CommandType`, `AggregateType`) that Chronicle mined from an event store's history for a scope, for example one user. **An empty result is an answer, not a failure**: the scope has no established behavior for that context. Treat it as "do not claim to know".
|
|
11
11
|
|
|
12
12
|
```elixir
|
|
13
|
-
{:ok, patterns} = Chronicle.Patterns.get_patterns_at("user-42")
|
|
14
|
-
{:ok, patterns} = Chronicle.Patterns.get_patterns_at("user-42", moment, also_constraining: %{Chronicle.Patterns.FacetName.aggregate_type() => "Invoice"})
|
|
15
|
-
action = pattern.facets[Chronicle.Patterns.FacetName.command_type()]
|
|
13
|
+
{:ok, patterns} = Cratis.Chronicle.Patterns.get_patterns_at("user-42")
|
|
14
|
+
{:ok, patterns} = Cratis.Chronicle.Patterns.get_patterns_at("user-42", moment, also_constraining: %{Cratis.Chronicle.Patterns.FacetName.aggregate_type() => "Invoice"})
|
|
15
|
+
action = pattern.facets[Cratis.Chronicle.Patterns.FacetName.command_type()]
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
- Default to `get_patterns_at/3` ("what does this scope usually do now"). It derives `Day` and `TimeBucket` from the moment's **own offset**, not UTC, with the rule the kernel mined with; the moment defaults to now.
|
|
19
19
|
- Use `get_patterns/3` and `get_usual_actions/3` only for a hand-built facet map; `get_usual_actions/3` returns at most one answer per action.
|
|
20
20
|
- `get_patterns_for_scope/2` and `get_scopes/1` inspect what has been mined.
|
|
21
|
-
- `Chronicle.Patterns.time_bucket/1` exposes the kernel's part-of-day rule (`:early_morning`, `:morning`, `:midday`, `:afternoon`, `:evening`, `:night`). **Never write a copy**: a slot the mining never used looks exactly like "nothing established".
|
|
21
|
+
- `Cratis.Chronicle.Patterns.time_bucket/1` exposes the kernel's part-of-day rule (`:early_morning`, `:morning`, `:midday`, `:afternoon`, `:evening`, `:night`). **Never write a copy**: a slot the mining never used looks exactly like "nothing established".
|
|
22
22
|
- Options on every call: `:client`, `:namespace`, `:minimum_confidence` (0.0 to 1.0) and `:max_results`. The all-patterns query is not exposed.
|
|
@@ -8,13 +8,13 @@ Source: `Cratis/Chronicle.Elixir`.
|
|
|
8
8
|
| Pitfall | Why it bites |
|
|
9
9
|
| --- | --- |
|
|
10
10
|
| Copying an older root README | Its module names may not exist; use namespaced `Chronicle.*` modules |
|
|
11
|
-
| Using `Chronicle.Concept` on a client that lacks it | Annotate fields with `pii/1,2` instead |
|
|
11
|
+
| Using `Cratis.Chronicle.Concept` on a client that lacks it | Annotate fields with `pii/1,2` instead |
|
|
12
12
|
| Combining `pii` and `encrypted` | The same leaf raises `PiiAndEncryptedCombinedNotSupported`; neither is allowed on an `event_source_id: true` concept |
|
|
13
13
|
| Quoting the `VERSION` file | It is a build-time placeholder |
|
|
14
14
|
| Putting options only in `config.exs` | The client reads no application env; your app must pass child-spec keyword options |
|
|
15
15
|
| Omitting `:otp_app` | Discovery falls back to scanning every loaded module |
|
|
16
16
|
| Assuming the namespace default is `"default"` | It is `"Default"`; the moduledoc is wrong |
|
|
17
|
-
| `:ok = Chronicle.append(...)` in a server | A constraint violation returns `{:error, _}` and raises `MatchError` |
|
|
17
|
+
| `:ok = Cratis.Chronicle.append(...)` in a server | A constraint violation returns `{:error, _}` and raises `MatchError` |
|
|
18
18
|
| Waiting for `:connected` | Observers attach at `:registered` |
|
|
19
19
|
| Reading `:correlation_id` or `:caused_by` from the context of an older client | It was a bare six-key map before the `EventContext` struct; see the upgrading reference |
|
|
20
20
|
| Two read models with the same final module segment | The default id is the last segment only |
|
|
@@ -23,9 +23,9 @@ Source: `Cratis/Chronicle.Elixir`.
|
|
|
23
23
|
| Shipping the default TLS behavior | `skip_tls_validation` defaults to `true` |
|
|
24
24
|
| Forgetting `global_handlers:` or `:otp_app` discovery | Shared mappings are not merged into variants unless registered |
|
|
25
25
|
| A shared handler mapping a field one variant lacks | `GlobalHandlerPropertyNotOnVariant` at registration, not a silently skipped mapping |
|
|
26
|
-
| `DecisionReads.get/2` outside `Chronicle.decide/2` | Returns `{:error, :requires_unit_of_work}`; it guards nothing |
|
|
26
|
+
| `DecisionReads.get/2` outside `Cratis.Chronicle.decide/2` | Returns `{:error, :requires_unit_of_work}`; it guards nothing |
|
|
27
27
|
| Unset expected sequence number as "expect no event" | It disables the check; use `ConcurrencyScope.expecting_no_matching_event/1` |
|
|
28
|
-
| Passing no `client: client` in a `Chronicle.Testing.Case` spec | The call addresses the default client, not the test's |
|
|
28
|
+
| Passing no `client: client` in a `Cratis.Chronicle.Testing.Case` spec | The call addresses the default client, not the test's |
|
|
29
29
|
| Trusting a spec that passed on the in-memory kernel | Queries, projections and `closes_stream` return `{:error, {:not_supported_in_memory, rpc}}`; use `Testing.Integration` |
|
|
30
30
|
| Renaming a reactor, reducer or projection module without a pinned `:id` | Its observation position silently resets |
|
|
31
31
|
| Capture event type ids with hyphens | `append/2,3` needs an uppercase-first, letters-digits-underscore id |
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
# Projection options and keys
|
|
5
5
|
|
|
6
|
-
Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/chronicle/read_models/read_model.ex`, `projections/projection.ex`, and `registration/coordinator.ex`.
|
|
6
|
+
Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/cratis/chronicle/read_models/read_model.ex`, `projections/projection.ex`, and `registration/coordinator.ex`.
|
|
7
7
|
|
|
8
|
-
`use Chronicle.ReadModels.ReadModel` accepts `id:`, `passive: true`, `not_rewindable: true`, and `event_sequence: "sequence-name"`. Defaults are the last module segment as id, active, rewindable, and `"event-log"`. Standalone `Chronicle.Projections.Projection` also accepts sequence/rewindability options and requires `model:`.
|
|
8
|
+
`use Cratis.Chronicle.ReadModels.ReadModel` accepts `id:`, `passive: true`, `not_rewindable: true`, and `event_sequence: "sequence-name"`. Defaults are the last module segment as id, active, rewindable, and `"event-log"`. Standalone `Cratis.Chronicle.Projections.Projection` also accepts sequence/rewindability options and requires `model:`.
|
|
9
9
|
|
|
10
10
|
AutoMap maps matching event/model properties by default. `no_auto_map()` disables it for the whole projection; `no_auto_map([:balance, :status])` excludes only those properties so explicit mappings can own them.
|
|
11
11
|
|
|
@@ -22,7 +22,7 @@ This module excerpt assumes a registered `MyApp.Events.AccountOpened` event. The
|
|
|
22
22
|
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
23
23
|
|
|
24
24
|
defmodule MyApp.ReadModels.WeeklyAccountOpenings do
|
|
25
|
-
use Chronicle.ReadModels.ReadModel
|
|
25
|
+
use Cratis.Chronicle.ReadModels.ReadModel
|
|
26
26
|
defstruct transaction_count: 0
|
|
27
27
|
|
|
28
28
|
from(MyApp.Events.AccountOpened,
|
|
@@ -55,7 +55,7 @@ from_every(increment: [event_counts: {:event_context, :type}])
|
|
|
55
55
|
|
|
56
56
|
Requires `cratis_chronicle` 3.13.0 for the one-line form, `removed_with_join/2`, `clear_with/2` and the compile-time checks below; `children/2,3` itself requires 3.11.0.
|
|
57
57
|
|
|
58
|
-
`children/2,3` declares a list on the parent that grows, changes and shrinks with events. It works in `use Chronicle.ReadModels.ReadModel` and `use Chronicle.Projections.Projection`; declare the list field's element type with `types: [items: {:list, MyApp.ReadModels.BasketItem}]`.
|
|
58
|
+
`children/2,3` declares a list on the parent that grows, changes and shrinks with events. It works in `use Cratis.Chronicle.ReadModels.ReadModel` and `use Cratis.Chronicle.Projections.Projection`; declare the list field's element type with `types: [items: {:list, MyApp.ReadModels.BasketItem}]`.
|
|
59
59
|
|
|
60
60
|
```elixir
|
|
61
61
|
children :items, identified_by: :item_id do
|
|
@@ -4,7 +4,7 @@ This reference holds a worked reactor module and a worked model-bound read model
|
|
|
4
4
|
|
|
5
5
|
```elixir
|
|
6
6
|
defmodule MyApp.Reactors.DepositLogger do
|
|
7
|
-
use Chronicle.Reactors.Reactor
|
|
7
|
+
use Cratis.Chronicle.Reactors.Reactor
|
|
8
8
|
require Logger
|
|
9
9
|
|
|
10
10
|
alias MyApp.Events.FundsDeposited
|
|
@@ -22,7 +22,7 @@ end
|
|
|
22
22
|
|
|
23
23
|
```elixir
|
|
24
24
|
defmodule MyApp.ReadModels.AccountBalance do
|
|
25
|
-
use Chronicle.ReadModels.ReadModel
|
|
25
|
+
use Cratis.Chronicle.ReadModels.ReadModel
|
|
26
26
|
defstruct id: "", balance: 0
|
|
27
27
|
|
|
28
28
|
from(MyApp.Events.FundsDeposited,
|
|
@@ -3,24 +3,24 @@
|
|
|
3
3
|
|
|
4
4
|
# Querying, observing and previewing read models
|
|
5
5
|
|
|
6
|
-
Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/chronicle/read_models.ex`, `read_models/watchers.ex`, `read_models/reactor.ex`, `projections.ex`, and `Documentation/read-models.md`, `projections.md`.
|
|
6
|
+
Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/cratis/chronicle/read_models.ex`, `read_models/watchers.ex`, `read_models/reactor.ex`, `projections.ex`, and `Documentation/read-models.md`, `projections.md`.
|
|
7
7
|
|
|
8
8
|
Requires `cratis_chronicle` 3.13.0 for everything below except `watch/2`.
|
|
9
9
|
|
|
10
|
-
A read model is eventually consistent: `Chronicle.read_model/3` returns `{:ok, nil}` both for an absent key and for one not projected yet. To read your own write, append with `append_and_wait_for_completion/3` or call `Chronicle.Projections.wait_for/3`.
|
|
10
|
+
A read model is eventually consistent: `Cratis.Chronicle.read_model/3` returns `{:ok, nil}` both for an absent key and for one not projected yet. To read your own write, append with `append_and_wait_for_completion/3` or call `Cratis.Chronicle.Projections.wait_for/3`.
|
|
11
11
|
|
|
12
12
|
## Wait for a projection
|
|
13
13
|
|
|
14
14
|
```elixir
|
|
15
|
-
{:ok, %{sequence_number: sequence}} = Chronicle.EventSequences.EventLog.append_with_result(id, event)
|
|
16
|
-
:ok = Chronicle.Projections.wait_for(MyApp.ReadModels.Account, sequence)
|
|
15
|
+
{:ok, %{sequence_number: sequence}} = Cratis.Chronicle.EventSequences.EventLog.append_with_result(id, event)
|
|
16
|
+
:ok = Cratis.Chronicle.Projections.wait_for(MyApp.ReadModels.Account, sequence)
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
`wait_for/3` polls until the projection has handled that sequence number or returns `{:error, :timeout}`.
|
|
20
20
|
|
|
21
21
|
## Filter and sort
|
|
22
22
|
|
|
23
|
-
`Chronicle.ReadModels.query/2` accepts `:filter` (all conditions must match; a value means equality, or `{:gt, v}`, `{:gte, v}`, `{:lt, v}`, `{:lte, v}`, `{:ne, v}`, `{:in, [v]}`, `{:contains, v}`) and `:sort` (`{:amount, :desc}`). An unknown field returns `{:error, {:unknown_field, field}}`.
|
|
23
|
+
`Cratis.Chronicle.ReadModels.query/2` accepts `:filter` (all conditions must match; a value means equality, or `{:gt, v}`, `{:gte, v}`, `{:lt, v}`, `{:lte, v}`, `{:ne, v}`, `{:in, [v]}`, `{:contains, v}`) and `:sort` (`{:amount, :desc}`). An unknown field returns `{:error, {:unknown_field, field}}`.
|
|
24
24
|
|
|
25
25
|
**The client applies the filter** by paging through the whole read model, because the kernel contract cannot filter. A read model with more than `:max_scan` instances (default `10_000`) returns `{:error, {:scan_limit_exceeded, max_scan}}` rather than a partial answer. For large data, give the question its own projection.
|
|
26
26
|
|
|
@@ -34,8 +34,8 @@ A read model is eventually consistent: `Chronicle.read_model/3` returns `{:ok, n
|
|
|
34
34
|
|
|
35
35
|
`subscribe/2` shares one kernel stream per read model, client, namespace and event sequence and reconnects with backoff (500 ms doubling to 30 s). **Changes made while the stream was down are not replayed**; query again after `:chronicle_read_model_watch_resumed`. `observe/2` accepts `:page_size`, `:filter` and `:sort`; with a filter, `total_count` counts matches within the delivered page only.
|
|
36
36
|
|
|
37
|
-
A `use Chronicle.ReadModels.Reactor, model: M` module reacts to read model changes through optional `on_added/2`, `on_modified/2` and `on_removed/2`, and is registered with the client's `:read_model_reactors` option. It subscribes through `subscribe/2` and re-subscribes after a reconnect.
|
|
37
|
+
A `use Cratis.Chronicle.ReadModels.Reactor, model: M` module reacts to read model changes through optional `on_added/2`, `on_modified/2` and `on_removed/2`, and is registered with the client's `:read_model_reactors` option. It subscribes through `subscribe/2` and re-subscribes after a reconnect.
|
|
38
38
|
|
|
39
39
|
## Ad-hoc queries and previews
|
|
40
40
|
|
|
41
|
-
`Chronicle.Projections.query/2` sends a Projection Declaration Language string to the kernel and returns the projected entries without registering a projection or defining a module; entries are plain maps unless `:read_model` is given. Bad syntax returns `{:error, {:invalid_declaration, [%{message:, line:, column:}]}}`. `Chronicle.Projections.preview/2` runs an **already registered** projection's declaration over the stored event sequence; previewing over events you supply is not possible.
|
|
41
|
+
`Cratis.Chronicle.Projections.query/2` sends a Projection Declaration Language string to the kernel and returns the projected entries without registering a projection or defining a module; entries are plain maps unless `:read_model` is given. Bad syntax returns `{:error, {:invalid_declaration, [%{message:, line:, column:}]}}`. `Cratis.Chronicle.Projections.preview/2` runs an **already registered** projection's declaration over the stored event sequence; previewing over events you supply is not possible.
|
|
@@ -3,28 +3,28 @@
|
|
|
3
3
|
|
|
4
4
|
# Testing against an in-memory kernel
|
|
5
5
|
|
|
6
|
-
Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/chronicle/testing.ex`, `testing/case.ex`, `testing/assertions.ex`, `testing/in_memory_kernel.ex`, `testing/integration.ex`, `testing/projections.ex`, and `Documentation/testing.md`.
|
|
6
|
+
Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/cratis/chronicle/testing.ex`, `testing/case.ex`, `testing/assertions.ex`, `testing/in_memory_kernel.ex`, `testing/integration.ex`, `testing/projections.ex`, and `Documentation/testing.md`.
|
|
7
7
|
|
|
8
|
-
Requires `cratis_chronicle` 3.13.0. Earlier clients ship no `Chronicle.Testing` modules.
|
|
8
|
+
Requires `cratis_chronicle` 3.13.0. Earlier clients ship no `Cratis.Chronicle.Testing` modules.
|
|
9
9
|
|
|
10
|
-
## Default: `Chronicle.Testing.Case`
|
|
10
|
+
## Default: `Cratis.Chronicle.Testing.Case`
|
|
11
11
|
|
|
12
|
-
Use the case template for ExUnit specs. It starts a real `Chronicle.Client` against `Chronicle.Testing.InMemoryKernel`, puts the client name in the test context as `:chronicle`, and stops it on exit. Every test gets a unique event store, so it is safe under `async: true`.
|
|
12
|
+
Use the case template for ExUnit specs. It starts a real `Cratis.Chronicle.Client` against `Cratis.Chronicle.Testing.InMemoryKernel`, puts the client name in the test context as `:chronicle`, and stops it on exit. Every test gets a unique event store, so it is safe under `async: true`.
|
|
13
13
|
|
|
14
14
|
```elixir
|
|
15
15
|
# Copyright (c) Cratis. All rights reserved.
|
|
16
16
|
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
17
17
|
|
|
18
18
|
defmodule MyApp.AccountTest do
|
|
19
|
-
use Chronicle.Testing.Case,
|
|
19
|
+
use Cratis.Chronicle.Testing.Case,
|
|
20
20
|
event_types: [MyApp.Events.AccountOpened],
|
|
21
21
|
reducers: [MyApp.Reducers.AccountReducer]
|
|
22
22
|
|
|
23
|
-
import Chronicle.Testing.Assertions
|
|
23
|
+
import Cratis.Chronicle.Testing.Assertions
|
|
24
24
|
|
|
25
25
|
test "opening an account appends AccountOpened", %{chronicle: client} do
|
|
26
26
|
:ok =
|
|
27
|
-
Chronicle.EventSequences.EventLog.append(
|
|
27
|
+
Cratis.Chronicle.EventSequences.EventLog.append(
|
|
28
28
|
"account-1",
|
|
29
29
|
%MyApp.Events.AccountOpened{owner_name: "Alice"},
|
|
30
30
|
client: client
|
|
@@ -35,16 +35,16 @@ defmodule MyApp.AccountTest do
|
|
|
35
35
|
end
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
**Pass `client: client` on every call.** Without it the call addresses the default `Chronicle.Client` name, not the test's client.
|
|
38
|
+
**Pass `client: client` on every call.** Without it the call addresses the default `Cratis.Chronicle.Client` name, not the test's client.
|
|
39
39
|
|
|
40
40
|
`start_supervised_client/1` (outside ExUnit templates; pair with `stop_supervised_client/1`) accepts `:event_types`, `:event_sources`, `:constraints` (standalone constraint modules), `:reactors`, `:reducers`, `:projections`, `:name`, `:event_store` and `:namespace`.
|
|
41
41
|
|
|
42
42
|
## Waiting and reading
|
|
43
43
|
|
|
44
|
-
An append returns once the event is committed; reactors and reducers run afterward in `Chronicle.Testing.Dispatcher`, synchronously after each committed append. Call `Chronicle.Testing.wait_for_observers(client)` before asserting on their effects; it is a sleep-free barrier that returns `{:error, failures}` when a reactor or reducer raised.
|
|
44
|
+
An append returns once the event is committed; reactors and reducers run afterward in `Cratis.Chronicle.Testing.Dispatcher`, synchronously after each committed append. Call `Cratis.Chronicle.Testing.wait_for_observers(client)` before asserting on their effects; it is a sleep-free barrier that returns `{:error, failures}` when a reactor or reducer raised.
|
|
45
45
|
|
|
46
|
-
- `Chronicle.Testing.read_model(client, ReducerModule, key)` reads the state a **reducer** built, keyed by event source id.
|
|
47
|
-
- `Chronicle.Testing.appended_events(client, event_source_id)` returns decoded `Chronicle.Events.AppendedEvent` structs.
|
|
46
|
+
- `Cratis.Chronicle.Testing.read_model(client, ReducerModule, key)` reads the state a **reducer** built, keyed by event source id.
|
|
47
|
+
- `Cratis.Chronicle.Testing.appended_events(client, event_source_id)` returns decoded `Cratis.Chronicle.Events.AppendedEvent` structs.
|
|
48
48
|
|
|
49
49
|
## Assertions
|
|
50
50
|
|
|
@@ -54,10 +54,10 @@ An append returns once the event is committed; reactors and reducers run afterwa
|
|
|
54
54
|
|
|
55
55
|
Appends, reads, the tail lookups, concurrency scopes (including `expecting_no_matching_event/1`), and `unique/2` and `unique_event_type/1` constraints are modeled. **Everything else returns `{:error, {:not_supported_in_memory, rpc}}`**: `closes_stream` constraints, `ReadModels` queries and `Projections` queries. A spec that passes against it proves client logic, not kernel behavior.
|
|
56
56
|
|
|
57
|
-
`Chronicle.Testing.Projections.apply_event(ReadModel, instance_or_nil, event)` folds one event through the supported subset of a read model's declarations (`from/2` with `:set`, `:add`, `:subtract`, `:count`, `:increment`, `:decrement`, `:clear`, AutoMap, and `removed_with/2`). `join/2`, `children/2`, `from_every/1` and `removed_with_join/2` raise `Chronicle.Testing.UnsupportedProjectionOperation`; test those against a real kernel.
|
|
57
|
+
`Cratis.Chronicle.Testing.Projections.apply_event(ReadModel, instance_or_nil, event)` folds one event through the supported subset of a read model's declarations (`from/2` with `:set`, `:add`, `:subtract`, `:count`, `:increment`, `:decrement`, `:clear`, AutoMap, and `removed_with/2`). `join/2`, `children/2`, `from_every/1` and `removed_with_join/2` raise `Cratis.Chronicle.Testing.UnsupportedProjectionOperation`; test those against a real kernel.
|
|
58
58
|
|
|
59
|
-
## Real kernel: `Chronicle.Testing.Integration`
|
|
59
|
+
## Real kernel: `Cratis.Chronicle.Testing.Integration`
|
|
60
60
|
|
|
61
|
-
Tag these specs `@moduletag :integration`. `Chronicle.Testing.Integration.setup_isolated_client(opts, client \\ Chronicle.Client)` starts a real client with a unique event store and namespace, reading `CHRONICLE_INTEGRATION_CONNECTION_STRING` unless `:connection_string` is given, and waits for registration. Use `append_with_result/3` then `Integration.wait_for_observers(result.sequence_number, client: client)`; do not sleep. The stores it creates are not deleted afterward because the kernel has no delete call.
|
|
61
|
+
Tag these specs `@moduletag :integration`. `Cratis.Chronicle.Testing.Integration.setup_isolated_client(opts, client \\ Cratis.Chronicle.Client)` starts a real client with a unique event store and namespace, reading `CHRONICLE_INTEGRATION_CONNECTION_STRING` unless `:connection_string` is given, and waits for registration. Use `append_with_result/3` then `Integration.wait_for_observers(result.sequence_number, client: client)`; do not sleep. The stores it creates are not deleted afterward because the kernel has no delete call.
|
|
62
62
|
|
|
63
|
-
`Chronicle` adopts `Chronicle.Behaviour`, so code that only needs to be observed calling the facade can use a Mox mock (`Mox.defmock(Mock, for: Chronicle.Behaviour)`); Mox is not a dependency of the client.
|
|
63
|
+
`Chronicle` adopts `Cratis.Chronicle.Behaviour`, so code that only needs to be observed calling the facade can use a Mox mock (`Mox.defmock(Mock, for: Cratis.Chronicle.Behaviour)`); Mox is not a dependency of the client.
|
|
@@ -3,7 +3,23 @@
|
|
|
3
3
|
|
|
4
4
|
# Upgrading from older clients
|
|
5
5
|
|
|
6
|
-
Source: `Cratis/Chronicle.Elixir` (`Source/chronicle/mix.exs`, `mix.lock`, `lib/chronicle/wire_result.ex`, `jobs.ex`, `event_sequences/event_log.ex`, `read_models.ex`, `seeding.ex`).
|
|
6
|
+
Source: `Cratis/Chronicle.Elixir` (`Source/chronicle/mix.exs`, `mix.lock`, `lib/cratis/chronicle/wire_result.ex`, `jobs.ex`, `event_sequences/event_log.ex`, `read_models.ex`, `seeding.ex`).
|
|
7
|
+
|
|
8
|
+
## Moving to the 4.x line
|
|
9
|
+
|
|
10
|
+
The 4.x line moved every module under the `Cratis` namespace and `lib/chronicle` to
|
|
11
|
+
`lib/cratis/chronicle`. It is a breaking, mechanical change; nothing else in the API moved.
|
|
12
|
+
|
|
13
|
+
| Before | Now |
|
|
14
|
+
| --- | --- |
|
|
15
|
+
| `use Chronicle.Events.EventType, id: "..."` | `use Cratis.Chronicle.Events.EventType, id: "..."` |
|
|
16
|
+
| `Chronicle.append/2`, `Chronicle.all/2` | `Cratis.Chronicle.append/2`, `Cratis.Chronicle.all/2` |
|
|
17
|
+
| `Chronicle.Reactors.Reactor`, `Reducers.Reducer`, `Projections.Projection` | the same names under `Cratis.Chronicle.` |
|
|
18
|
+
| `Chronicle.Testing` | `Cratis.Chronicle.Testing` |
|
|
19
|
+
|
|
20
|
+
Rename with a search for `Chronicle.` not preceded by `Cratis.` or a dot, then recompile. Use the latest
|
|
21
|
+
patch of the line: its first release passed a reducer handler a state without `client`, which the next
|
|
22
|
+
patch restores. A current Arc for Elixir release needs this line.
|
|
7
23
|
|
|
8
24
|
## Dependencies and wire compatibility
|
|
9
25
|
|
|
@@ -39,7 +55,7 @@ Requires `cratis_chronicle` 3.13.0 for the behaviors below; each is a difference
|
|
|
39
55
|
|
|
40
56
|
| Behavior | Review |
|
|
41
57
|
| --- | --- |
|
|
42
|
-
| Reactor and reducer `context` is a `Chronicle.Events.EventContext` struct | Pattern matches on a bare map keep working; `correlation_id`, `caused_by`, `causation`, `tags`, `subject`, `appended_generation` and `replaying?` are now present |
|
|
58
|
+
| Reactor and reducer `context` is a `Cratis.Chronicle.Events.EventContext` struct | Pattern matches on a bare map keep working; `correlation_id`, `caused_by`, `causation`, `tags`, `subject`, `appended_generation` and `replaying?` are now present |
|
|
43
59
|
| `drift_policy` defaults to `:warn` | Start-up makes extra kernel calls and logs findings; set `:ignore` to skip them, `:fail` to block on a drift warning |
|
|
44
60
|
| Discovery warns once per module for a reactor, reducer or projection with no pinned `:id` | Pin ids before renaming or moving modules; see [discovery-and-generations.md](discovery-and-generations.md) |
|
|
45
61
|
| Appending a struct that is not an event type returns `{:error, {:unknown_event_type, module}}` | Handle it as an ordinary append error |
|
|
@@ -49,4 +65,4 @@ Requires `cratis_chronicle` 3.13.0 for the behaviors below; each is a difference
|
|
|
49
65
|
|
|
50
66
|
Requires `cratis_chronicle` 3.11.0 for the context struct; it was a bare map before.
|
|
51
67
|
|
|
52
|
-
Capabilities covered by these references: decision reads ([decision-reads.md](decision-reads.md)), `Chronicle.Testing` ([testing.md](testing.md)), captures ([captures.md](captures.md)), standalone constraints ([constraints.md](constraints.md)), `Chronicle.Patterns` ([patterns.md](patterns.md)) and read model subscriptions ([read-models.md](read-models.md)). A git tag is not a Hex release: confirm the version is on hex.pm before depending on it.
|
|
68
|
+
Capabilities covered by these references: decision reads ([decision-reads.md](decision-reads.md)), `Cratis.Chronicle.Testing` ([testing.md](testing.md)), captures ([captures.md](captures.md)), standalone constraints ([constraints.md](constraints.md)), `Cratis.Chronicle.Patterns` ([patterns.md](patterns.md)) and read model subscriptions ([read-models.md](read-models.md)). A git tag is not a Hex release: confirm the version is on hex.pm before depending on it.
|
|
@@ -12,8 +12,8 @@ The client source does not establish whether the kernel maps `$eventSourceId` pr
|
|
|
12
12
|
Some entities do not have one shape for their whole lifetime — a work item is a
|
|
13
13
|
backlog entry until a pull request exists for it, then it is a pull request
|
|
14
14
|
until it merges. `variant_of/2` and `enters_on/1,2` are macros imported by
|
|
15
|
-
**both** `use Chronicle.ReadModels.ReadModel` and
|
|
16
|
-
`use Chronicle.Projections.Projection`, so the model-bound and declarative
|
|
15
|
+
**both** `use Cratis.Chronicle.ReadModels.ReadModel` and
|
|
16
|
+
`use Cratis.Chronicle.Projections.Projection`, so the model-bound and declarative
|
|
17
17
|
paths declare a variant identically:
|
|
18
18
|
|
|
19
19
|
```elixir
|
|
@@ -21,7 +21,7 @@ defmodule MyApp.ReadModels.WorkItem do
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
defmodule MyApp.ReadModels.BacklogItem do
|
|
24
|
-
use Chronicle.ReadModels.ReadModel
|
|
24
|
+
use Cratis.Chronicle.ReadModels.ReadModel
|
|
25
25
|
defstruct id: "", title: ""
|
|
26
26
|
|
|
27
27
|
variant_of MyApp.ReadModels.WorkItem, key: :id
|
|
@@ -31,7 +31,7 @@ defmodule MyApp.ReadModels.BacklogItem do
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
defmodule MyApp.ReadModels.PullRequestItem do
|
|
34
|
-
use Chronicle.ReadModels.ReadModel
|
|
34
|
+
use Cratis.Chronicle.ReadModels.ReadModel
|
|
35
35
|
defstruct id: "", title: "", pull_request_url: "", build_status: ""
|
|
36
36
|
|
|
37
37
|
variant_of MyApp.ReadModels.WorkItem, key: :id
|
|
@@ -53,24 +53,24 @@ locally or merged from a shared handler, is automatically reclassified into an
|
|
|
53
53
|
update-only join keyed on `variant_of`'s `:key`.
|
|
54
54
|
|
|
55
55
|
A mapping shared across every variant of an identity is a
|
|
56
|
-
`Chronicle.Projections.GlobalHandler`, never registered as a projection on its
|
|
56
|
+
`Cratis.Chronicle.Projections.GlobalHandler`, never registered as a projection on its
|
|
57
57
|
own:
|
|
58
58
|
|
|
59
59
|
```elixir
|
|
60
60
|
defmodule MyApp.Projections.WorkItemTitleHandler do
|
|
61
|
-
use Chronicle.Projections.GlobalHandler, identity: MyApp.ReadModels.WorkItem
|
|
61
|
+
use Cratis.Chronicle.Projections.GlobalHandler, identity: MyApp.ReadModels.WorkItem
|
|
62
62
|
|
|
63
63
|
from MyApp.Events.TitleChanged, set: [title: :title]
|
|
64
64
|
end
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
Register it explicitly with `global_handlers: [...]` on `Chronicle.Client`, or
|
|
67
|
+
Register it explicitly with `global_handlers: [...]` on `Cratis.Chronicle.Client`, or
|
|
68
68
|
let `:otp_app` auto-discovery find it (modules exporting
|
|
69
69
|
`__chronicle_global_handler__/1`). A mapping that targets a field some variant
|
|
70
|
-
lacks raises `Chronicle.Projections.GlobalHandlerPropertyNotOnVariant` at
|
|
70
|
+
lacks raises `Cratis.Chronicle.Projections.GlobalHandlerPropertyNotOnVariant` at
|
|
71
71
|
registration, not a silently skipped mapping.
|
|
72
72
|
|
|
73
73
|
**A variant with no `enters_on` raises
|
|
74
|
-
`Chronicle.Projections.VariantMustDeclareEntersOnEvent`** at registration — a
|
|
74
|
+
`Cratis.Chronicle.Projections.VariantMustDeclareEntersOnEvent`** at registration — a
|
|
75
75
|
variant that could never be entered could never be written to at all, since
|
|
76
76
|
every other handler on it is update-only.
|
|
@@ -4,18 +4,18 @@
|
|
|
4
4
|
"fixtures": [],
|
|
5
5
|
"assertions": [
|
|
6
6
|
{ "kind": "skill-contains", "value": "`Cratis/Chronicle.Elixir`" },
|
|
7
|
-
{ "kind": "skill-contains", "value": "{:cratis_chronicle, \"~>
|
|
7
|
+
{ "kind": "skill-contains", "value": "{:cratis_chronicle, \"~> 4.0\"}" },
|
|
8
8
|
{ "kind": "skill-contains", "value": "ConnectionString.development()" },
|
|
9
9
|
{ "kind": "skill-contains", "value": "`~> 1.18`" },
|
|
10
10
|
{ "kind": "skill-contains", "value": "`nil` registers as string" },
|
|
11
|
-
{ "kind": "skill-contains", "value": "**The context is a `Chronicle.Events.EventContext` struct**" },
|
|
11
|
+
{ "kind": "skill-contains", "value": "**The context is a `Cratis.Chronicle.Events.EventContext` struct**" },
|
|
12
12
|
{ "kind": "skill-contains", "value": "`delivery_id` (stable across replay and failed-partition" },
|
|
13
13
|
{ "kind": "skill-contains", "value": "**Page 1 is the second page**" },
|
|
14
14
|
{ "kind": "skill-contains", "value": "`:retry_attempts` is accepted but ignored", "file": "references/connections.md" },
|
|
15
15
|
{ "kind": "skill-contains", "value": "Client certificates cannot be combined with `disableTls=true`", "file": "references/connections.md" },
|
|
16
16
|
{ "kind": "skill-contains", "value": "registered-source metadata", "file": "references/event-sources.md" },
|
|
17
17
|
{ "kind": "skill-contains", "value": "`{:incompatible_concurrency_scopes, id, guards}`", "file": "references/event-sources.md" },
|
|
18
|
-
{ "kind": "skill-contains", "value": "`Chronicle.Events.ConcurrencyScope.none()`", "file": "references/event-sources.md" },
|
|
18
|
+
{ "kind": "skill-contains", "value": "`Cratis.Chronicle.Events.ConcurrencyScope.none()`", "file": "references/event-sources.md" },
|
|
19
19
|
{ "kind": "skill-contains", "value": "**no many-event variant**", "file": "references/append-api.md" },
|
|
20
20
|
{ "kind": "skill-contains", "value": "`subject/1` is not imported by `EventType`", "file": "references/compliance.md" },
|
|
21
21
|
{ "kind": "skill-contains", "value": "calendar year, not the ISO week-year", "file": "references/projections.md" },
|