Skip to content

Commit

Permalink
Adjusted README and docker config
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardudycz committed Dec 9, 2024
1 parent 7c2420f commit 262b4f5
Show file tree
Hide file tree
Showing 24 changed files with 87 additions and 50 deletions.

Large diffs are not rendered by default.

This file was deleted.

37 changes: 25 additions & 12 deletions workshops/introduction_to_event_sourcing/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Twitter Follow](https://img.shields.io/twitter/follow/oskar_at_net?style=social)](https://twitter.com/oskar_at_net) [![Github Sponsors](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&link=https://github.com/sponsors/oskardudycz/)](https://github.com/sponsors/oskardudycz/) [![blog](https://img.shields.io/badge/blog-event--driven.io-brightgreen)](https://event-driven.io/?utm_source=event_sourcing_jvm) [![blog](https://img.shields.io/badge/%F0%9F%9A%80-Architecture%20Weekly-important)](https://www.architecture-weekly.com/?utm_source=event_sourcing_net)
[<img src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white" height="20px" />](https://www.linkedin.com/in/oskardudycz/) [![Github Sponsors](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&link=https://github.com/sponsors/oskardudycz/)](https://github.com/sponsors/oskardudycz/) [![blog](https://img.shields.io/badge/blog-event--driven.io-brightgreen)](https://event-driven.io/?utm_source=event_sourcing_jvm) [![blog](https://img.shields.io/badge/%F0%9F%9A%80-Architecture%20Weekly-important)](https://www.architecture-weekly.com/?utm_source=event_sourcing_net)

# Introduction to Event Sourcing Self-Paced Kit

Expand All @@ -10,7 +10,7 @@ The emphasis will be on a pragmatic understanding of architectures and applying

You can do the workshop as a self-paced kit. That should give you a good foundation for starting your journey with Event Sourcing and learning tools like EventStoreDB.

**If you'd like to get full coverage with all nuances of the private workshop, check [training page on my blog for more details](https://event-driven.io/en/training/) feel free to contact me via [email](mailto:oskar[email protected]).**
**If you'd like to get full coverage with all nuances of the private workshop, check [training page on my blog for more details](https://event-driven.io/en/training/) feel free to contact me via [email](mailto:oskar@event-driven.io).**

Read also more in my article [Introduction to Event Sourcing - Self Paced Kit](https://event-driven.io/en/introduction_to_event_sourcing/?utm_source=event_sourcing_nodejs).

Expand All @@ -21,18 +21,20 @@ Follow the instructions in exercises folders.
1. [Events definition](./src/01_events_definition/).
2. [Getting State from events](./src/02_getting_state_from_events/).
3. Appending Events:
- [EventStoreDB](./src/03_appending_events_eventstoredb/)
- [Raw EventStoreDB](./src/03_appending_events_eventstoredb/)
- [Emmett with various storages (PostgreSQL, EventStoreDB, MongoDB)](./src/04_appending_events_emmett/)
4. Getting State from events
- [EventStoreDB](./src/04_getting_state_from_events_eventstoredb/)
5. [Business logic](./src/05_business_logic/)
- [Raw EventStoreDB](./src/05_getting_state_from_events_eventstoredb/)
- [Emmett with various storages (PostgreSQL, EventStoreDB, MongoDB)](./src/06_getting_state_from_events_emmett/)
5. [Business logic](./src/07_business_logic/)
6. Application logic:
- [EventStoreDB](./src/06_application_logic_eventstoredb/)
- [EventStoreDB](./src/08_application_logic_eventstoredb/)
7. Optimistic Concurrency:
- [EventStoreDB](./src/07_optimistic_concurrency_eventstoredb/)
- [EventStoreDB](./src/09_optimistic_concurrency_eventstoredb/)
8. Projections:
- [General](./src/08_projections_single_stream/)
- [Idempotency](./src/09_projections_single_stream_idempotency/)
- [Eventual Consistency](./src/10_projections_single_stream_eventual_consistency/)
- [General](./src/10_projections_single_stream/)
- [Idempotency](./src/11_projections_single_stream_idempotency/)
- [Eventual Consistency](./src/12_projections_single_stream_eventual_consistency/)

## Prerequisites

Expand All @@ -51,12 +53,23 @@ Follow the instructions in exercises folders.

## Ensuring that all is setup correctly

1. Run: `docker compose up` to start EventStoreDB docker image.
1. Run: `docker compose up` to start PostgreSQL, EventStoreDB, MongoDB docker images.
2. Run `npm run test:solved`. If all is fine then all tests should be green.

## Running

1. Run: `docker compose up` to start EventStoreDB docker image.You should automatically get EventStoreDB UI: http://localhost:2113/
1. Tests by default are using TestContainers, but if you'd like to troubleshoot it manually, you can disable the TestContainers and use regular docker images by setting the `ES_USE_TEST_CONTAINERS` environment variable to false:

```bash
ES_USE_TEST_CONTAINERS=false
```

2. Then run: `docker compose up` to start EventStoreDB docker image.You should automatically get:

- EventStoreDB UI: http://localhost:2113/
- Mongo Express UI: http://localhost:8081/
- PgAdmin: http://localhost:5050/

2. You can get build watch by running `npm run build:ts:watch`.
3. To run test for exercises run `npm run test:exercise`. For solutions run `npm run test:solved`, for all `npm run test`.
4. Whe you're working with exercise and want to have tests running on file change run `npm run test:exercise:watch`.
3 changes: 2 additions & 1 deletion workshops/introduction_to_event_sourcing/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ services:
container_name: postgres
environment:
- POSTGRES_DB=postgres
- POSTGRES_PASSWORD=Password12!
- POSTGRES_PASSWORD=postgres
- POSTGRES_USER=postgres
ports:
- 5432:5432
networks:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
# Exercise 03 - Appending events to EventStoreDB
# Exercise 04 - Appending events to Emmett

Using a defined structure of events from the [first exercise](../01_events_definition/), fill a `appendToStream` function to store events in [EventStoreDB](https://developers.eventstore.com/clients/grpc/).
Using a defined structure of events from the [first exercise](../01_events_definition/), fill a `appendToStream` function to store events in selected Emmet's event storage:

## Prerequisites
- [EventStoreDB](./eventstoredb/),
- [PostgreSQL](./postgresql/),
- [MongoDB](./mongodb)

Run [docker compose](../docker-compose.yml) script from the main workshop repository to start EventStoreDB instance.
## Prerequisities

```shell
docker compose up
1. Tests by default are using TestContainers, but if you'd like to troubleshoot it manually, you can disable the TestContainers and use regular docker images by setting the `ES_USE_TEST_CONTAINERS` environment variable to false:

```bash
ES_USE_TEST_CONTAINERS=false
```

After that you can use EventStoreDB UI to see how streams and events look like. It's available at: http://localhost:2113/.
2. Then run: `docker compose up` to start EventStoreDB docker image.You should automatically get:

- EventStoreDB UI: http://localhost:2113/
- Mongo Express UI: http://localhost:8081/
- PgAdmin: http://localhost:5050/

2. You can get build watch by running `npm run build:ts:watch`.
3. To run test for exercises run `npm run test:exercise`. For solutions run `npm run test:solved`, for all `npm run test`.
4. Whe you're working with exercise and want to have tests running on file change run `npm run test:exercise:watch`.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Exercise 04 - Getting the current entity state from events using EventStoreDB
# Exercise 05 - Getting the current entity state from events using EventStoreDB

Having a defined structure of events and an entity representing the shopping cart from the [first exercise](../01_events_definition/), fill a `GetShoppingCart` function that will rebuild the current state from events.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Exercise 04 - Getting the current entity state from events using EventStoreDB
# Exercise 06 - Getting the current entity state from events using Emmett

Having a defined structure of events and an entity representing the shopping cart from the [first exercise](../01_events_definition/), fill a `GetShoppingCart` function that will rebuild the current state from events.

If needed you can modify the events or entity structure.

There are two variations:

- using mutable entities: [oop/gettingStateFromEvents.exercise.test.ts](./oop/gettingStateFromEvents.exercise.test.ts),
- using fully immutable structures: [immutable/gettingStateFromEvents.exercise.test.ts](./immutable/gettingStateFromEvents.exercise.test.ts).
- using mutable entities: [./mongodb/oop/gettingStateFromEvents.exercise.test.ts](./oop/gettingStateFromEvents.exercise.test.ts),
- using fully immutable structures: [./mongodb/immutable/gettingStateFromEvents.exercise.test.ts](./immutable/gettingStateFromEvents.exercise.test.ts).

Select your preferred approach (or both) to solve this use case. If needed you can modify entities or events.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Exercise 05 - Business Logic
# Exercise 07 - Business Logic

Having the following shopping cart process:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Exercise 06 - Application Logic
# Exercise 08 - Application Logic

Having the following shopping cart process:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Exercise 07 - Application Logic with Optimistic Concurrency
# Exercise 09 - Application Logic with Optimistic Concurrency

Having the following shopping cart process:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Exercise 08 - Projections
# Exercise 10 - Projections

With the [Database](./tools/database.ts) interface representing the sample database, implement the following projections:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Exercise 09 - Projections Idempotency
# Exercise 11 - Projections Idempotency

With the [Database](./tools/database.ts) interface representing the sample database, implement the following projections:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const getEventStoreDBTestClient = async (
): Promise<EventStoreDBClient> => {
let connectionString;

if (useTestContainers) {
if (process.env.ES_USE_TEST_CONTAINERS !== 'false' && useTestContainers) {
++instanceCounter;
if (!esdbContainer)
esdbContainer = await new EventStoreDBContainer().start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ export const getMongoDBTestClient = async (
): Promise<MongoClient> => {
let connectionString;

if (useTestContainers) {
if (process.env.ES_USE_TEST_CONTAINERS !== 'false' && useTestContainers) {
++instanceCounter;
if (!mongoDBContainer)
mongoDBContainer = await new MongoDBContainer().start();

connectionString = mongoDBContainer.getConnectionString();
} else {
connectionString = 'mongodb://mongodb:27017/';
connectionString = 'mongodb://localhost:27017/';
}

return new MongoClient(connectionString, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const getPostgreSQLConnectionString = async (
): Promise<string> => {
let connectionString;

if (useTestContainers) {
if (process.env.ES_USE_TEST_CONTAINERS !== 'false' && useTestContainers) {
++instanceCounter;
if (!postgreSQLContainer)
postgreSQLContainer = await new PostgreSqlContainer().start();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
# Exercise 03 - Appending events to EventStoreDB
# Exercise 04 - Appending events to Emmett

Using a defined structure of events from the [first exercise](../01_events_definition/), fill a `appendToStream` function to store events in [EventStoreDB](https://developers.eventstore.com/clients/grpc/).
Using a defined structure of events from the [first exercise](../01_events_definition/), fill a `appendToStream` function to store events in selected Emmet's event storage:

## Prerequisites
- [EventStoreDB](./eventstoredb/),
- [PostgreSQL](./postgresql/),
- [MongoDB](./mongodb)

Run [docker compose](../docker-compose.yml) script from the main workshop repository to start EventStoreDB instance.
## Prerequisities

```shell
docker compose up
1. Tests by default are using TestContainers, but if you'd like to troubleshoot it manually, you can disable the TestContainers and use regular docker images by setting the `ES_USE_TEST_CONTAINERS` environment variable to false:

```bash
ES_USE_TEST_CONTAINERS=false
```

After that you can use EventStoreDB UI to see how streams and events look like. It's available at: http://localhost:2113/.
2. Then run: `docker compose up` to start EventStoreDB docker image.You should automatically get:

- EventStoreDB UI: http://localhost:2113/
- Mongo Express UI: http://localhost:8081/
- PgAdmin: http://localhost:5050/

2. You can get build watch by running `npm run build:ts:watch`.
3. To run test for exercises run `npm run test:exercise`. For solutions run `npm run test:solved`, for all `npm run test`.
4. Whe you're working with exercise and want to have tests running on file change run `npm run test:exercise:watch`.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Exercise 04 - Getting the current entity state from events using EventStoreDB
# Exercise 05 - Getting the current entity state from events using EventStoreDB

Having a defined structure of events and an entity representing the shopping cart from the [first exercise](../01_events_definition/), fill a `GetShoppingCart` function that will rebuild the current state from events.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Exercise 04 - Getting the current entity state from events using EventStoreDB
# Exercise 06 - Getting the current entity state from events using Emmett

Having a defined structure of events and an entity representing the shopping cart from the [first exercise](../01_events_definition/), fill a `GetShoppingCart` function that will rebuild the current state from events.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Exercise 05 - Business Logic
# Exercise 07 - Business Logic

Having the following shopping cart process:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Exercise 06 - Application Logic
# Exercise 08 - Application Logic

Having the following shopping cart process:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Exercise 07 - Application Logic with Optimistic Concurrency
# Exercise 09 - Application Logic with Optimistic Concurrency

Having the following shopping cart process:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Exercise 08 - Projections
# Exercise 10 - Projections

With the [Database](./tools/database.ts) interface representing the sample database, implement the following projections:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Exercise 09 - Projections Idempotency
# Exercise 11 - Projections Idempotency

With the [Database](./tools/database.ts) interface representing the sample database, implement the following projections:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Exercise 09 - Projections Idempotency
# Exercise 12 - Projections Idempotency

With the [Database](./tools/database.ts) interface representing the sample database, implement the following projections:

Expand Down

0 comments on commit 262b4f5

Please sign in to comment.