What is Nats

NATS is a simple, secure and performant communications system for digital systems, services and devices. NATS is part of the Cloud Native Computing Foundation (CNCF).

NATS has over 40 client language implementations, and its server can run on-premise, in the cloud, at the edge, and even on a Raspberry Pi. NATS can secure and simplify design and operation of modern distributed systems.

Github repository

https://github.com/nats-io/nats-server

Use Nats

With Caddy

You have to build your caddy instance including Souin and Nats using xcaddy (refer to the build caddy section).

  xcaddy build --with github.com/darkweak/souin/plugins/caddy --with github.com/darkweak/storages/nats/caddy
  

You will be able to use nats in your Caddyfile or JSON configuration file.

  {
    cache {
        ttl 1h
        nats {
            url nats://nats:4222
        }
    }
}

route {
    cache
    respond "Hello HTTP cache"
}
  

Configuration

You can find the configuration for Nats here or check the values table below.

Values

Key nametyperequired
Urlstring
Servers[]string
MaxReconnectint
MaxPingsOutint
ReconnectBufSizeint
SubChanLenint
Namestring
Nkeystring
Userstring
Passwordstring
Tokenstring
ProxyPathstring
InboxPrefixstring
ReconnectWaitDuration
ReconnectJitterDuration
ReconnectJitterTLSDuration
TimeoutDuration
DrainTimeoutDuration
FlusherTimeoutDuration
PingIntervalDuration
NoRandomizebool
NoEchobool
Verbosebool
Pedanticbool
Securebool
TLSHandshakeFirstbool
AllowReconnectbool
UseOldRequestStylebool
NoCallbacksAfterClientClosebool
RetryOnFailedConnectbool
Compressionbool
IgnoreAuthErrorAbortbool
SkipHostLookupbool