Skip to content

Commit

Permalink
Fix readme
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandremcosta committed Jun 12, 2024
1 parent 454124e commit 51349ce
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ Wraps `eredis` and `eredis_sub` functionallity for Elixir usage.
- Publishes binary messages to Redis Pub/Sub channels.
- Subscribes to channels and calls a handler function when a message is received.

## Why not use `Phoenix.PubSub`?

Because multiple applications in many programming languages can use Redis Pub/Sub,
but they don't serialize their binary messages according to `Phoenix` schema.

## Why not use `eredis` directly?

That's also a great option. With `EredisSub` Elixir abstraction we intend to hide
Erlang specific knowledge, for example Erlang strings and OTP processes. We changed
the API to let clients subscribe a handler function to a Pub/Sub channel, similar
to how [`:telemetry`](https://hexdocs.pm/telemetry/readme.html) attaches handlers.

We sacrificed flexibility on client process architecture, for a simpler mental model.
If you need to handle message passing or a pool of processes, for example to handle
heavier loads, use `:eredis` directly.

## Usage

### Publish
Expand Down Expand Up @@ -34,7 +50,7 @@ Subscribe to a channel:

```elixir
metadata_example = %{subscribed_at: DateTime.utc_now()}
EredisSub.subscribe("my_channel", {MyModule, :handle, metadata_example})
EredisSub.subscribe("my_channel", MyModule, metadata_example)
```

## Installation
Expand Down

0 comments on commit 51349ce

Please sign in to comment.