### C# Aggregate Root Example Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/aggregates.md A C# example demonstrating the structure and logic of an aggregate root, enforcing business rules before an action. ```csharp public class Kitchen { Chefs _chefs; Inventory _inventory; Menu _menu; public void PrepareDish(Dish dish) { if (!_menu.Contains(dish)) { throw new DishNotOnMenu(dish); } foreach (var ingredient in dish.ingredients) { var foundIngredient = _inventory .GetIngredient(ingredient.Name); if (!foundIngredient) { throw new IngredientNotInInventory(ingredient); } if (foundIngredient.Amount < ingredient.Amount) { throw new InventoryOutOfIngredient(foundIngredient); } } var availableChef = _chefs.GetAvailableChef(); if (!availableChef) { throw new NoAvailableChefs(); } availableChef.IsAvailable = false; } } ``` -------------------------------- ### Basic Projection Example Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/projections.md Defines a projection that tracks eaten dishes. It handles the DishEaten event and appends the dish to a list. The projection is identified by a GUID. ```csharp [Projection("185107c2-f897-40c8-bb06-643b3642f230")] public class DishesEaten: ReadModel { public string[] Dishes { get; set; } = {}; public void On(DishEaten evt, ProjectionContext ctx) // Create On-methods for each event you want to handle { Dishes = Dishes.Append(evt.Dish).ToArray(); // And update its state } } ``` -------------------------------- ### Example runtime.yml Configuration Source: https://github.com/dolittle/runtime/blob/master/Documentation/References/configuration.md This snippet shows a comprehensive example of a runtime.yml file, including platform details, microservice configurations, and tenant-specific resources like event store and read models, as well as event horizon consents. ```yaml platform: customerID: 6d8eaf84-969c-4234-b78f-30632a608e5a applicationID: e0078604-ae62-378d-46fb-9e245d824c61 microserviceID: ffb20e4f-9227-574d-31aa-d6e59b34495d customerName: TheCustomer applicationName: TheApplication microserviceName: TheMicroservice environment: Dev microservices: d47c6fb7-2339-e286-2912-2b9f163a5aa3: host: some.host port: 50052 tenants: 1c707441-95b3-4214-a4d1-4199c58afa23: resources: eventStore: connectionString: mongodb://my.host:27017 database: eventstore readModels: connectionString: mongodb://my.host:27017 database: readmodels eventHorizons: d47c6fb7-2339-e286-2912-2b9f163a5aa3: consents: - consumerTenant: c5b5847a-68e6-4b31-ad33-8f2beb216d8b stream: d9b302bb-5439-4226-a225-3b4a0986f6ed partition: 00000000-0000-0000-0000-000000000000 consent: 4d43e837-0a8e-4b3d-a3eb-5301f5650d91 ``` -------------------------------- ### Install Dolittle CLI as a .NET tool Source: https://github.com/dolittle/runtime/blob/master/Documentation/CLI/_index.md Installs the Dolittle Runtime CLI tool globally on your machine using the .NET CLI. ```shell dotnet tool install --global Dolittle.Runtime.CLI ``` -------------------------------- ### Docker Compose runtime.yml Configuration Source: https://github.com/dolittle/runtime/blob/master/Documentation/References/configuration.md This YAML snippet is an example of a runtime.yml file used within a Docker Compose setup, specifying MongoDB connection details for both the Runtime and the host machine. ```yaml tenants: 445f8ea8-1a6f-40d7-b2fc-796dba92dc44: # Development Tenant resources: eventStore: connectionString: mongodb://mongo:27017 # Accessed by the Runtime, from within the compose network database: event_store maxConnectionPoolSize: 1000 readModels: connectionString: mongodb://localhost:27017 # Accessed by the application, from the host machine database: readmodels ``` -------------------------------- ### Run MongoDB Docker Container Source: https://github.com/dolittle/runtime/blob/master/Source/Events.Store.MongoDB/Development/MongoDB/README.md Starts a MongoDB Docker container in detached mode, exposing port 27017. This is the primary command to get a local MongoDB instance running. ```shell $ docker run -d -p 27017:27017 dolittle/mongodb 4a05adadc29a672c695a57cbd5fb87c120d1201eda5a7d6f4bc7c68c31c5dffd ``` -------------------------------- ### Get details about a running Aggregate Root Source: https://github.com/dolittle/runtime/blob/master/Documentation/CLI/_index.md Retrieve detailed information about a specific running Aggregate Root. ```shell dolittle runtime aggregates get ``` -------------------------------- ### Get details about a running Event Handler Source: https://github.com/dolittle/runtime/blob/master/Documentation/CLI/_index.md Obtain detailed information for a specific running Event Handler. ```shell dolittle runtime eventhandlers get ``` -------------------------------- ### CLI Command to Get Event Handler Source: https://github.com/dolittle/runtime/blob/master/Documentation/CLI/Runtime/EventHandlers/get.md Use this command to retrieve details of a specific Event Handler. Provide the Event Handler's identifier, which can be an ID or alias, optionally with a scope. Options can filter by tenant, specify the runtime host, and control output format. ```shell dolittle runtime eventhandlers get [options] ``` -------------------------------- ### Update Dolittle CLI as a .NET tool Source: https://github.com/dolittle/runtime/blob/master/Documentation/CLI/_index.md Updates the globally installed Dolittle Runtime CLI tool to the latest version. ```shell dotnet tool update --global Dolittle.Runtime.CLI ``` -------------------------------- ### Get Aggregate Root Command Source: https://github.com/dolittle/runtime/blob/master/Documentation/CLI/Runtime/Aggregates/get.md This is the basic command to retrieve details for a specific Aggregate Root. Replace `` with the actual ID or alias of the Aggregate Root. ```shell dolittle runtime aggregates get [options] ``` -------------------------------- ### Get committed events for an Aggregate Root Instance Source: https://github.com/dolittle/runtime/blob/master/Documentation/CLI/_index.md Fetch the history of committed events associated with a particular Aggregate Root instance. ```shell dolittle runtime aggregates events ``` -------------------------------- ### appsettings.json Configuration Structure Source: https://github.com/dolittle/runtime/blob/master/Documentation/References/configuration.md This JSON structure illustrates how Runtime configurations can be provided through the Asp.Net appsettings.json file, using the 'Dolittle:Runtime' prefix. ```json { "Dolittle": { "Runtime": { "Platform": { "ApplicationID": ... }, "Tenants": { "": { "Resources": { ... } } } } }, "Logging": { ... } } ``` -------------------------------- ### Make binary executable Source: https://github.com/dolittle/runtime/blob/master/Documentation/CLI/_index.md Makes the downloaded Dolittle CLI binary executable on a Unix-like system. ```shell chomd a+x /usr/local/bin/dolittle ``` -------------------------------- ### Default runtime.yml Configuration Source: https://github.com/dolittle/runtime/blob/master/Documentation/References/configuration.md This snippet shows the default runtime.yml configuration provided with dolittle/runtime images, which sets up resources for the 'Development Tenant'. ```yaml tenants: 445f8ea8-1a6f-40d7-b2fc-796dba92dc44: resources: eventStore: connectionString: mongodb://localhost:27017 database: event_store maxConnectionPoolSize: 1000 readModels: connectionString: mongodb://localhost:27017 database: readmodels useSSL: false ``` -------------------------------- ### Docker Compose for Dolittle Runtime and MongoDB Source: https://github.com/dolittle/runtime/blob/master/Documentation/References/configuration.md This docker-compose.yml file sets up a MongoDB replica set and the Dolittle runtime. The runtime container expects its configuration file at /app/.dolittle/runtime.yml. ```yaml services: # MongoDB as a replica set mongo: image: mongo:7.0 command: ["--replSet", "rs0", "--bind_ip_all", "--port", "27017"] healthcheck: test: echo "try { rs.status() } catch (err) { rs.initiate({_id:'rs0',members:[{_id:0,host:'localhost:27017'}]}) }" | mongosh --port 27017 --quiet interval: 30s timeout: 30s start_period: 0s start_interval: 1s retries: 30 hostname: mongo ports: - 27017:27017 runtime: image: dolittle/runtime:9.4.0 volumes: # The runtime container expects the runtime.yml file to be located in the .dolittle folder, and the working directory is /app - ./runtime.yml:/app/.dolittle/runtime.yml ports: - 50052:50052 - 50053:50053 ``` -------------------------------- ### Build Production Docker Image Source: https://github.com/dolittle/runtime/blob/master/README.md Builds the production Docker image for the Dolittle Runtime from the project root. Tags the image as 'dolittle/runtime'. ```shell docker build -t dolittle/runtime -f ./Docker/Production/Dockerfile . ``` -------------------------------- ### Build ARM64 Development Docker Image Source: https://github.com/dolittle/runtime/blob/master/README.md Builds the ARM64 variant of the development Docker image for the Dolittle Runtime from the project root. Tags the image as 'dolittle/runtime:arm64-development'. ```shell docker build -t dolittle/runtime:arm64-development -f ./Docker/ARM64Development/Dockerfile . ``` -------------------------------- ### Build Development Docker Image Source: https://github.com/dolittle/runtime/blob/master/README.md Builds the development Docker image for the Dolittle Runtime from the project root. Tags the image as 'dolittle/runtime:development'. ```shell docker build -t dolittle/runtime:development -f ./Docker/Development/Dockerfile . ``` -------------------------------- ### Build ARM64 Production Docker Image Source: https://github.com/dolittle/runtime/blob/master/README.md Builds the ARM64 variant of the production Docker image for the Dolittle Runtime from the project root. Tags the image as 'dolittle/runtime:arm64'. ```shell docker build -t dolittle/runtime:arm64 -f ./Docker/ARM64Production/Dockerfile . ``` -------------------------------- ### Run Dolittle Runtime Source: https://github.com/dolittle/runtime/blob/master/README.md Runs the Dolittle Runtime application from the Source/Server directory. Configuration files are located in Source/Server/.dolittle/. ```shell cd Source/Server dotnet run ``` -------------------------------- ### Build Dolittle Runtime Source: https://github.com/dolittle/runtime/blob/master/README.md Builds the Dolittle Runtime project from the project root. This command compiles the C# code. ```shell dotnet build ``` -------------------------------- ### Replay events for a running Event Handler Source: https://github.com/dolittle/runtime/blob/master/Documentation/CLI/_index.md Initiate a replay of events for a specified running Event Handler. ```shell dolittle runtime eventhandlers replay ``` -------------------------------- ### Test Dolittle Runtime Source: https://github.com/dolittle/runtime/blob/master/README.md Executes the test suite for the Dolittle Runtime project from the project root. ```shell dotnet test ``` -------------------------------- ### List all running Aggregate Roots Source: https://github.com/dolittle/runtime/blob/master/Documentation/CLI/_index.md Use this command to view a list of all currently active Aggregate Roots within the Dolittle runtime. ```shell dolittle runtime aggregates list ``` -------------------------------- ### List all running Event Handlers Source: https://github.com/dolittle/runtime/blob/master/Documentation/CLI/_index.md This command lists all Event Handlers that are currently active in the Dolittle runtime. ```shell dolittle runtime eventhandlers list ``` -------------------------------- ### Verify Running Docker Containers Source: https://github.com/dolittle/runtime/blob/master/Source/Events.Store.MongoDB/Development/MongoDB/README.md Lists all currently running Docker containers. Use this to confirm that the MongoDB container is active and check its details. ```shell $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4a05adadc29a dolittle/mongodb:4.2.2 "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 0.0.0.0:27017->27017/tcp objective_mendeleev ``` -------------------------------- ### List Event Types CLI Command Source: https://github.com/dolittle/runtime/blob/master/Documentation/CLI/Runtime/EventTypes/list.md The base command to list all registered event types. Use options to control output format and details. ```shell dolittle runtime eventtypes list [options] ``` -------------------------------- ### List Aggregate Roots Command Source: https://github.com/dolittle/runtime/blob/master/Documentation/CLI/Runtime/Aggregates/list.md This is the base command to list all Aggregate Roots registered by clients to the Runtime. It can be used with various options to filter and format the output. ```shell dolittle runtime aggregates list [options] ``` -------------------------------- ### List Event Handlers CLI Command Source: https://github.com/dolittle/runtime/blob/master/Documentation/CLI/Runtime/EventHandlers/list.md The basic command to list all registered Event Handlers. Options can be appended to filter or format the output. ```shell dolittle runtime eventhandlers list [options] ``` -------------------------------- ### List all registered Event Types Source: https://github.com/dolittle/runtime/blob/master/Documentation/CLI/_index.md View a list of all event types that have been registered within the Dolittle system. ```shell dolittle runtime eventtypes list ``` -------------------------------- ### Dolittle Runtime CLI Base Command Source: https://github.com/dolittle/runtime/blob/master/Documentation/CLI/Runtime/_index.md The base command for interacting with the Dolittle Runtime. Subcommands are used to perform specific management tasks. ```shell dolittle runtime [subcommand] ``` -------------------------------- ### Dolittle Runtime Event Handlers CLI Command Source: https://github.com/dolittle/runtime/blob/master/Documentation/CLI/Runtime/EventHandlers/_index.md The base command for interacting with event handlers in the Dolittle Runtime. Use subcommands to perform specific actions. ```shell dolittle runtime eventhandlers [subcommand] ``` -------------------------------- ### Runtime Event Types CLI Command Source: https://github.com/dolittle/runtime/blob/master/Documentation/CLI/Runtime/EventTypes/_index.md The base command for interacting with event types in the Dolittle Runtime. Use subcommands to perform specific actions. ```shell dolittle runtime eventtypes [subcommand] ``` -------------------------------- ### Runtime Aggregates CLI Base Command Source: https://github.com/dolittle/runtime/blob/master/Documentation/CLI/Runtime/Aggregates/_index.md The base command for interacting with Dolittle Runtime Aggregates via the CLI. Use subcommands to perform specific actions. ```shell dolittle runtime aggregates [subcommand] ``` -------------------------------- ### Define Customer Aggregate Root Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/concurrency.md Defines the Customer aggregate root with methods to create and delete customers. It uses the aggregate root pattern with event sourcing. ```csharp [AggregateRoot("...")] public class Customer : AggregateRoot { readonly CustomerNumber _id; public Customer(EventSourceId id) : base(id) => _id = id; public Create() => Apply(new CustomerCreated(_id)); public Delete() => Apply(new CustomerDeleted(_id)); } ``` -------------------------------- ### Projection with Key Selector Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/projections.md Defines a projection that tracks dishes eaten by specific customers. It uses the Customer property of the DishEaten event as the key selector to identify individual read model instances. ```csharp [Projection("185107c2-f897-40c8-bb06-643b3642f231")] public class DishesEatenByCustomer: ReadModel { public string[] Dishes { get; set; } = {}; [KeyFromProperty(nameof(DishEaten.Customer))] // Use the Customer property of the DishEaten event as key / id public void On(DishEaten evt) // Projection context can be omitted if not needed { Dishes = Dishes.Append(evt.Dish).ToArray(); } } ``` -------------------------------- ### Subscription Structure Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/event_horizon.md A simplified structure of a Subscription object used by a consumer to receive events from a producer. It specifies the producer's microservice, tenant, public stream, and partition, along with the consumer's scoped event log. ```csharp Subscription { // the producers microservice, tenant, public stream and partition MicroserviceId Guid TenantId Guid PublicStreamId Guid PartitionId string // the consumers scoped event log ScopeId Guid } ``` -------------------------------- ### Replay All Events for an Event Handler Source: https://github.com/dolittle/runtime/blob/master/Documentation/CLI/Runtime/EventHandlers/replay.md Initiates reprocessing of all events from the beginning of the Event Handler stream for all tenants. Specify the Event Handler identifier. ```shell dolittle runtime eventhandlers replay all [options] ``` -------------------------------- ### Subscription State Structure Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/event_store.md Tracks the state of an Event Horizon Subscription, including its position and failure details. ```json { "Microservice": "UUID", "Tenant": "UUID", "Stream": "UUID", "Partition": "string", "Position": "decimal", "LastSuccesfullyProcessed": "date", "RetryTime": "date", "FailureReason": "string", "ProcessingAttempts": "int", "IsFailing": "bool } ``` -------------------------------- ### CLI Command for Aggregate Events Source: https://github.com/dolittle/runtime/blob/master/Documentation/CLI/Runtime/Aggregates/events.md Use this command to retrieve committed events for a specific Aggregate Root instance. Provide the Aggregate Root identifier and its Event Source. ```shell dolittle runtime aggregates events [options] ``` -------------------------------- ### Define Order Aggregate Root Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/concurrency.md Defines the Order aggregate root with methods to create orders, add order lines, and ship orders. It utilizes event sourcing for state management. ```csharp [AggregateRoot("...")] public class Order : AggregateRoot { readonly OrderNumber _id; public Order(EventSourceId id) : base(id) => _id = id; public Create(CustomerNumber c) => Apply(new OrderCreated(_id, c)); public Add(OrderLine line) => Apply(new OrderLineAdded(_id, line)) public Ship() => Apply(new OrderShipped(_id)); } ``` -------------------------------- ### Dolittle AggregateRoot Structure Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/aggregates.md A simplified representation of the main components of an AggregateRoot in Dolittle, including IDs, version, and aggregate events. ```csharp AggregateRoot { AggregateRootId Guid EventSourceId string Version int AggregateEvents AggregateEvent[] { EventSourceId string AggregateRootId Guid // normal Event properties also included ... } } ``` -------------------------------- ### Replay Events from a Specific Position Source: https://github.com/dolittle/runtime/blob/master/Documentation/CLI/Runtime/EventHandlers/replay.md Initiates reprocessing of events from a specified position in the Event Handler stream for a specific tenant. The position cannot be greater than the current position. ```shell dolittle runtime eventhandlers replay from [options] ``` -------------------------------- ### Event Structure in C# Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/events.md This snippet shows the main components of an event as represented in C#. The 'Content' field must be JSON serializable. ```csharp Event { Content object EventLogSequenceNumber int EventSourceId string Public bool EventType { EventTypeId Guid Generation int } } ``` -------------------------------- ### Stream Processor Calculation Formula Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/streams.md Formula for calculating the total number of stream processors created based on event handlers, filters, tenants, and event horizon subscriptions. ```text (((2 x event handlers) + filters) x tenants) + event horizon subscriptions = stream processors ``` -------------------------------- ### Sequential Event Handler Implementation Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/concurrency.md An event handler that processes events sequentially. This ensures that events related to the same aggregate are processed in the order they occurred. ```csharp [EventHandler("...")] public class HandleSequentially { public Task Handle(CustomerCreated e, EventContext ctx) { //.. } public Task Handle(CustomerDeleted e, EventContext ctx) { //.. } public Task Handle(OrderCreated e, EventContext ctx) { //.. } public Task Handle(OrderLineAdded e, EventContext ctx) { //.. } public Task Handle(OrderShipped e, EventContext ctx) { //.. } } ``` -------------------------------- ### Stream Event Structure Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/event_store.md Represents an event within a stream, including partition information. ```json { "Partition": "string" } ``` -------------------------------- ### CustomerOrders Aggregate with EventSourceId Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/concurrency.md Defines a CustomerOrders aggregate, using the customer's ID as the EventSourceId to guarantee in-order processing of order-related events. Requires the AggregateRoot attribute. ```csharp [AggregateRoot("...")] public class CustomerOrders : AggregateRoot { readonly CustomerNumber _customerNumber; readonly OrderNumber _orderNumber; public Order(EventSourceId customerNumber) : base(customerNumber) => _customerId = id; public Create(OrderId o) => Apply(new OrderCreated(_orderNumber, _customerNumber)); public Add(OrderLine line) => Apply(new OrderLineAdded(_orderNumber, line)) public Ship() => Apply(new OrderShipped(_orderNumber)); void On(OrderCreated e) => _orderNumber = e.OrderId; } ``` -------------------------------- ### Consolidated Customer Aggregate with Orders Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/concurrency.md Consolidates order information directly within the Customer aggregate to enforce in-order processing of order-related events. Includes nested Order class for managing order state. ```csharp [AggregateRoot("...")] public class Customer : AggregateRoot { readonly CustomerNumber _id; readonly List _orders = new List(); public Customer(EventSourceId id) : base(id) => _id = id; public Create() => Apply(new CustomerCreated(_id)); public Delete() => Apply(new CustomerDeleted(_id)); public CreateOrder(OrderNumber o) => Apply(new OrderCreated(_id)); public AddOrderLine(OrderNumber o, OrderLine line) => _orders.Any(o => o.Number == o) ? Apply(new OrderLineAdded(_id, line) : throw new InvalidOperationException("Order does not exist"); public ShipOrder(OrderNumber o) => _orders.Single(o => o.Number == o).Shipped == false ? Apply(new OrderShipped(_id)) : throw new InvalidOperationException("Order already shipped"); void On(OrderCreated e) => _orders.Add(new Order(e.OrderId)); void On(OrderLineAdded e) => _orders.Single(o => o.Id == e.OrderId).AddLine(e.Line); void On(OrderShipped e) => _orders.Single(o => o.Id == e.OrderId).Ship(); class Order { public OrderNumber Number { get; init; } public bool Shipped { get; private set; } = false readonly List _lines = new List(); public Order(OrderNumber number) => _number = number; public AddLine(OrderLine line) => _lines.Add(line); public Ship() => Shipped = true; } } ``` -------------------------------- ### StreamProcessor Structure Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/streams.md This C# structure outlines the internal components of a StreamProcessor, including its source stream, event processor, processing position, and failure/retry management details. Stream processors are internal to the Runtime and not directly accessible via the SDK. ```csharp StreamProcessor { SourceStream Guid EventProcessor Guid // the next event to be processed Position int // for keeping track of failures and retry attempts LastSuccesfullyProcessed DateTime RetryTime DateTime FailureReason string ProcessingAttempts int IsFailing bool } ``` -------------------------------- ### Access MongoDB Shell in Container Source: https://github.com/dolittle/runtime/blob/master/Source/Events.Store.MongoDB/Development/MongoDB/README.md Executes the MongoDB shell inside a running Docker container. This allows direct interaction with the MongoDB server instance. ```shell $ docker exec -it objective_mendeleev mongo MongoDB shell version v4.2.2 connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb Implicit session: session { "id" : UUID("89edffef-b042-4d93-87eb-eaa74bcb030c") } MongoDB server version: 4.2.2 ... rs0:PRIMARY> ``` -------------------------------- ### Stream Definition Structure Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/event_store.md Defines a filter for creating a stream, specifying event types and partitioning. ```json { "_id": "UUID", "Partitioned": "bool", "Public": "bool", "Filter": { "Type": "string", "Types": [ // EventTypeIds to filter into the stream ] } } ``` -------------------------------- ### Stream Processor Event Processor State Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/event_store.md Tracks the state of an event processor, including partitioned stream information and failing partitions. ```json { "Partitioned": true, "SourceStream": "UUID", "EventProcessor": "UUID", "Position": "decimal", "LastSuccessfullyProcessed": "date", "FailingPartitions": { // for each failing partition "": { // the position of the failing event in the stream "Position": "decimal", "RetryTime": "date", "Reason": "string", "ProcessingAttempts": "int", "LastFailed": "date" } } } ``` -------------------------------- ### Sequential Event Handler Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/concurrency.md This C# code defines an event handler that processes events sequentially. It is the default behavior when the 'concurrency' attribute is not specified. ```csharp [EventHandler("...")] public class HandleSequentially { public Task Handle(CustomerCreated e, EventContext ctx) { //.. } public Task Handle(CustomerDeleted e, EventContext ctx) { //.. } } ``` -------------------------------- ### Concurrent Event Handler by Event Source ID Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/concurrency.md An event handler configured for concurrent processing, with a concurrency level of 100. Events are processed concurrently per event source ID, meaning events for the same ID are ordered, but events for different IDs may interleave. ```csharp [EventHandler("..."), concurrency: 100)] public class HandleConcurrentlyByEventSourceId { public Task Handle(CustomerCreated e, EventContext ctx) { //.. } public Task Handle(CustomerDeleted e, EventContext ctx) { //.. } public Task Handle(OrderCreated e, EventContext ctx) { //.. } public Task Handle(OrderLineAdded e, EventContext ctx) { //.. } public Task Handle(OrderShipped e, EventContext ctx) { //.. } } ``` -------------------------------- ### Concurrent Event Handler Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/concurrency.md This C# code defines an event handler configured for concurrent processing with a concurrency limit of 100. Events are split by EventSourceId and processed up to the specified limit concurrently. ```csharp [EventHandler(eventHandlerId: "...", concurrency: 100)] public class HandleConcurrently { public Task Handle(CustomerCreated e, EventContext ctx) { // .. } public Task Handle(CustomerDeleted e, EventContext ctx) { //.. } } ``` -------------------------------- ### Stream Processor Filter State Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/event_store.md Tracks the state of a filter acting as a stream processor, including its position and failure information. ```json { "SourceStream": "UUID", "EventProcessor": "UUID", "Position": "decimal", "LastSuccesfullyProcessed": "date", "RetryTime": "date", "FailureReason": "string", "ProcessingAttempts": "int", "IsFailing": "bool } ``` -------------------------------- ### MongoDB Event Log Structure Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/event_store.md This JSON structure represents a committed event in the MongoDB event log. It includes metadata for aggregates and events coming from the Event Horizon. ```json { "_id": "decimal", "Content": "object", "Aggregate": { "wasAppliedByAggregate": "bool", "TypeId": "UUID", "TypeGeneration": "long", "Version": "decimal" }, "EventHorizon": { "FromEventHorizon": "bool", "ExternalEventLogSequenceNumber": "decimal", "Received": "date", "Concent": "UUID" }, "ExecutionContext": { "Correlation": "UUID", "Microservice": "UUID", "Tenant": "UUID", "Version": "object", "Environment": "string" }, "Metadata": { "Occurred": "date", "EventSource": "string", "TypeId": "UUID", "TypeGeneration": "long", "Public": "bool" } } ``` -------------------------------- ### MongoDB Aggregates Structure Source: https://github.com/dolittle/runtime/blob/master/Documentation/Concepts/event_store.md This JSON structure represents an aggregate instance stored in the MongoDB aggregates collection. It tracks the aggregate type and its current version. ```json { "EventSource": "string", "AggregateType": "UUID", "Version": "decimal" } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.