Giter VIP home page Giter VIP logo

fireworks's Introduction

#Fireworks

Fireworks is a framework for providing simplicity in connecting, configuring and consuming RabbitMQ queues. It is intended to provide automatic exchange -> queue bindings and handle failovers.

Usage

Fireworks requires information about the main connection to be defined in the application environment

config :fireworks, :connection,
  host: "rabbitmq.local",
  #hosts: ["rabbitmq1.local", "rabbitmq2.local"],
  username: "guest",
  password: "guest",
  heartbeat: 30

This information will be used at application start to establish a connection with the RabbitMQ Node.

Fireworks consumers are required to be declared through their own modules.

config :my_app, MyApp.WorkQueue,
  consumers: 5,
  prefetch: 100

Each fireworks module requires the following behavior methods to be declared

defmodule MyApp.WorkQueue do
  use Fireworks.Channel, otp_app: :my_app

  require Logger

  def config(channel) do
    exchange = "my_exchange"
    queue = "my_queue"

    Exchange.topic(channel, exchange, durable: true)

    Queue.declare(
      channel,
      error_queue,
      durable: false
    )

    Queue.bind(channel, queue, exchange, routing_key: "#")
    queue
  end

  def consume(%{} = message, %{delivery_tag: tag}) do
    Logger.debug "Process Message: #{inspect message}"
    ack tag
  end

  def consume(msg, _), do: Logger.error "Invalid Message: #{inspect msg}"
end

If a connection to the rabbit node is lost, fireworks will automatically attempt a reconnection to the node.

Optionally you can specify task timeout, default is 60000 miliseconds.

defmodule MyApp.WorkQueue do
  use Fireworks.Channel, [otp_app: :my_app, task_timeout: 1000]
end

Logging

Fireworks has a Logger backend which can be used to send logs to an exchange on rabbit using fireworks publisher. To use this backend you must configure :logger

In your config.exs

config :logger,
  backends: [:console, {Fireworks.Logger, otp_app: :my_app, exchange: "logger"}]

Contributing

The easiest way to test and contribute to the fireworks library is to develop and test the features through an example app that is leveraging the Fireworks behaviour. A test suite is in the works for this framework.

fireworks's People

Contributors

ewitchin avatar gsobot avatar marcantoine-arnaud avatar mjaric avatar mmmries avatar mobileoverlord avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

fireworks's Issues

Actively Maintained?

Hey, I'm thinking about using this library for a project at work. Since it's been a while since this project has merged a PR I just wanted to check if there was an active desire to maintain it. I'd be happy to do some PRs to update dependencies (ie using amqp_client 3.6.X branch), and make the configurable number of consumers work.

I just wanted to check whether there is an active set of maintainers here before I invested the time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.