ausimian
Stagger - Point-to-point, durable message-queues for GenStage
Stagger is a small library I wrote to provide simple, durable message queues, for a use-case where inbound data has to be reliably captured even when downstream processing might not be available. In this use-case, capture should be better than ‘in-memory only’ but didn’t warrant a full enterprise-grade message-queuing system.
The inbound data source opens and writes to the message queue (just a file)
{:ok, pid} = Stagger.open("/path/to/msg/queue")
...
:ok = Stagger.write(pid, msg)
The downstream processing is implemented as a GenStage consumer, and subscribes the producer to process the events:
use GenStage
def init(args) do
{:ok, pid} = Stagger.open("/path/to/msg/queue")
:ok = GenStage,async_subscribe(self(), to: pid)
{:consumer, pid}
end
def handle_events(events, _from, state) do
# process events
{:noreply, [], state}
end
Other possible points of interest:
- The Producer supports message recovery, purging and acknowledgement
- The Producer is implemented via a GenServer and handles the GenStage protocol directly, as I considered the buffering to be already taken care of by the file itself
- There’s a reasonably fully-featured stateful property test, via PropCheck, that puts the Producer through its paces.
- The library has no extra dependencies other than GenStage.
I expect there will be at least some point releases in the near future 
Popular in Libraries
Lexical
Lexical is a next-generation language server for the Elixir programming language.
Features
Context aware code completion
As-you...
New
Raxx is an alternative to Plug and is inspired by projects such as Rack(Ruby) and Ring(Clojure).
1.0-rc.1 is now available. To use it re...
New
I’d like to announce a small library called boundaries.
This is an experimental project which explores the idea of enforcing boundaries ...
New
I released Doggo, a collection of unstyled Phoenix components.
Features
Unstyled Phoenix components.
Storybook that can be added to...
New
Hi all!
I’m happy to announce that Telemetry v0.3.0 is out! This release marks the conversion from Elixir to Erlang so that all the libr...
New
Hi everyone,
I’m coming from the Symfony (PHP) framework. I like Phoenix, but it has a one thing that was build much better in the Symfo...
New
PhoenixWS - Websockets over Phoenix Channels
Source code on Github here: https://github.com/tmbb/phoenix_ws
Phoenix channels are a great...
New
Hi there,
for my project DBLSQD, I needed a file storage solution that is a bit more flexible than Arc. Because I thought others might f...
New
Bandit is an HTTP server for Plug and WebSock apps.
Bandit is written entirely in Elixir and is built atop Thousand Island. It can serve...
New
import Meeseeks.CSS
html = HTTPoison.get!("https://news.ycombinator.com/").body
for story <- Meeseeks.all(html, css("tr.athing")) do...
New
Other popular topics
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
15:22:35.803 [error] gen_event {lager_file_backend...
New
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!)
This post collects co...
New
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
I have a User schema with a :from_id field set to type :string:
defmodule TweetBot.Repo.Migrations.CreateUsers do
use Ecto.Migration
...
New
Hey,
Just curious what are the main benefits of Elixir compared to Clojure?
When is Elixir more useful than Clojure and vice versa?
Th...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New







