项目作者: bleacherreport

项目描述 :
AMQP Connection Manager
高级语言: Elixir
项目地址: git://github.com/bleacherreport/carrot.git
创建时间: 2018-06-12T21:12:52Z
项目社区:https://github.com/bleacherreport/carrot

开源协议:Apache License 2.0

下载


Carrot

AMQP connection manager

Build Status
codecov

Installation

The package can be installed by adding carrot to your list of dependencies in mix.exs:

  1. def deps do
  2. [{:carrot, "~> 1.0"}]
  3. end

Configuration and startup

Carrot does not use Mix or Application configuration. The ConnectionManager
simply takes a Keyword list of connection options as the first argument to
start_link/2:

  1. {:ok, pid} = Carrot.ConnectionManager.start_link([
  2. host: "localhost",
  3. password: "guest",
  4. username: "guest",
  5. virtual_host: "/"
  6. ])

Supervision

The ConnectionManager is meant to be started as part of a supervision tree.
Therefore, it is most common to register the process with a name. The second
argument to start_link/2 is a list of GenServer
options.

See Name Registration
for more details.

  1. ...
  2. worker(Carrot.ConnectionManager, [
  3. [
  4. host: "localhost",
  5. password: "guest",
  6. username: "guest",
  7. virtual_host: "/"
  8. ],
  9. [
  10. name: Carrot.ConnectionManager
  11. ]
  12. ]),
  13. ...

Potential gotchas

If your application dependends on cowboy at v1.x, you may need to add a
dependency override for ranch:

  1. {:ranch, "~> 1.4", override: true}

It appears there are no breaking changes between ranch 1.3 and 1.5.

Another issue you might come across is from a dependency on lager. You may
need to ensure that lager is started before Elixir’s logger:

  1. # mix.exs
  2. def application do
  3. [applications: [:lager, :logger]]
  4. end

You can also silence lager by setting its log level to critical:

  1. config :lager,
  2. handlers: [level: :critical]

Documentation

Documentation can be be found on HexDocs.