Hey there BEAM community!
I’m happy to share with you my latest creation. Erlang library called Blockade. This library was born out of a personal need and a desire to improve event handling in Erlang/Elixir projects. After searching for existing solutions, I found that nothing quite all my requirements. There are many nice libraries such as Phoenix PubSub but they do not offer event filtering. So, I rolled up my sleeves and developed Blockade.
- Subscribe to events
- Dispatch events
- Filter events by priority level
- Discard events by priority level
Blockade is built on top of Erlang pg module which actually does the heavy lifting and provides the distributed features meaning events can be dispatched to all subscribers in the Erlang cluster, subscribers (processes) who die will be automatically removed from the subscribers list.
A Real-World Use Case
Let me share a real-world scenario where Blockade shines. Imagine you have a system processing critical transactions. During this time, you need to ensure that no other transactions are processed concurrently, as it could lead to inconsistencies. By leveraging Blockade, you can simply set a higher priority level on the event queue, effectively creating a blockade that locks all resources. This way, any other events in the queue will wait until the transaction processing is complete. Once the transaction finishes, resetting the priority level will automatically unleash the queued events.