vahuja4

vahuja4

Hi Everyone,

I am new to Elixir (read the first seven chapters of Elixir in Action and completed some exercises). Programming in Elixir is certainly joyful :-):slightly_smiling_face: Am working in the blockchain space and I need to develop a notification engine. Since this is my first time designing this kind of a system, I need some advice please. The requirement is as follows:

  1. Whenever a transaction is done on a blockchain, like Hyperledger Fabric (HLF), an event can be emitted. In my specific case, the event is a JSON with multiple fields.

  2. HLF has a nodejs SDK which provides the functionality to listen to these events.

  3. These events have to be sent to a notification engine which can do things like below:

a. If an event has been generated with ‘quantity’ > 1000, then notify the ‘supplier’.
b. In a 24 hour window, how many orders have been shipped to me; notify the ‘receiver’.
c. In a 5 minute window, do something based on a ‘field’ or 'fields’ in the event JSON; notify a particular ‘person’ which is mentioned in the event JSON.

The basic design in my mind is below:

  1. Run one server per notification type.
    2.Another server which manages all the notification servers. Basically, this server will maintain a map between the notification type and the notification server pid. This server will also receive the events from the nodejs HLF sdk.

Is this design reasonable? Another question I have is that the notifications have to be persisted as well. Should the database writes happen in a separate process/ task? Lastly, is ther ea good way to implement the notion of a time window in Elixir? Looking forward to some guidance. Thank you!

Showing Posts 1 to 2

tcoopman

tcoopman

Hi @vahuja4,

Welcome to ElixirForum!

What do you mean exactly by server here? Do you mean a GenServer? Reading along, it seems you mean indeed GenServer because you want to have a map to the notification pid.

It’s kind a hard to say if your design is reasonable or not. For these kind of things I would wonder about some guarantees first:

  • How do you receive the message from HLF?
  • Is that message delivered via a at-least-on or at-most-once delivery (meaning you could see duplicates or you might miss messages depending on the system)
  • Can the notification fail? And if it fails do you need to retry?
  • If the notification fails do you still have to persist it?
  • How many messages do you expect to receive, how many will result in notifications?
  • …

For the design of your code, I would recommend you to read this awesome blog The Erlangelist - To spawn, or not to spawn?.

As you can read there in the main points:

  • Use functions and modules to separate thought concerns.
  • Use processes to separate runtime concerns.
  • Do not use processes (not even agents) to separate thought concerns.

It sounds like you are using processes to split business logic, and that’s not what processes are for. It sounds like you probably want modules/functions for your different notifications types and processes to handle the way you handle messages. How you want to handle the messages depends a lot on how robust you want to be in handling the messages.

vahuja4

vahuja4 OP

Thank you for your reply! I skimmed through the blog and will re-read it in detail. It is certainly helpful. Yes, in my post, when I say server I refer to GenServer (that is all I know today). The reason I was thinking of one server per notification type is that every event will have to be checked for the different patterns that could lead to a notification. In other words, an event could contribute towards multiple notifications. And this reasoning is based on the following statement in the ‘Elixir in Action’ book: Another way to look at server processes is to think of them as services. Each process is like a small service that’s responsible for a single task.

— All posts loaded —

Where Next? Top

Trending in Questions Top

axelson
One of my LiveView view’s has a very heavy javascript dependency so I want to avoid loading it for every page on the site, while still us...
New
yasoob
Hi all! I know that quite a few people use Phoenix LiveView but it is hard to get a more up-to-date list of folks/companies using it. I ...
New
Hellowman
Hello everyone! I am new to coding with Elixir/Erlang. And i am looking for some utilities for fuzzing testing like AFL++. Does anyone ...
New
yarrichar
I’m very new to Elixir, so sorry if this is a silly question: I am wondering what happens to the mailbox of a process when the machine i...
New
mandar1045
I load tested a plain Phoenix chat app backed by Postgres with 100 million messages in it, everything on default settings, to see what br...
New
caioaao
Hey, I know this has been discussed ad nauseum, but I couldn’t find a definitive answer or at least some consensus around this, so let me...
New
Liam_or
I don’t suppose you can lazy load a library depending on runtime data? For example if it’s a certain user they can lazy load ‘library A’ ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
261 13183 112
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
charlenopires
Hi everyone :waving_hand: I’ve been working on PhiaUI, an open-source UI component library for Phoenix LiveView, and I wanted to share i...
New
PJUllrich
On November 23, 2026, an unauthorized third party exploited a vulnerability in hex.pm (CVE-2026-129514, CVSS 10.0) that let them run comm...
New
akoutmos
@hugobarauna, Dr. Dimitrios Koutmos (my brother) and I (Alex Koutmos) have been hard at work on writing a book on how you can use Elixir ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews