A Zenoh storage backend using redb embedded database. Pure Rust, ACID-compliant, zero-copy reads, with wildcard query support.
  • Rust 89.8%
  • Just 6.9%
  • Dockerfile 3%
  • Shell 0.3%
Find a file
Marc Pardo 4fa7fc21ca Release 0.3.1
- Fix clippy warnings
- Fix code formatting
- Simplify CI workflow
2025-12-28 16:07:04 +01:00
.github/workflows Simplify CI workflow 2025-12-28 15:49:16 +01:00
benches simplify the CI 2025-11-06 10:59:25 +01:00
bin Improve zenohd integration tests and fix version compatibility 2025-12-28 15:40:25 +01:00
config initial commit 2025-10-25 19:23:19 +02:00
examples two table architecture 2025-11-05 16:58:20 +01:00
src Fix code formatting 2025-12-28 15:56:10 +01:00
tests Improve zenohd integration tests and fix version compatibility 2025-12-28 15:40:25 +01:00
.dockerignore wip 2025-11-06 13:27:15 +01:00
.gitignore initial commit 2025-10-25 19:23:19 +02:00
audit.toml initial commit 2025-10-25 19:23:19 +02:00
Cargo.lock Release 0.3.1 2025-12-28 16:07:04 +01:00
Cargo.toml Release 0.3.1 2025-12-28 16:07:04 +01:00
CHANGELOG.md Release 0.3.1 2025-12-28 16:07:04 +01:00
ci-local.sh simplify the CI 2025-11-06 10:59:25 +01:00
CLAUDE.md Update documentation for Zenoh 1.7.0 and Rust 1.91.1 2025-12-28 15:43:06 +01:00
deny.toml initial commit 2025-10-25 19:23:19 +02:00
docker-compose.yml Improve zenohd integration tests and fix version compatibility 2025-12-28 15:40:25 +01:00
Dockerfile Release v0.3.0 2025-12-28 15:45:32 +01:00
justfile Update documentation for Zenoh 1.7.0 and Rust 1.91.1 2025-12-28 15:43:06 +01:00
README.md Update documentation for Zenoh 1.7.0 and Rust 1.91.1 2025-12-28 15:43:06 +01:00
rust-toolchain.toml Improve zenohd integration tests and fix version compatibility 2025-12-28 15:40:25 +01:00

Zenoh Backend redb

License License

A Zenoh storage backend using redb as the underlying database engine.

Overview

This backend provides persistent storage for Zenoh using redb, a pure Rust embedded key-value database with ACID compliance and zero-copy reads. It's particularly well-suited for edge computing, IoT devices, and applications requiring a lightweight, dependency-free storage solution.

Compatible with Zenoh 1.7.0

Features

  • Pure Rust - No C dependencies, fully memory-safe
  • High Performance - Zero-copy reads with MVCC support, thread-local buffers
  • ACID Compliant - Reliable data storage with transaction support
  • Wildcard Queries - Supports Zenoh wildcard patterns (* and **)
  • Flexible Configuration - Per-storage configuration options
  • Read-Only Mode - Optional read-only storage instances
  • Prefix Stripping - Efficient key storage with optional prefix removal
  • Embedded - No separate database server required
  • Persistent - Data survives zenohd restarts

Installation

  1. Build the plugin library:
cargo build --release --features plugin
  1. Install the plugin in your Zenoh plugin directory:
cp target/release/libzenoh_backend_redb.so ~/.zenoh/lib/

Quick Start

  1. Configure Zenoh to use the backend in your zenoh.json5 config file:
{
  plugins: {
    storage_manager: {
      volumes: {
        redb: {}
      },
      storages: {
        demo: {
          key_expr: "demo/example/**",
          strip_prefix: "demo/example",
          volume: {
            id: "redb",
            dir: "demo_storage",
            create_db: true,
            fsync: true
          }
        }
      }
    }
  }
}
  1. Start Zenoh with the configuration:
zenohd -c zenoh.json5

Configuration

Storage Configuration

Each storage instance can be individually configured:

Parameter Type Default Description
dir String required Database directory name (creates <name>.redb)
db_file String - Alternative to dir, explicit database filename
cache_size Number redb default Cache size in bytes
fsync Boolean true Enable fsync for durability
create_db Boolean true Create database if it doesn't exist
read_only Boolean false Read-only mode

Environment Variables

  • ZENOH_BACKEND_REDB_ROOT: Override default storage directory (default: ~/.zenoh/zenoh_backend_redb)

Usage Examples

Basic Storage Configuration

{
  plugins: {
    storage_manager: {
      volumes: {
        redb: {}
      },
      storages: {
        sensor_data: {
          key_expr: "sensor/**",
          volume: {
            id: "redb",
            dir: "sensors",
            fsync: true
          }
        }
      }
    }
  }
}

Multiple Storages

{
  plugins: {
    storage_manager: {
      volumes: {
        redb: {}
      },
      storages: {
        sensors: {
          key_expr: "sensor/**",
          volume: {
            id: "redb",
            dir: "sensor_db"
          }
        },
        config: {
          key_expr: "config/**",
          volume: {
            id: "redb",
            dir: "config_db"
          }
        }
      }
    }
  }
}

Using Strip Prefix

Strip prefix saves storage space by removing the common prefix from stored keys:

{
  plugins: {
    storage_manager: {
      volumes: {
        redb: {}
      },
      storages: {
        demo: {
          key_expr: "demo/example/**",
          strip_prefix: "demo/example",
          volume: {
            id: "redb",
            dir: "demo_storage"
          }
        }
      }
    }
  }
}

Read-Only Storage

{
  plugins: {
    storage_manager: {
      volumes: {
        redb: {}
      },
      storages: {
        archive: {
          key_expr: "archive/**",
          volume: {
            id: "redb",
            dir: "archive_db",
            read_only: true
          }
        }
      }
    }
  }
}

Custom Cache Size

{
  plugins: {
    storage_manager: {
      volumes: {
        redb: {}
      },
      storages: {
        large_data: {
          key_expr: "large/**",
          volume: {
            id: "redb",
            dir: "large_db",
            cache_size: 104857600  // 100 MB cache
          }
        }
      }
    }
  }
}

Architecture

┌─────────────────────────────────────┐
│       Zenoh Application             │
└────────────┬────────────────────────┘
             │
             ↓
┌─────────────────────────────────────┐
│      RedbBackend                    │
│  - Manages multiple storages        │
│  - Configuration management         │
└────────────┬────────────────────────┘
             │
             ↓
┌─────────────────────────────────────┐
│      RedbStorage                    │
│  - CRUD operations                  │
│  - Wildcard matching (* and **)     │
│  - Dual-table design                │
└────────────┬────────────────────────┘
             │
             ↓
┌─────────────────────────────────────┐
│         redb Database               │
│  - ACID transactions                │
│  - MVCC                             │
│  - Zero-copy reads                  │
└─────────────────────────────────────┘

Comparison with Other Backends

Feature redb RocksDB LMDB
Pure Rust Yes No (C++) No (C)
ACID Yes Yes Yes
Zero-copy reads Yes No Yes
Concurrent writes MVCC Yes Limited
Memory-mapped Yes No Yes
Setup complexity Simple Moderate Moderate
Best for Edge/Embedded High-throughput Read-heavy

Testing

Run unit and integration tests (excludes zenohd tests):

just test

zenohd Integration Tests

The zenohd integration tests verify the full plugin lifecycle:

  • Plugin loading in zenohd
  • PUT/GET/DELETE operations
  • Wildcard queries (* and **)
  • Data persistence across zenohd restarts

Requirements: The tests require zenohd and the storage_manager plugin to be built with the exact same Zenoh version and Rust compiler as the redb plugin.

# Recommended: Use Podman for version-matched testing
just docker-test-zenohd

# Local testing (requires matching zenohd 1.7.0 + plugins in ~/.zenoh/lib/)
just test-zenohd

The Docker method builds zenohd and all plugins from source with matching versions, ensuring compatibility.

Development

# Install development tools
just install-tools

# Format and lint
just check

# Run all quality checks
just quality

# Pre-commit verification
just verify

License

This project is licensed under either of:

at your option.

Resources

Status

This project is currently in alpha stage. The API may change as we gather feedback and improve the implementation.