# `PhoenixMicro.Producer`
[🔗](https://github.com/iamkanishka/phoenix_micro/blob/v1.0.0/lib/phoenix_micro/producer.ex#L1)

High-level message producer with batching, async fire-and-forget,
and sync-with-ack publishing.

## Usage

    # Async fire-and-forget
    PhoenixMicro.Producer.publish("payments.created", %{amount: 100})

    # Sync with confirmation
    :ok = PhoenixMicro.Producer.publish_sync("payments.created", %{amount: 100})

    # Batch publish
    messages = [
      {"payments.created", %{amount: 100}},
      {"payments.created", %{amount: 200}}
    ]
    PhoenixMicro.Producer.publish_batch(messages)

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `publish`

```elixir
@spec publish(String.t(), term(), keyword()) :: :ok
```

Publishes a message asynchronously (fire-and-forget).
Returns immediately; does not wait for broker acknowledgment.

# `publish_batch`

```elixir
@spec publish_batch(
  [{String.t(), term()}],
  keyword()
) :: :ok
```

Publishes multiple messages, automatically batching them.

# `publish_sync`

```elixir
@spec publish_sync(String.t(), term(), keyword()) :: :ok | {:error, term()}
```

Publishes a message synchronously, waiting for broker confirmation.
Returns `:ok` or `{:error, reason}`.

# `start_link`

```elixir
@spec start_link(keyword()) :: GenServer.on_start()
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
