In order to build a useful application, Atmo needs to be able to connect to external resources. Currently, Atmo can connect to NATS and Redis, and upcoming releases will include additional types such as databases and more.

To create connections, add a connections section to your Directive:

serverAddress: nats://localhost:4222
serverAddress: localhost:6379

When Atmo starts up, it will establish the connections you've configured, and make them available to your application in a few different ways.

The NATS connection is made available as a stream source:

- type: stream
source: nats
resource: user.created
- fn: record-signup

By setting the source field of the handler, we tell Atmo to listen to that particular connection and handle messages it sends us. The resource field dictates which topic or subject the handler is listening to, which is useful for messaging systems such as NATS and Kafka.

Streams that use an external source can also use the respondTo field to set which topic or subject the response message is sent to:

- type: stream
source: nats
resource: user.login
- fn: record-login
respondTo: user.send-login-email

The Redis connection will be made available to Runnables utilizing the cache capability:

use suborbital::runnable::*;
use suborbital::req;
use suborbital::cache;
struct CacheGet{}
impl Runnable for CacheGet {
fn run(&self, _: Vec<u8>) -> Result<Vec<u8>, RunErr> {
let key = req::url_param("key");
let val = cache::get(key.as_str()).unwrap_or_default();