# amoorion.nats.service

The daemon’s service: what arrives on `<prefix>.in.>` is kept in the inbox.

### Functions

| [`to_message`](#amoorion.nats.service.to_message)(subject, data)   | A NATS message as an inbox message: JSON with `text` is read, the rest kept as plain text.   |
|------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------|

### Classes

| [`NatsService`](#amoorion.nats.service.NatsService)(server[, vault, inbox])   | A daemon service: keeps what arrives on `<prefix>.in.>` in the inbox.   |
|----------------------------------------------------------------------------------------|-------------------------------------------------------------------------|

### amoorion.nats.service.to_message(subject, data)

A NATS message as an inbox message: JSON with `text` is read, the rest kept as plain text.

* **Parameters:**
  * **subject** (*str*)
  * **data** (*bytes*)
* **Return type:**
  [*Message*](amoorion.models.base.html.md#amoorion.models.base.Message)

### *class* amoorion.nats.service.NatsService(server, vault=None, inbox=None)

Bases: [`Controller`](amoorion.core.html.md#amoorion.core.Controller)

A daemon service: keeps what arrives on `<prefix>.in.>` in the inbox.

* **Parameters:**
  * **server** (*str*)
  * **vault** ([*Vault*](amoorion.vault.base.html.md#amoorion.vault.base.Vault) *|* *None*)
  * **inbox** ([*Inbox*](amoorion.inbox.base.html.md#amoorion.inbox.base.Inbox) *|* *None*)

#### *async* run()

Subscribe and wait for `stop`; draining lets what has arrived finish.

* **Return type:**
  None

#### *async* stop()

End `run`.

* **Return type:**
  None
