defmodule Pulsar.CCConsumer do @doc """ """ alias Pulsar.Connection # Dummy callback module for consumers defmodule EchoConsumer do @doc """ A dummy consumer that prints the consumed messages to standard output. All messages are acknowledged after being printed out. """ def handle_message(_message), do: :ok def handle_messages(_messages), do: :ok end #use Connection defstruct topic: "", type: :Exclusive, name: "", consumer_id: 0, callback: nil @type t :: %__MODULE__{ topic: String.t(), type: String.t(), name: String.t(), consumer_id: integer(), callback: atom() } def start_link(conn, callback, topic, type, name) do args = [ conn, callback, topic, type, name ] # TO-DO: handle redirects # TO-DO: handle errors {:ok, broker} = Connection.lookup_topic(conn, topic) consumer_id = System.unique_integer([:monotonic, :positive]) consumer = %__MODULE__{ topic: topic, type: type, name: name, consumer_id: consumer_id, callback: callback } Connection.start_link( name, broker, callback: __MODULE__, callback_data: consumer ) end # callback functions def authenticated() do end def subscribed() do end def flow() do end def active() do end end