Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Documentation/chronicle/add-event-sourcing.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const app = await builder.build();
await app.run({ port: Number(process.env.PORT ?? 3000) });
```

Importing `@cratis/arc.chronicle` adds `withChronicle` to the builder. Call it before or after `discover`: the integration records each discovered event type and projection, including those discovered earlier, and hands them to Chronicle when it connects. The application connects when a command or query first needs Chronicle, and Chronicle creates the `MyArcApp` event store then. Events and read models go to the namespace of the request's tenant; this application resolves no tenant, so they go to the `Default` namespace.
Importing `@cratis/arc.chronicle` adds `withChronicle` to the builder. Call it before `discover`: the integration records each discovered event type and projection and hands them to Chronicle when it connects. Classes with Arc metadata are recorded either way, but a Chronicle-only class discovered before `withChronicle` is dropped unless `activateArtifactsInScopes` is on. The application connects when a command or query first needs Chronicle, and Chronicle creates the `MyArcApp` event store then. Events and read models go to the namespace of the request's tenant; this application resolves no tenant, so they go to the `Default` namespace.

Call `withChronicle` before `add()` for Chronicle-only artifacts: without an Arc decorator, `add()` rejects them until Chronicle is registered. `chronicle://localhost:35000` without credentials uses the SDK's development client and accepts the kernel's self-signed certificate. That fits a local kernel only. [Registration options](registration-options.md) shows how to read the connection from `appsettings.json` or environment variables, and how to pass a client you create yourself.

Expand Down
2 changes: 1 addition & 1 deletion Documentation/chronicle/reactors/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class ShelfBuilder {
}
```

`CreateShelf` is an ordinary Arc `@command()` in your application. Register the reactor the way you register every other artifact, with `builder.add(...)` after [`withChronicle`](../add-event-sourcing.md), or with `builder.discover(...)` in either order. The Arc-owned Chronicle client starts observing it when the application builds.
`CreateShelf` is an ordinary Arc `@command()` in your application. Register the reactor the way you register every other artifact, with `builder.add(...)` or `builder.discover(...)` after [`withChronicle`](../add-event-sourcing.md). A reactor has no Arc decorator, so one discovered before `withChronicle` is dropped unless [`activateArtifactsInScopes`](scoped-activation.md) is on. The Arc-owned Chronicle client starts observing it when the application builds.

## How a handler is found

Expand Down
2 changes: 1 addition & 1 deletion Documentation/chronicle/registration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ builder.withChronicle({ connectionString: 'chronicle://localhost:35000', eventSt

Importing `@cratis/arc.chronicle` adds the `withChronicle` method to the Node builder and to the Fetch API builder from `@cratis/arc.core/fetch`. The package also exports the function `withChronicle(builder, options)`, which does the same; the [Library sample](https://github.com/Cratis/Arc.TypeScript/blob/main/Samples/Library/main.ts) uses that form.

Call it before or after `discover(...)`. The integration records the event types, projections, reducers, reactors, and constraints discovered by Arc, including artifacts discovered earlier. For Chronicle-only artifacts passed to `add(...)`, call `withChronicle` first: Arc otherwise rejects them without an Arc decorator. Arc-owned clients pass the registered artifacts to the SDK and set `discoveryPatterns: []`, so they do not depend on SDK file scanning. For a caller-owned client, import and register your artifacts explicitly or configure its `discoveryPatterns`. Since SDK 6.10.0, compiled JavaScript entry points no longer scan `.ts` files by default; explicit patterns still apply.
The integration records the event types, projections, reducers, reactors, and constraints Arc discovers. A class with Arc metadata is recorded whether `discover(...)` runs before or after `withChronicle`. A Chronicle-only class, one without an Arc decorator, is picked up only when `withChronicle` runs first, so call it before `discover(...)`. The same goes for `add(...)`, which otherwise rejects such a class. With [`activateArtifactsInScopes`](reactors/scoped-activation.md) on, Chronicle-only classes discovered earlier are picked up too. Arc-owned clients pass the registered artifacts to the SDK and set `discoveryPatterns: []`, so they do not depend on SDK file scanning. For a caller-owned client, import and register your artifacts explicitly or configure its `discoveryPatterns`. Since SDK 6.10.0, compiled JavaScript entry points no longer scan `.ts` files by default; explicit patterns still apply.

Each recorded reactor and reducer also gets a scoped service registration in Arc, but only when nothing else registers that class. A registration in `builder.services` (before or after `withChronicle`), an entry in `options.services`, or an Arc lifetime decorator such as `@singleton()` always wins, and discovering an artifact twice does not add a second registration. With a caller-supplied `ServiceRegistry` in `options.services`, Arc adds no such registrations; register the artifacts yourself. By default Arc does not construct reactors or reducers through these registrations; the Chronicle SDK creates them. To opt in, see [Scoped activation](reactors/scoped-activation.md).

Expand Down
Loading