lfex / kanin

An LFE Wrapper for the Erlang RabbitMQ (AMQP) Client
Apache License 2.0
7 stars 2 forks source link

Add supervised API #4

Open oubiwann opened 7 years ago

oubiwann commented 7 years ago

One of the things I've noticed when working with the Erlang RabbitMQ library is how easy it is to crash a process (usually through a fault of my own, e.g., by calling a function improperly -- wrong types or wrong number of parameters). Regardless, abuse like this results in a bad user/developer experience and makes writing applications that much more finicky.

What I propose we do is provide a unifying API in the kanin module that, when started, creates a supervised kanin server that maintains connection options, connection(s), and channel(s) as state and when child processes die, new connections, channels, etc., are created automatically.

Furthermore, we could provide a default channel that is used implicitly making the API even easier to use.

Features/tasks:

Part of release v0.7.0

oubiwann commented 7 years ago

I'll set this task as an epic and create features/tasks

oubiwann commented 7 years ago

@arpunk: Would this sort of thing be of interest/help to you?

arpunk commented 7 years ago

@oubiwann Yes, I use this sort of strategy all the time (I work with RabbitMQ on a daily basis). In my experience all the pooling strategies are very opinionated. However these are my ideas:

I currently use GenStage based consumers at work using wabbit and/or custom AMQP wrappers.

I tend to wrap very lighly on the standard RabbitMQ Erlang clients. Sometimes I use turtle for simplicity when working on small PoC/MVP in Erlang.

oubiwann commented 7 years ago

@arpunk This is great feedback -- thanks!

oubiwann commented 7 years ago

@arpunk I'm much happier using this new API in the kanin module that the old one (which mirrors the native Erlang client). Still WIP, but making good progress. Default supervision tree is up next.

Compare examples:

After this release, one tedious (to implement) improvement that could be made would be to convert calls like this:

    (kanin:call
      (make-queue.bind
        queue example-queue
        exchange example-exchange
        routing_key example-key))

into this:

    (kanin:bind-queue
      queue example-queue
      exchange example-exchange
      routing-key example-key)

Much better developer experience ... but that's more than I want to tackle right now ;-)