# `Electric.Replication.ShapeLogCollector.RequestBatcher`
[🔗](https://github.com/electric-sql/electric/tree/%40core/sync-service%401.6.2/packages/sync-service/lib/electric/replication/shape_log_collector/request_batcher.ex#L1)

Module responsible for registering and unregistering shapes
with the ShapeLogCollector. It batches registration and
unregistration requests to avoid overwhelming the ShapeLogCollector
with frequent updates.

The current implementation batches updates until it receives an
acknowledgement that its previous update was processed by the processor,
and only then sends the next batch of updates. This is slower than a
regular debounce, but prevents any buildup on the processor.

In the future, this could also create diffs to the shape filters
instead of sending the full list of shapes to add/remove on each update.

# `t`

```elixir
@type t() :: %Electric.Replication.ShapeLogCollector.RequestBatcher{
  ack_ref: reference() | nil,
  ack_waiters: [{Electric.shape_handle(), GenServer.from()}],
  stack_id: Electric.stack_id(),
  to_add: %{required(Electric.shape_handle()) =&gt; Electric.Shapes.Shape.t()},
  to_remove: MapSet.t(Electric.shape_handle()),
  to_schedule_waiters: %{
    required(Electric.shape_handle()) =&gt; GenServer.from() | nil
  }
}
```

# `add_shape`

```elixir
@spec add_shape(
  Electric.stack_id(),
  Electric.shape_handle(),
  Electric.Shapes.Shape.t(),
  :create | :restore
) :: :ok | {:error, any()}
```

Registers a shape with the SLC, returns after the shape has actually
been added and is receiving operations from the log.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `handle_processor_update_response`

```elixir
@spec handle_processor_update_response(
  Electric.stack_id(),
  reference(),
  %{optional(Electric.shape_handle()) =&gt; :ok | {:error, String.t()}}
) :: :ok
```

Handles the response from the Processor acknowledging a registration update.

# `name`

```elixir
@spec name(Electric.stack_id()) :: GenServer.name()
```

# `remove_shape`

```elixir
@spec remove_shape(Electric.stack_id(), Electric.shape_handle()) :: :ok
```

Schedules a shape removal from the SLC, returns before the shape is
actually removed.

# `start_link`

---

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