# `Electric.Connection.Restarter`
[🔗](https://github.com/electric-sql/electric/tree/%40core/sync-service%401.6.2/packages/sync-service/lib/electric/connection/restarter.ex#L1)

Gen server responsible for shutting down and restarting the connection subsystem.

It makes sure to update StatusMonitor with the current subsystem state to maintain correct
behaviour of other components of the system that depend on the database availability, such
as:

  - HTTP API server processing shape requests
  - publication manager
  - schema reconciler

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `init`

# `name`

# `restart_connection_subsystem`

Restart the connection subsystem.

# `restore_connection_subsystem`

Restore the connection subsystem after it had been stopped by `stop_connection_subsystem/1`.

## Implementation notes
To restore the subsystem, the Shapes.Supervisor is stopped first before getting
restarted by the Connection.Manager later. The Connection.Manager itself is started
via a `Supervisor.restart_child()` call.

# `start_link`

# `stop_connection_subsystem`

Stop the connection subsystem, closing all database connections.

This lets the database server scale its compute to zero if it supports this feature and has
no other sessions.

Inside Electric, the shape subsystem keeps running.

## Implementation notes

Currently, this function stops only the Connection.Manager process which shuts down all types
of database connections linked to it. When a new shape request arrives, it will immediately
stop the Shapes.Supervisor and restart the Connection.Manager, which then in turn starts
a fresh Shapes.Supervisor again.

---

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