defmodule Pulsar.CConsumer do # Dummy callback module for consumers defmodule XXX do def handle_message(_message), do: :ok def handle_messages(_messages), do: :ok end @behaviour :gen_statem 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 ] {: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