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 Announcing
import Meeseeks.CSS
html = HTTPoison.get!("https://news.ycombinator.com/").body
for story <- Meeseeks.all(html, css("tr.athing")) do...
New
I’m excited to announce Jido, a framework providing foundational primitives for building autonomous agent systems in Elixir. While develo...
New
Hey everyone
i’ve developed a library for Jalaali calendar for elixir which supports converting Gregorian dates to Jalaali and vice vers...
New
Experimenting with this code.
OK.try do
user <- fetch_user(1)
cart <- fetch_cart(1)
order = checkout(cart, user)
save_orde...
New
Hi! Today, after a couple weeks of development I’ve released v0.1 of LiveVue.
It’s a seamless integration of Vue and Phoenix LiveView, i...
New
Here is my first stab at this. README pasted below.
https://github.com/Hal9000/elixir_random
Comments and critiques are welcome.
Thank...
New
TypeCheck: Fast and flexible runtime type-checking for your Elixir projects.
Core ideas
Type- and function specifications are const...
New
Hey all,
We have made an Ecto3 Adapter for SQLite3, ecto_sqlite3!
We have successfully on-boarded the full suite of integration tests (...
New
I’ve cleaned up and open sourced three financial libraries I was using for my company. They are bindings for the APIs of these three comp...
New
Hey guyz
We at @aviabird are working on a payment library in elixir/phoenix. We are targeting March 2018 to add 56 Gateways to it.
Have...
New
Other popular topics
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch.
This project took far...
New
Hi,
I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
Hey all,
I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
Hi everyone,
One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
Hello everybody,
usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
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
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









