Read, write, list, and delete keys in a NATS JetStream Key-Value bucket.
| Operation | Description |
|---|
get | Read a value by key. |
put | Write a value. Uses event.data.content if present, otherwise the full event data. |
list | List keys matching a prefix. |
delete | Delete a key. |
- nats_kv_store:
name: write_flow
operation: put
credentials_path: /etc/nats/credentials.json
url: "{{env.NATS_URL}}"
bucket: flowgen_system
key: "flows.{{event.data.path}}"
| Field | Type | Default | Description |
|---|
name | string | required | Task name. |
operation | string | required | One of get, put, list, delete. |
credentials_path | string | required | Path to NATS credentials file. |
url | string | localhost:4222 | NATS server URL. |
bucket | string | required | KV bucket name. |
key | string | | Key for get, put, and delete. Supports templating. |
key_prefix | string | | Key prefix for list operations. Supports templating. |
depends_on | list | | Upstream task names. |
retry | object | | Retry configuration. |
Format: JSON
| Field | Type | Description |
|---|
key | string | Requested key. |
content | string / null | Stored value, or null if not found. |
found | bool | Whether the key exists. |
| Field | Type | Description |
|---|
key | string | Written key. |
revision | int | KV store revision number. |
| Field | Type | Description |
|---|
key | string | Deleted key. |
| Field | Type | Description |
|---|
keys | array | Matching key names. |
count | int | Number of keys returned. |
prefix | string | Prefix that was searched. |
- nats_kv_store:
name: save_config
operation: put
bucket: flowgen_system
key: "config.{{event.data.name}}"
credentials_path: /etc/nats/credentials.json
url: "{{env.NATS_URL}}"
- nats_kv_store:
name: load_config
operation: get
bucket: flowgen_system
key: "config.my_setting"
credentials_path: /etc/nats/credentials.json
url: "{{env.NATS_URL}}"
Returns {key, content, found}. content is null if the key does not exist.
- nats_kv_store:
name: list_flows
operation: list
bucket: flowgen_system
key_prefix: "flows."
credentials_path: /etc/nats/credentials.json
url: "{{env.NATS_URL}}"
Returns {prefix, keys, count}.
- nats_kv_store:
name: remove_config
operation: delete
bucket: flowgen_system
key: "config.old_setting"
credentials_path: /etc/nats/credentials.json
url: "{{env.NATS_URL}}"