Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
renatillas committed Jan 25, 2025
1 parent 9b72a37 commit a7f598d
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 19 deletions.
101 changes: 85 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,93 @@
# eventsourcing_postgres
<h1 align="center">Eventsourcing Postgres</h1>

[![Package Version](https://img.shields.io/hexpm/v/eventsourcing_postgres)](https://hex.pm/packages/eventsourcing_postgres)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/eventsourcing_postgres/)
<div align="center">
✨ <strong>Event Sourcing Library for Gleam with PostgreSQL</strong> ✨
</div>

```sh
<div align="center">
A Gleam library for building event-sourced systems using PostgreSQL as the event store.
</div>

<br />

<div align="center">
<a href="https://hex.pm/packages/eventsourcing_postgres">
<img src="https://img.shields.io/hexpm/v/eventsourcing_postgres" alt="Available on Hex" />
</a>
<a href="https://hexdocs.pm/eventsourcing_postgres">
<img src="https://img.shields.io/badge/hex-docs-ffaff3" alt="Documentation" />
</a>
</div>

---

## Table of contents

- [Introduction](#introduction)
- [Features](#features)
- [Concurrency Safety](#concurrency-safety)
- [Philosophy](#philosophy)
- [Installation](#installation)
- [Support](#support)
- [Contributing](#contributing)
- [License](#license)

## Introduction

`eventsourcing_postgres` is a Gleam library designed to help developers build event-sourced systems using PostgreSQL. Event sourcing is a pattern where changes to the application's state are stored as a sequence of events.

## Features

- **Event Sourcing**: Build systems based on the event sourcing pattern.
- **PostgreSQL Event Store**: Robust event store implementation using PostgreSQL.
- **Command Handling**: Handle commands and produce events with robust error handling.
- **Event Application**: Apply events to update aggregates.
- **Snapshotting**: Optimize aggregate rebuilding with configurable snapshots.
- **Type-safe Error Handling**: Comprehensive error types and Result-based API.
- **Concurrency Safe**: Uses pessimistic concurrency to ensure safe concurrent access.

## Concurrency Safety

### What is Pessimistic Concurrency?

Pessimistic concurrency is a method of managing concurrent access to a resource by locking it when a transaction is being performed. This ensures that no other transaction can modify the resource until the lock is released.

### Why is it Important?

In the context of event sourcing, multiple transactions could attempt to modify the same aggregate simultaneously. Without proper concurrency control, this could lead to inconsistencies in the stored events. Pessimistic concurrency ensures that only one transaction can modify an aggregate at any given time, preserving data integrity and consistency.

## Philosophy

eventsourcing_postgres is designed to make building event-sourced systems easy and intuitive.
It encourages a clear separation between command handling and event application,
making your code more maintainable and testable.

## Installation

Add eventsourcing_postgres to your Gleam projects from the command line:

``` sh
gleam add eventsourcing_postgres@1
```
```gleam
import eventsourcing_postgres

pub fn main() {
// TODO: An example of the project in use
}
```
## Support

Further documentation can be found at <https://hexdocs.pm/eventsourcing_postgres>.
eventsourcing_postgres is built by Renatillas.
Contributions are very welcome!
If you've spotted a bug, or would like to suggest a feature,
please open an issue or a pull request.

## Development
## Contributing

```sh
gleam run # Run the project
gleam test # Run the tests
```
Contributions are welcome! Please follow these steps:

1. Fork the repository.
2. Create a new branch (git checkout -b my-feature-branch).
3. Make your changes and commit them (git commit -m 'Add new feature').
4. Push to the branch (git push origin my-feature-branch).
5. Open a pull request.
6. Please ensure your code adheres to the project's coding standards and includes appropriate tests.

## License

This project is licensed under the MIT License. See the LICENSE file for details.
2 changes: 1 addition & 1 deletion gleam.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version = "5.1.0"
# your project to the Hex package manager.
#
description = "Postgres event store for the Eventsourcing library"
licences = ["Apache-2.0"]
licences = ["MIT"]
repository = { type = "github", user = "renatillas", repo = "eventsourcing_postgres" }

# For a full reference of all the available options, you can have a look at
Expand Down
4 changes: 2 additions & 2 deletions manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages = [
{ name = "birdie", version = "1.2.5", build_tools = ["gleam"], requirements = ["argv", "edit_distance", "filepath", "glance", "gleam_community_ansi", "gleam_erlang", "gleam_stdlib", "justin", "rank", "simplifile", "trie_again"], otp_app = "birdie", source = "hex", outer_checksum = "2531AD6AC71C89DFB7ECC8839C3DAB858963ECA425E9308302D3B93B8AE0FEAD" },
{ name = "birl", version = "1.8.0", build_tools = ["gleam"], requirements = ["gleam_regexp", "gleam_stdlib", "ranger"], otp_app = "birl", source = "hex", outer_checksum = "2AC7BA26F998E3DFADDB657148BD5DDFE966958AD4D6D6957DD0D22E5B56C400" },
{ name = "edit_distance", version = "2.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "edit_distance", source = "hex", outer_checksum = "A1E485C69A70210223E46E63985FA1008B8B2DDA9848B7897469171B29020C05" },
{ name = "eventsourcing", version = "6.0.1", build_tools = ["gleam"], requirements = ["birl", "gleam_stdlib"], otp_app = "eventsourcing", source = "hex", outer_checksum = "88AA61514647F7D99D9A1225E96E8E8E9AE16B1A12730CBA397F0F54B045D182" },
{ name = "eventsourcing", version = "6.1.0", build_tools = ["gleam"], requirements = ["birl", "gleam_stdlib"], otp_app = "eventsourcing", source = "hex", outer_checksum = "3E2C164F72F4BCE01BBDE9E930D905104A46D25C28A0C403D1D1B57B8B74BD40" },
{ name = "filepath", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "67A6D15FB39EEB69DD31F8C145BB5A421790581BD6AA14B33D64D5A55DBD6587" },
{ name = "glam", version = "2.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "glam", source = "hex", outer_checksum = "66EC3BCD632E51EED029678F8DF419659C1E57B1A93D874C5131FE220DFAD2B2" },
{ name = "glance", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "glexer"], otp_app = "glance", source = "hex", outer_checksum = "784CE3B5658CF589B2E811031992FDADDFA9C7FD2A51F1140EE019F121D6D0EB" },
Expand Down Expand Up @@ -35,7 +35,7 @@ packages = [

[requirements]
birdie = { version = ">= 1.2.5 and < 2.0.0" }
eventsourcing = { version = ">= 6.0.0 and < 7.0.0" }
eventsourcing = { version = ">= 6.1.0 and < 7.0.0" }
gleam_json = { version = ">= 2.3.0 and < 3.0.0" }
gleam_otp = { version = ">= 0.16.1 and < 1.0.0" }
gleam_stdlib = { version = ">= 0.52.0 and < 2.0.0" }
Expand Down

0 comments on commit a7f598d

Please sign in to comment.