Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/deadtrickster/amqp_rpc
RPC Client/Server for amqp Elixir library
https://github.com/deadtrickster/amqp_rpc
amqp-rpc elixir fuse monitoring rabbitmq rpc-client
Last synced: about 1 month ago
JSON representation
RPC Client/Server for amqp Elixir library
- Host: GitHub
- URL: https://github.com/deadtrickster/amqp_rpc
- Owner: deadtrickster
- License: mit
- Created: 2016-07-30T00:33:02.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-09-25T12:17:50.000Z (about 5 years ago)
- Last Synced: 2024-10-07T08:15:25.086Z (about 1 month ago)
- Topics: amqp-rpc, elixir, fuse, monitoring, rabbitmq, rpc-client
- Language: Elixir
- Size: 21.5 KB
- Stars: 6
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AMQP RPC Client/Server templates [![Build Status](https://travis-ci.org/deadtrickster/amqp_rpc.svg?branch=master)](https://travis-ci.org/deadtrickster/amqp_rpc) [![Hex.pm](https://img.shields.io/hexpm/v/amqp_rpc.svg?maxAge=2592000?style=plastic)](https://hex.pm/packages/amqp_rpc)
**Warning!** POC quality!
## Goals
- Reduce boilerplate
- Handle reconnects
- Messages housekeeping
- Logging
- Monitoring
- Use [fuse](https://github.com/jlouis/fuse)
- Content negotiation### Fuse
[Fuse](https://github.com/jlouis/fuse) helps reduce latency when something goes wrong with RabbitMQ or RPC server side by breaking circuit and returning immideately. Fuse can be configured via `fuse_name` and `fuse_opts` keys. We trying to maintain sensible default for those.### Monitoring/Instrumenting
Clients can be instrumented using built-in metrics plugins. Currenly [implemented](https://github.com/deadtrickster/amqp_rpc/blob/master/lib/amqp/rpc/stat/plugin.ex)
- ETS-backed plugin (default)
- [Prometheus](https://github.com/deadtrickster/prometheus.erl) plugin.## Example
Below is 'classic' RPC example from [RabbitMQ tutorials](http://www.rabbitmq.com/tutorials/tutorial-six-elixir.html)
rewritten using amqp_rpc:Client:
```elixir
defmodule Fibonacci do
use AMQP.RPC.Client, [exchange: "",
queue: "rpc_queue"]def fib(n, timeout \\ @timeout) do
rpc(%{command_name: "fib",
args: n}, timeout)
end
end
```Server:
```elixir
defmodule FibonacciServer do
use AMQP.RPC.Server, [exchange: "",
queue: "rpc_queue",
commands: [:fib]]## adapted from https://gist.github.com/stevedowney/2f910bd3d72678b4cf99
def fib(0), do: 0
def fib(n)
when is_number(n) and n > 0,
do: fib(n, 1, 0, 1)def fib(_), do: [error: "positive integers only"]
def fib(n, m, _prev_fib, current_fib)
when n == m,
do: current_fibdef fib(n, m, prev_fib, current_fib),
do: fib(n, m+1, current_fib, prev_fib + current_fib)end
```## Installation
[Available in Hex](https://hex.pm/packages/amqp_rpc), the package can be installed as:
1. Add `amqp_rpc` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:amqp_rpc, "~> 0.0.7"}]
end
```2. Ensure `amqp_rpc` is started before your application:
```elixir
def application do
[applications: [:amqp_rpc]]
end
```