Current section

39 Versions

Jump to

Compare versions

15 files changed
+91 additions
-24 deletions
  @@ -10,7 +10,7 @@ The package can be installed as:
10 10
11 11 ```elixir
12 12 def deps do
13 - [{:conduit, "~> 0.6.0"}]
13 + [{:conduit, "~> 0.7.0"}]
14 14 end
15 15 ```
16 16
  @@ -59,13 +59,26 @@ Next you'll want to find the adapter that matches the message
59 59 queue (MQ) you're using. Currently, there is only an adapter
60 60 for MQ's with support for AMQP 0-9-1. More protocols and MQ's will be supported in the future.
61 61
62 - * AMQP 0-9-1 - [ConduitAMQP](https://github.com/conduitframework/conduit_amqp)
62 + * AMQP 0-9-1 - [ConduitAMQP](https://github.com/conduitframework/conduit_amqp#configuring-the-adapter)
63 63 * STOMP - TODO
64 64 * SQS - TODO
65 65 * Beanstalkd - TODO
66 66 * Kafka - TODO
67 67 * ZeroMQ - TODO
68 68
69 + ## Configuring the Broker Topology
70 +
71 + MQ's have queues which need to be setup and may involve other
72 + concepts as well, including exchanges and bindings. Conduit
73 + attemps to stay out of the way when you need to define these
74 + things because each MQ has a different opinion on what you need.
75 +
76 + Because of that, you'll need to looks at the specific adapter
77 + for what options are available.
78 +
79 + * AMQP 0-9-1 - [Exchanges](https://github.com/conduitframework/conduit_amqp#configuring-exchanges) & [Queues](https://github.com/conduitframework/conduit_amqp#configuring-queues)
80 +
81 + ## Testing
69 82
70 83 ## Example Broker
  @@ -44,4 +44,4 @@
44 44 {<<"name">>,<<"poison">>},
45 45 {<<"optional">>,false},
46 46 {<<"requirement">>,<<"~> 2.0">>}]]}.
47 - {<<"version">>,<<"0.7.1">>}.
47 + {<<"version">>,<<"0.7.2">>}.
  @@ -1,4 +1,8 @@
1 1 defmodule Conduit do
2 + @moduledoc """
3 + A message queue framework, with support for middleware and multiple adapters.
4 + """
5 +
2 6 defmodule UnknownContentTypeError do
3 7 @moduledoc """
4 8 Exception raised when the content type is not recognized
  @@ -26,4 +30,20 @@ defmodule Conduit do
26 30 """
27 31 defexception [:message]
28 32 end
33 +
34 + defmodule AdapterNotConfiguredError do
35 + @moduledoc """
36 + Exception raised when no adapter is configured
37 + """
38 + defexception message: """
39 + There was no adapter configured for your broker. You can configured
40 + an adapter in your config.
41 +
42 + config :my_app, MyApp.Broker,
43 + adapter: ConduitAdapter # The message queue adapter to use
44 +
45 + Note that different adapters may have additional configuration
46 + necessary.
47 + """
48 + end
29 49 end
  @@ -10,6 +10,9 @@ defmodule Conduit.Adapter do
10 10 @callback start_link(broker, topology, subscribers, Keyword.t) :: GenServer.on_start
11 11 @callback publish(Conduit.Message.t, Keyword.t) :: {:ok, Conduit.Message.t} | {:error, binary}
12 12
13 + @doc """
14 + Defines the `use`ing module as implementing the `Conduit.Adapter` behavior.
15 + """
13 16 defmacro __using__(_opts) do
14 17 quote do
15 18 @behaviour Conduit.Adapter
  @@ -26,10 +26,10 @@ defmodule Conduit.Broker do
26 26 import Supervisor.Spec
27 27
28 28 config = Application.get_env(@otp_app, __MODULE__)
29 - adapter = Keyword.get(config, :adapter)
29 + adapter = Keyword.get(config, :adapter) || raise Conduit.AdapterNotConfiguredError
30 30
31 31 subs =
32 - subscribers
32 + subscribers()
33 33 |> Enum.map(fn {name, {_, opts}} ->
34 34 {name, opts}
35 35 end)
  @@ -37,7 +37,7 @@ defmodule Conduit.Broker do
37 37
38 38 children = [supervisor(adapter, [
39 39 __MODULE__,
40 - topology,
40 + topology(),
41 41 subs,
42 42 config
43 43 ])]
Loading more files…