https://github.com/michalmuskala/persist
GenStage-based persistence layer guaranteeing at-least-once delivery of the events.
https://github.com/michalmuskala/persist
Last synced: 5 months ago
JSON representation
GenStage-based persistence layer guaranteeing at-least-once delivery of the events.
- Host: GitHub
- URL: https://github.com/michalmuskala/persist
- Owner: michalmuskala
- Created: 2016-08-02T21:53:40.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-08-02T22:04:57.000Z (over 8 years ago)
- Last Synced: 2024-10-06T10:41:46.180Z (7 months ago)
- Language: Elixir
- Homepage:
- Size: 23.4 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Persist
GenStage-based persistence layer guaranteeing at-least-once delivery of the
events.## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed as:
1. Add `persist` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:persist, "~> 0.1.0"}]
end
```2. Ensure `persist` is started before your application:
```elixir
def application do
[applications: [:persist]]
end
```If [published on HexDocs](https://hex.pm/docs/tasks#hex_docs), the docs can
be found at [https://hexdocs.pm/persist](https://hexdocs.pm/persist)## Usage
```elixir
{:ok, _} = Persist.start_link(EventBus, path: "./data")# Insert some events into the EventBus
{:ok, producer} = GenStage.from_enumerable(1..1000)
GenStage.sync_subscribe(Persist.consumer(EventBus), to: producer)# Consume the events
GenStage.stream([Persist.producer(EventBus, :my_subscription)])
|> Enum.each(fn {ack_ref, event} ->
Persist.ack(ack_ref)
IO.inspect event
end)
```