# `Malla.Plugins.Base`
[🔗](https://github.com/netkubes/malla/blob/main/lib/malla/plugins/base.ex#L21)

The base plugin that all services include by default.

This module provides a set of essential callbacks that form the foundation of
a Malla service's behavior. All services include this plugin in their dependency
list, even if not explicitly declared.

# `class`

```elixir
@type class() :: Malla.class()
```

# `config`

```elixir
@type config() :: map()
```

# `cont`

```elixir
@type cont() :: Malla.cont()
```

# `id`

```elixir
@type id() :: Malla.id()
```

# `user_state`

```elixir
@type user_state() :: map()
```

# `malla_authorize`
*optional* 

```elixir
@callback malla_authorize(term(), term(), Malla.authorize_opt()) ::
  boolean() | {boolean(), term()} | {:error, term()}
```

  Called when `Malla.authorize/3` is called.

  By default it returns `{:error, :auth_not_implemented}`

# `service_cb_in`
*optional* 

```elixir
@callback service_cb_in(atom(), list(), keyword()) :: any()
```

  Called from `Malla.remote/4` and functions in `Malla.Node` when a remote callback is received.
  By default it will simply call `apply(service_module, fun, args)` but you
  can override it in your plugins to add tracing, etc.

# `service_drain`
*optional* 

```elixir
@callback service_drain() :: boolean() | cont()
```

  Called when `Malla.Service.drain/1` is called.

  Each plugin must prepare for stop, cleaning its state.

  If it could clean everything ok, it should return `:cont` to jump to next.
  If it could not, it should return `false`, meaning the drain could not complete,
  and it will be retried later.

# `service_is_ready?`
*optional* 

```elixir
@callback service_is_ready?() :: boolean() | cont()
```

  Called when `Malla.Service.is_ready?/1` is called.

  Each plugin must return either 'false' (when it is not ready) or 'cont' to go to next
  (when it is ready).

# `service_status_changed`
*optional* 

```elixir
@callback service_status_changed(Malla.Service.running_status()) :: :ok
```

Called when the service status changes.

This callback is called when the [_running_status_](`t:Malla.Service.running_status/0`) of the service
changes. You should always return `:cont` so next plugin can receive the change too.

The service information can be obtained using `Malla.get_service_id!/0` or by calling
`service_module.service()` to get the full service struct.

---

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