Skip to content

Commit 9c75be3

Browse files
committed
style: fix formatting
1 parent b714af1 commit 9c75be3

File tree

10 files changed

+98
-57
lines changed

10 files changed

+98
-57
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ A clear and concise description of what you expected to happen.
2020
If applicable, add screenshots to help explain your problem.
2121

2222
**Library Version:**
23-
- Go-Akt version: [e.g. 2.1.0]
24-
- Go version: [e.g. 1.22]
23+
24+
- Go-Akt version: [e.g. 2.1.0]
25+
- Go version: [e.g. 1.22]
2526

2627
**Additional context**
2728
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/performance_report.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ A clear and concise description of what you expected to happen.
2020
If applicable, add screenshots to help explain your problem.
2121

2222
**Library Version:**
23-
- Go-Akt version: [e.g. 2.5.0]
24-
- Go version: [e.g. 1.22]
23+
24+
- Go-Akt version: [e.g. 2.5.0]
25+
- Go version: [e.g. 1.22]
2526

2627
**Additional context**
2728
Add any other context about the problem here.

CODE_OF_CONDUCT.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
106106
### 4. Permanent Ban
107107

108108
**Community Impact**: Demonstrating a pattern of violation of community
109-
standards, including sustained inappropriate behavior, harassment of an
109+
standards, including sustained inappropriate behavior, harassment of an
110110
individual, or aggression toward or disparagement of classes of individuals.
111111

112112
**Consequence**: A permanent ban from any sort of public interaction within

contributing.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Contributions are welcome
22

3-
The project adheres to [Semantic Versioning](https://semver.org) and [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
3+
The project adheres to [Semantic Versioning](https://semver.org)
4+
and [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
45
This repo uses [Earthly](https://earthly.dev/get-earthly).
56

67
There are two ways you can become a contributor:

plugins/statestore/postgres/postgres.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ func NewStateStore(config *Config) *DurableStore {
6969
// create the underlying db connection
7070
db := postgres.New(postgres.NewConfig(config.DBHost, config.DBPort, config.DBUser, config.DBPassword, config.DBName))
7171
return &DurableStore{
72-
db: db,
73-
sb: sq.StatementBuilder.PlaceholderFormat(sq.Dollar),
74-
connected: atomic.NewBool(false),
72+
db: db,
73+
sb: sq.StatementBuilder.PlaceholderFormat(sq.Dollar),
74+
connected: atomic.NewBool(false),
7575
}
7676
}
7777

readme.md

+81-43
Original file line numberDiff line numberDiff line change
@@ -6,96 +6,130 @@
66
![GitHub Release](https://img.shields.io/github/v/release/Tochemey/ego)
77
[![codecov](https://codecov.io/gh/Tochemey/ego/branch/main/graph/badge.svg?token=Z5b9gM6Mnt)](https://codecov.io/gh/Tochemey/ego)
88

9-
eGo is a minimal library that help build event-sourcing and CQRS application through a simple interface, and it allows developers to describe their **_commands_**, **_events_** and **_states_** **_are defined using google protocol buffers_**.
10-
Under the hood, ego leverages [Go-Akt](https://github.com/Tochemey/goakt) to scale out and guarantee performant, reliable persistence.
9+
eGo is a minimal library that help build event-sourcing and CQRS application through a simple interface, and it allows
10+
developers to describe their **_commands_**, **_events_** and **_states_** **_are defined using google protocol buffers_
11+
**.
12+
Under the hood, ego leverages [Go-Akt](https://github.com/Tochemey/goakt) to scale out and guarantee performant,
13+
reliable persistence.
1114

1215
## Table of Content
1316

1417
- [Features](#features)
15-
- [Event Sourced Behavior](#event-sourced-behavior)
16-
- [Howto](#howto)
17-
- [Events Stream](#events-stream)
18-
- [Projection](#projection)
19-
- [Events Store](#events-store)
20-
- [Offset Store](#offsets-store)
21-
- [Durable State Behavior](#durable-state-behavior)
22-
- [State Store](#state-store)
23-
- [Howto](#howto-1)
24-
- [State Stream](#events-stream-1)
18+
- [Event Sourced Behavior](#event-sourced-behavior)
19+
- [Howto](#howto)
20+
- [Events Stream](#events-stream)
21+
- [Projection](#projection)
22+
- [Events Store](#events-store)
23+
- [Offset Store](#offsets-store)
24+
- [Durable State Behavior](#durable-state-behavior)
25+
- [State Store](#state-store)
26+
- [Howto](#howto-1)
27+
- [State Stream](#events-stream-1)
2528

2629
## Features
2730

2831
### Event Sourced Behavior
2932

30-
The [`EventSourcedBehavior`](./behavior.go) is crucial for maintaining data consistency, especially in distributed systems. It defines how to handle the various commands (requests to perform actions) that are always directed at the event sourced entity.
31-
In eGo commands sent to the [`EventSourcedBehavior`](./behavior.go) are processed in order. When a command is processed, it may result in the generation of events, which are then stored in an event store. Every event persisted has a revision number
32-
and timestamp that can help track it. The [`EventSourcedBehavior`](./behavior.go) in eGo is responsible for defining how to handle events that are the result of command handlers.
33-
The end result of events handling is to build the new state of the event sourced entity. When running in cluster mode, aggregate root are sharded.
33+
The [`EventSourcedBehavior`](./behavior.go) is crucial for maintaining data consistency, especially in distributed
34+
systems. It defines how to handle the various commands (requests to perform actions) that are always directed at the
35+
event sourced entity.
36+
In eGo commands sent to the [`EventSourcedBehavior`](./behavior.go) are processed in order. When a command is processed,
37+
it may result in the generation of events, which are then stored in an event store. Every event persisted has a revision
38+
number
39+
and timestamp that can help track it. The [`EventSourcedBehavior`](./behavior.go) in eGo is responsible for defining how
40+
to handle events that are the result of command handlers.
41+
The end result of events handling is to build the new state of the event sourced entity. When running in cluster mode,
42+
aggregate root are sharded.
3443

3544
- `Commands handler`: The command handlers define how to handle each incoming command,
36-
which validations must be applied, and finally, which events will be persisted if any. When there is no event to be persisted a nil can
45+
which validations must be applied, and finally, which events will be persisted if any. When there is no event to be
46+
persisted a nil can
3747
be returned as a no-op. Command handlers are the meat of the event sourced actor.
38-
They encode the business rules of your event sourced actor and act as a guardian of the event sourced entity consistency.
48+
They encode the business rules of your event sourced actor and act as a guardian of the event sourced entity
49+
consistency.
3950
The command handler must first validate that the incoming command can be applied to the current model state.
4051
Any decision should be solely based on the data passed in the commands and the state of the Behavior.
41-
In case of successful validation, one or more events expressing the mutations are persisted. Once the events are persisted, they are applied to the state producing a new valid state.
42-
- `Events handler`: The event handlers are used to mutate the state of the event sourced entity by applying the events to it.
43-
Event handlers must be pure functions as they will be used when instantiating the event sourced entity and replaying the event store.
52+
In case of successful validation, one or more events expressing the mutations are persisted. Once the events are
53+
persisted, they are applied to the state producing a new valid state.
54+
- `Events handler`: The event handlers are used to mutate the state of the event sourced entity by applying the events
55+
to it.
56+
Event handlers must be pure functions as they will be used when instantiating the event sourced entity and replaying
57+
the event store.
4458

4559
#### Howto
4660

4761
To define an event sourced entity, one needs to:
62+
4863
1. define the state of the event sourced entity using google protocol buffers message
4964
2. define the various commands that will be handled by the event sourced entity
50-
3. define the various events that are result of the command handlers and that will be handled by the event sourced entity to return the new state of the event sourced entity
65+
3. define the various events that are result of the command handlers and that will be handled by the event sourced
66+
entity to return the new state of the event sourced entity
5167
4. implement the [`EventSourcedBehavior`](./behavior.go) interface.
5268
5. call the `Entity` method of eGo [engine](./engine.go)
5369

5470
#### Events Stream
5571

56-
Every event handled by event sourced entity are pushed to an events stream. That enables real-time processing of events without having to interact with the events store.
57-
Just use `Subscribe` method of [Engine](./engine.go) and start iterating through the messages and cast every message to the [Event](./protos/ego/v3/ego.proto).
72+
Every event handled by event sourced entity are pushed to an events stream. That enables real-time processing of events
73+
without having to interact with the events store.
74+
Just use `Subscribe` method of [Engine](./engine.go) and start iterating through the messages and cast every message to
75+
the [Event](./protos/ego/v3/ego.proto).
5876

5977
#### Projection
6078

61-
One can add a projection to the eGo engine to help build a read model. Projections in eGo rely on an offset store to track how far they have consumed events
79+
One can add a projection to the eGo engine to help build a read model. Projections in eGo rely on an offset store to
80+
track how far they have consumed events
6281
persisted by the write model. The offset used in eGo is a timestamp-based offset. One can also:
82+
6383
- remove a given projection: this will stop the projection and remove it from the system
6484
- check the status of a given projection
6585

6686
#### Events Store
6787

68-
One can implement a custom events store. See [EventsStore](persistence/events_store.go). eGo comes packaged with two events store:
88+
One can implement a custom events store. See [EventsStore](persistence/events_store.go). eGo comes packaged with two
89+
events store:
90+
6991
- [Postgres](plugins/eventstore/postgres/postgres.go): Schema can be found [here](./resources/eventstore_postgres.sql)
7092
- [Memory](plugins/eventstore/memory/memory.go) (for testing purpose only)
7193

7294
#### Offsets Store
7395

74-
One can implement a custom offsets store. See [OffsetStore](./offsetstore/iface.go). eGo comes packaged with two offset store:
96+
One can implement a custom offsets store. See [OffsetStore](./offsetstore/iface.go). eGo comes packaged with two offset
97+
store:
98+
7599
- [Postgres](./offsetstore/postgres/postgres.go): Schema can be found [here](./resources/offsetstore_postgres.sql)
76100
- [Memory](./offsetstore/memory/memory.go) (for testing purpose only)
77101

78102
### Durable State Behavior
79103

80-
The [`DurableStateBehavior`](./behavior.go) represents a type of Actor that persists its full state after processing each command instead of using event sourcing.
81-
This type of Actor keeps its current state in memory during command handling and based upon the command response persists its full state into a durable store. The store can be a SQL or NoSQL database.
82-
The whole concept is given the current state of the actor and a command produce a new state with a higher version as shown in this diagram: (State, Command) => State
83-
[`DurableStateBehavior`](./behavior.go) reacts to commands which result in a new version of the actor state. Only the latest version of the actor state is persisted to the durable store.
104+
The [`DurableStateBehavior`](./behavior.go) represents a type of Actor that persists its full state after processing
105+
each command instead of using event sourcing.
106+
This type of Actor keeps its current state in memory during command handling and based upon the command response
107+
persists its full state into a durable store. The store can be a SQL or NoSQL database.
108+
The whole concept is given the current state of the actor and a command produce a new state with a higher version as
109+
shown in this diagram: (State, Command) => State
110+
[`DurableStateBehavior`](./behavior.go) reacts to commands which result in a new version of the actor state. Only the
111+
latest version of the actor state is persisted to the durable store.
84112
There is no concept of history regarding the actor state since this is not an event sourced actor.
85-
However, one can rely on the _version number_ of the actor state and exactly know how the actor state has evolved overtime.
86-
[`DurableStateBehavior`](./behavior.go) version number are numerically incremented by the command handler which means it is imperative that the newer version of the state is greater than the current version by one.
113+
However, one can rely on the _version number_ of the actor state and exactly know how the actor state has evolved
114+
overtime.
115+
[`DurableStateBehavior`](./behavior.go) version number are numerically incremented by the command handler which means it
116+
is imperative that the newer version of the state is greater than the current version by one.
87117
[`DurableStateBehavior`](./behavior.go) will attempt to recover its state whenever available from the durable state.
88-
During a normal shutdown process, it will persist its current state to the durable store prior to shutting down. This behavior help maintain some consistency across the actor state evolution.
118+
During a normal shutdown process, it will persist its current state to the durable store prior to shutting down. This
119+
behavior help maintain some consistency across the actor state evolution.
89120

90121
#### State Store
91122

92-
One can implement a custom state store. See [StateStore](persistence/state_store.go). eGo comes packaged with two state stores:
123+
One can implement a custom state store. See [StateStore](persistence/state_store.go). eGo comes packaged with two state
124+
stores:
125+
93126
- [Postgres](plugins/statestore/postgres/postgres.go): Schema can be found [here](./resources/durablestore_postgres.sql)
94127
- [Memory](plugins/statestore/memory/memory.go) (for testing purpose only)
95128

96129
#### Howto
97130

98131
To define a durable state entity, one needs to:
132+
99133
1. define the state of the entity using google protocol buffers message
100134
2. define the various commands that will be handled by the entity
101135
3. implements the [`DurableStateBehavior`](./behavior.go) interface
@@ -104,9 +138,10 @@ To define a durable state entity, one needs to:
104138

105139
#### Events Stream
106140

107-
[`DurableStateBehavior`](./behavior.go) full state is pushed to an events stream.
141+
[`DurableStateBehavior`](./behavior.go) full state is pushed to an events stream.
108142
That enables real-time processing of state without having to interact with the state store.
109-
Just use `Subscribe` method of [Engine](./engine.go) and start iterating through the messages and cast every message to the [DurableState](./protos/ego/v3/ego.proto).
143+
Just use `Subscribe` method of [Engine](./engine.go) and start iterating through the messages and cast every message to
144+
the [DurableState](./protos/ego/v3/ego.proto).
110145

111146
### Cluster
112147

@@ -279,25 +314,28 @@ The version system adopted in eGo deviates a bit from the standard semantic vers
279314
The version format is as follows:
280315

281316
- The `MAJOR` part of the version will stay at `v3` for the meantime.
282-
- The `MINOR` part of the version will cater for any new _features_, _breaking changes_ with a note on the breaking changes.
317+
- The `MINOR` part of the version will cater for any new _features_, _breaking changes_ with a note on the breaking
318+
changes.
283319
- The `PATCH` part of the version will cater for dependencies upgrades, bug fixes, security patches and co.
284320

285321
The versioning will remain like `v3.x.x` until further notice.
286322

287323
### Contribution
288324

289325
Contributions are welcome!
290-
The project adheres to [Semantic Versioning](https://semver.org) and [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
326+
The project adheres to [Semantic Versioning](https://semver.org)
327+
and [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
291328
This repo uses [Earthly](https://earthly.dev/get-earthly).
292329

293330
There are two ways you can become a contributor:
294331

295332
1. Request to become a collaborator, and then you can just open pull requests against the repository without forking it.
296333
2. Follow these steps
297-
- Fork the repository
298-
- Create a feature branch
299-
- Set your docker credentials on your fork using the following secret names: `DOCKER_USER` and `DOCKER_PASS`
300-
- Submit a [pull request](https://help.github.com/articles/using-pull-requests)
334+
335+
- Fork the repository
336+
- Create a feature branch
337+
- Set your docker credentials on your fork using the following secret names: `DOCKER_USER` and `DOCKER_PASS`
338+
- Submit a [pull request](https://help.github.com/articles/using-pull-requests)
301339

302340
## Test & Linter
303341

renovate.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
33
"extends": [
4-
"config:recommended", ":dependencyDashboardApproval"
4+
"config:recommended",
5+
":dependencyDashboardApproval"
56
]
67
}

resources/durablestore_postgres.sql

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ CREATE TABLE IF NOT EXISTS states_store
3232
shard_number BIGINT NOT NULL,
3333

3434
PRIMARY KEY (persistence_id, version_number)
35-
CREATE INDEX IF NOT EXISTS idx_states_store_persistence_id ON events_store(persistence_id);
36-
CREATE INDEX IF NOT EXISTS idx_states_store_version_number ON events_store(version_number);
3735
);
3836

37+
--- create an indexes
3938
CREATE INDEX IF NOT EXISTS idx_states_store_persistence_id ON states_store(persistence_id);
4039
CREATE INDEX IF NOT EXISTS idx_states_store_version_number ON states_store(version_number);

resources/eventstore_postgres.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ CREATE TABLE IF NOT EXISTS events_store
3737
PRIMARY KEY (persistence_id, sequence_number)
3838
);
3939

40-
--- create an index on the is_deleted column
40+
--- create an indexes
4141
CREATE INDEX IF NOT EXISTS idx_events_store_persistence_id ON events_store(persistence_id);
4242
CREATE INDEX IF NOT EXISTS idx_events_store_seqnumber ON events_store(sequence_number);
4343
CREATE INDEX IF NOT EXISTS idx_events_store_timestamp ON events_store (timestamp);

resources/offsetstore_postgres.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ CREATE TABLE IF NOT EXISTS offsets_store
3131
PRIMARY KEY (projection_name, shard_number)
3232
);
3333

34-
--- create an index on the projection_name column
34+
--- create an indexes
3535
CREATE INDEX IF NOT EXISTS idx_offsets_store_name ON offsets_store (projection_name);
3636
CREATE INDEX IF NOT EXISTS idx_offsets_store_shard ON offsets_store (shard_number);

0 commit comments

Comments
 (0)