Skip to content

Commit

Permalink
Use Material admonitions across docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Wojciech Klusek committed Dec 4, 2023
1 parent 1c1c974 commit 22aeb6c
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 20 deletions.
3 changes: 2 additions & 1 deletion docs/cqrs/authorization/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ All [queries], [commands] and [operations] can (and should!) be behind authoriza
}
```

> **Tip:** You can implement your own authorization and use it with LeanCode CoreLibrary authorizers. To see how you can implement authorization using Ory Kratos and LeanCode CoreLibrary see [here](../../external_integrations/authorization_ory_kratos/index.md).
!!! tip
You can implement your own authorization and use it with LeanCode CoreLibrary authorizers. To see how you can implement authorization using Ory Kratos and LeanCode CoreLibrary see [here](../../external_integrations/authorization_ory_kratos/index.md).

[query]: ../query/index.md
[command]: ../command/index.md
Expand Down
6 changes: 4 additions & 2 deletions docs/cqrs/command/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public class UpdateProjectName : ICommand, IProjectRelated
}
```

> **Tip:** More on authorization and permissions can be found [here](../authorization/index.md) and on error codes and validation [here](../validation/index.md).
!!! tip
More on authorization and permissions can be found [here](../authorization/index.md) and on error codes and validation [here](../validation/index.md).

## Naming conventions

Expand Down Expand Up @@ -78,7 +79,8 @@ public class UpdateProjectNameCH : ICommandHandler<UpdateProjectName>
}
```

> **Tip:** More on ids can be found [here](../../domain/id/index.md) and on validation [here](../validation/index.md).
!!! tip
More on ids can be found [here](../../domain/id/index.md) and on validation [here](../validation/index.md).

As you can see, the command handler is really simple - it just finds project with specified `ProjectId` and updates it's name. That does not mean this is the only responsibility of the handlers (it's just an example), but there are some guidelines related to them:

Expand Down
3 changes: 2 additions & 1 deletion docs/cqrs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ The strict separation of [command] and [query] has sometimes led to awkwardness
- **Validation on the write side:** With CQRS, the write side typically handles commands that change the state of the system. This is where validation of incoming data and business rules can be enforced. By centralizing validation logic on the write side, you ensure that all changes to the system go through a consistent validation process.
- **Flexibility in storage and models:** CQRS allows to use different data storage mechanisms for the read and write sides. For example, you might use a relational database for the write side and a NoSQL database for the read side. This flexibility enables you to choose the right tool for each job.

> **Tip:** You can find more about how CQRS allows us generate API contracts for clients [ContractsGenerator documentation](https://github.com/leancodepl/contractsgenerator/blob/main/docs/index.md).
!!! tip
You can find more about how CQRS allows us generate API contracts for clients [ContractsGenerator documentation](https://github.com/leancodepl/contractsgenerator/blob/main/docs/index.md).

[query]: ./query/index.md
[command]: ./command/index.md
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Avoid committing transactions in handlers

> **Tip:** Before delving into this section, it's highly recommended to explore the [CQRS], [Domain] and [MassTransit] sections.
!!! tip
Before delving into this section, it's highly recommended to explore the [CQRS], [Domain] and [MassTransit] sections.

**⚠️ Directly commiting transactions in [command]/[operation] handlers poses a challenge, potentially causing inconsistencies between [events] and the associated entities.**
!!! warning
Directly commiting transactions in [command]/[operation] handlers poses a challenge, potentially causing inconsistencies between [events] and the associated entities.

Let's consider following pipeline configuration:

Expand Down Expand Up @@ -124,7 +126,8 @@ In our scenario, if the database fails after successfully saving changes to the

Conversely, removing `SaveChangesAsync` from the [command] handler would result in both messages and project changes being committed in a single transaction. In the event of a database failure, neither project changes nor messages would be saved or sent, providing clients with information about the request failure without unintended side effects. This is why it's not recommended to not commit transactions directly in [command]/[operation] handlers.

> **Tip:** To read more about LeanCode Corelibrary MassTransit integtation visit [here](../../external_integrations/messaging_masstransit/index.md).
!!! tip
To read more about LeanCode Corelibrary MassTransit integtation visit [here](../../external_integrations/messaging_masstransit/index.md).

[CQRS]: ../index.md
[Domain]: ../../domain/index.md
Expand Down
3 changes: 2 additions & 1 deletion docs/cqrs/validation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public class UpdateProjectNameCV : AbstractValidator<UpdateProjectName>
}
```

> **Tip:** More on ids can be found [here](../../domain/id/index.md).
!!! tip
More on ids can be found [here](../../domain/id/index.md).

[commands]: ../command/index.md
[command]: ../command/index.md
Expand Down
3 changes: 2 additions & 1 deletion docs/domain/aggregate/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public class Project : IAggregateRoot<ProjectId>
}
```

> **Tip:** To see `Assignment` class implementation visit [here](../identifiable/index.md).
!!! tip
To see `Assignment` class implementation visit [here](../identifiable/index.md).

Notice that these added methods can and will throw an exception if a project does not contain any assignment with provided Id. This is an excepted behavior - checks for respecting domain logic should be performed in respective command (or operations) validators.
3 changes: 2 additions & 1 deletion docs/domain/domain_event/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,5 @@ Ensure that `EmployeeAssignedToAssignment` implements the `IDomainEvent` interfa

After being raised, the event can be handled by the matching `IConsumer` to perform wanted action.

> **Tip:** To read how to handle domain events, visit [here](../../external_integrations/messaging_masstransit/handling_events.md).
!!! tip
To read how to handle domain events, visit [here](../../external_integrations/messaging_masstransit/handling_events.md).
3 changes: 2 additions & 1 deletion docs/domain/time_provider/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ public class Project : IAggregateRoot<ProjectId>
}
```

> **Tip:** Employing a single instance of `LeanCode.TimeProvider.Time` throughout the domain enables convenient manipulation of time for testing purposes. Further information about this can be found [here](../../tests/faking_time/index.md).
!!! tip
Employing a single instance of `LeanCode.TimeProvider.Time` throughout the domain enables convenient manipulation of time for testing purposes. Further information about this can be found [here](../../tests/faking_time/index.md).
3 changes: 2 additions & 1 deletion docs/external_integrations/authorization_ory_kratos/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ LeanCode CoreLibrary provides 3 main components to integrate with Kratos:

Ory Kratos can be either hosted on [Ory Network](https://www.ory.sh/network/) or be self-hosted.

> **Tip:** To see quickstart about how you can run self-hosted Kratos instance visit [here](https://www.ory.sh/docs/kratos/quickstart).
!!! tip
To see quickstart about how you can run self-hosted Kratos instance visit [here](https://www.ory.sh/docs/kratos/quickstart).

## Configuration

Expand Down
3 changes: 2 additions & 1 deletion docs/external_integrations/logging_serilog/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public class Program
}
```

> **Tip:** If you rely on `appsettings.json` for your configuration or intend to use different configurations within your `Program.cs`, you can simply invoke `ConfigureDefaultLogging` on your `IHostBuilder`.
!!! tip
If you rely on `appsettings.json` for your configuration or intend to use different configurations within your `Program.cs`, you can simply invoke `ConfigureDefaultLogging` on your `IHostBuilder`.

Once configured, leverage Serilog for logging purposes in your application:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ public class SendEmailToEmployeeOnEmployeeAssignedToAssignment
}
```

> **Tip:** More about consumers can be found here: [MassTransit Consumers](https://masstransit.io/documentation/concepts/consumers). To read how you can send this email using LeanCode CoreLibrary SendGrid integration visit [here](../../external_integrations/emails_sendgrid/index.md).
!!! tip
More about consumers can be found here: [MassTransit Consumers](https://masstransit.io/documentation/concepts/consumers). To read how you can send this email using LeanCode CoreLibrary SendGrid integration visit [here](../../external_integrations/emails_sendgrid/index.md).
3 changes: 2 additions & 1 deletion docs/external_integrations/messaging_masstransit/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ To integrate [MassTransit] with LeanCode CoreLibrary CQRS, you can utilize the [
1. `CommitDatabaseTransactionMiddleware` (call [CommitTransaction])
2. `EventsPublisherMiddleware` (call [PublishEvents])

> **Tip:** To find you more how you can configure pipeline visit [here](../../cqrs/pipeline/index.md).
!!! tip
To find you more how you can configure pipeline visit [here](../../cqrs/pipeline/index.md).

For setting up bus configuration, [AddMassTransitIntegration] must be used. This method registers all the essential services required for [MassTransit] to work seamlessly with the rest of CoreLibrary. It effectively invokes [AddMassTransit], allowing you to consult the [MassTransit documentation](https://masstransit.io/documentation/concepts) for further insights.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,5 @@ To enable CQRS traces in your application, it's necessary to use the `CQRSTrace(
}
```

> **Tip:** To learn more about configuring the pipeline, visit [here](../../cqrs/pipeline/index.md).
!!! tip
To learn more about configuring the pipeline, visit [here](../../cqrs/pipeline/index.md).
3 changes: 2 additions & 1 deletion docs/external_integrations/push_notifications_fcm/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public override void ConfigureServices(IServiceCollection services)
}
```

> **Tip:** Further details about localization can be found [here](../../features/localization/index.md).
!!! tip
Further details about localization can be found [here](../../features/localization/index.md).

Following the above configuration, it is necessary to incorporate a `DbSet` for the push notification token store. This can be accomplished through `CoreDbContext`, utilizing `Microsoft.EntityFrameworkCore`.

Expand Down
9 changes: 6 additions & 3 deletions docs/features/audit_logs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ protected override void ConfigureApp(IApplicationBuilder app)

`UseAuthentication` and `UseIdentityTraceAttributes` method calls are optional and used to enrich audit logs with `ActorId`.

⚠️ Bear in mind, that the order here makes difference. If you don't want to collect changes in the MT inbox/outbox tables, then you should configure `Audit<TDbContext>()` middleware **after** the `PublishEvents()` middleware.
!!! warning
Bear in mind, that the order here makes difference. If you don't want to collect changes in the MT inbox/outbox tables, then you should configure `Audit<TDbContext>()` middleware **after** the `PublishEvents()` middleware.

### 4. Consumers

Expand All @@ -137,7 +138,8 @@ protected override void ConfigureConsumer(
}
```

⚠️ Bear in mind, that the order here makes difference. If you don't want to collect changes in the MT inbox/outbox tables, then you should configure `UseAuditLogs<TDbContext>(context)` filter **after** the `UseDomainEventsPublishing(context)` filter.
!!! warning
Bear in mind, that the order here makes difference. If you don't want to collect changes in the MT inbox/outbox tables, then you should configure `UseAuditLogs<TDbContext>(context)` filter **after** the `UseDomainEventsPublishing(context)` filter.

## Other options

Expand All @@ -147,7 +149,8 @@ If you want to use some other store for your data feel free to implement `IAudit

When configuring cloud resources in cloud you should remember about the right to be forgotten and costs of storing the data based on the access tiers. Below you can find a terraform snippet that configures automatic tier changes and deletion based on the last blob modification time.

⚠️ Bear in mind that the values provided below may not be valid for your use case.
!!! warning
Bear in mind that the values provided below may not be valid for your use case.

```terraform
resource "azurerm_storage_management_policy" "decrease_access_tier" {
Expand Down

0 comments on commit 22aeb6c

Please sign in to comment.