Skip to content

refactor(watch): Remove runtime config and improve client error handling #210

Closed

Description

@JoshuaChi

Summary

This PR refactors the Watch feature to simplify configuration and improve reliability:

  1. Remove runtime watch.enabled config - Watch is now controlled purely by compile-time feature flag
  2. Add sentinel error to gRPC watch streams - Clients receive explicit UNAVAILABLE error on server shutdown
  3. Comprehensive reliability documentation - Production-ready reconnection patterns and error handling guides
  4. Clarified test strategy - Focus on Watch code correctness, defer Raft integration tests

Motivation

Problem 1: Confusing configuration

  • Having both compile-time feature flag AND runtime config was redundant
  • Users had to enable watch in two places (Cargo.toml + config file)
  • Principle: "If compiled, it must be used"

Problem 2: Silent stream closure

  • gRPC watch streams ended with Ok(None) on server crash
  • Clients couldn't distinguish "no more events" from "server died"
  • No guidance on reconnection logic

Problem 3: Over-scoped test plan

  • Initial strategy included Raft integration tests (Leader election, network partition)
  • These test Raft correctness, not Watch correctness
  • Watch simply listens to StateMachine.apply() - Raft guarantees apply's correctness

Changes

1. Configuration Simplification

Before:

# Cargo.toml
d-engine = { features = ["watch"] }

# config/raft.toml
[raft.watch]
enabled = true  # ← Redundant!
event_queue_size = 1000

Activity

  1. added this to the v0.2.0 milestone on Dec 20, 2025
  2. added theissue type on Dec 20, 2025
  3. added
    concern:performanceThroughput, latency, CPU/memory/disk efficiency.
    type:refactorCode restructuring without changing external behavior
    on Dec 20, 2025
  4. coderabbitai commented on Dec 20, 2025

    @coderabbitai

    📝 CodeRabbit Plan Mode

    Generate an implementation plan and prompts that you can use with your favorite coding agent.

    • Create Plan
    Examples

    🔗 Similar Issues

    Related Issues

    🔗 Related PRs

    #130 - doc #129: update README to align with v0.1.3 [merged]
    #149 - V0.1.4 release [merged]
    #176 - Feature/172 ttl support [merged]
    #177 - feat #174: Implement lock-free Watch mechanism for real-time key monitoring [merged]
    #199 - Feature/196 client watch [merged]

    👤 Suggested Assignees

    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord or schedule a call!

  5. added 3 commits that reference this issue on Dec 20, 2025
  6. added 2 commits that reference this issue on Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    concern:performanceThroughput, latency, CPU/memory/disk efficiency.type:refactorCode restructuring without changing external behavior

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions