faucet-source-redis
A Redis source that reads records from lists, streams, or key patterns, returning them as JSON.
Part of the faucet-stream ecosystem.
Installation
[]
= "0.1"
= { = "1", = ["full"] }
Or via the umbrella crate:
= { = "0.2", = ["source-redis"] }
Quick Start
use ;
async
Configuration
RedisSourceConfig
| Field | Type | Default | Description |
|---|---|---|---|
url |
String |
(required) | Redis connection URL (e.g. "redis://127.0.0.1:6379"). Masked in debug output for security |
source_type |
RedisSourceType |
(required) | The type of Redis data structure to read from |
max_records |
Option<usize> |
None |
Optional maximum number of records to return (truncates after fetching) |
Source Types (RedisSourceType)
List
Read all elements from a Redis list via LRANGE 0 -1.
| Field | Type | Description |
|---|---|---|
key |
String |
The list key |
Each list element is parsed as JSON. If an element is not valid JSON, it is returned as a JSON string.
Stream
Read entries from a Redis stream via XREAD or XREADGROUP.
| Field | Type | Default | Description |
|---|---|---|---|
key |
String |
(required) | The stream key |
group |
Option<String> |
None |
Consumer group name. When set, uses XREADGROUP |
consumer |
Option<String> |
None |
Consumer name within the group (required when group is set) |
count |
Option<usize> |
None (100 for XREADGROUP) |
Maximum number of entries to read per call |
Each stream entry is returned as:
Stream field values are parsed as JSON where possible; otherwise they are returned as strings.
Keys
Scan for keys matching a glob pattern, then MGET all matched keys in a single round-trip.
| Field | Type | Description |
|---|---|---|
pattern |
String |
Glob pattern for SCAN (e.g. "user:*") |
Each key-value pair is returned as:
Values are parsed as JSON where possible; otherwise they are returned as strings.
Config Loading
use ;
use RedisSourceConfig;
let config: RedisSourceConfig = load_json?;
let config: RedisSourceConfig = load_env_file?;
Example JSON config (List)
Example JSON config (Stream with consumer group)
Example JSON config (Keys)
Example .env file
REDIS_SOURCE_URL=redis://127.0.0.1:6379
REDIS_SOURCE_MAX_RECORDS=1000
Config Schema Introspection
use Source;
let source = new;
let schema = source.config_schema;
println!;
Examples
Reading from a list
use ;
use Source;
let config = new
.max_records;
let source = new;
let notifications = source.fetch_all.await?;
Reading from a stream with consumer group
use ;
use Source;
let config = new;
let source = new;
let events = source.fetch_all.await?;
for event in &events
Scanning keys by pattern
use ;
use Source;
let config = new;
let source = new;
let users = source.fetch_all.await?;
for user in &users
License
Licensed under MIT or Apache-2.0.