Skip to content

feat(watch): add Watch mechanism and route writes through Raft#103

Merged
slow2342 merged 1 commit into
mainfrom
feat/watch
Jun 9, 2026
Merged

feat(watch): add Watch mechanism and route writes through Raft#103
slow2342 merged 1 commit into
mainfrom
feat/watch

Conversation

@slow2342

@slow2342 slow2342 commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Summary

Add bidirectional streaming Watch gRPC service for key change notifications. Refactor KvService to route writes through Raft consensus. Remove BTreeMap from state machine — RocksDB is now the single source of truth.

Changes

  • proto/watch.proto — AetherWatch service with WatchRequest/WatchResponse messages.
  • src/watch/mod.rs — WatchManager with broadcast channel fan-out, key/range filtering.
  • src/api/watch.rs — gRPC WatchService implementation with bidirectional streaming.
  • src/api/kv.rs — KvService refactored to route Put/Delete/Txn through raft.client_write(). Added require_leader() check. Reads remain direct from storage.
  • src/raft/state_machine.rs — Removed BTreeMap, all reads/writes go through RocksDB. Storage errors properly propagated in apply_request, build_snapshot, install_snapshot.
  • src/storage/rocksdb.rs — Added clear_default_cf() for snapshot restore.
  • src/main.rs — Wired WatchManager, WatchService, refactored KvService.

Testing

  • cargo build passes
  • cargo clippy -- -D warnings passes
  • cargo fmt -- --check passes
  • cargo test passes (10 existing storage tests)

Related issues

Refs #78

Add bidirectional streaming Watch gRPC service for key change
notifications. Refactor KvService to route Put/Delete/Txn writes
through Raft consensus instead of writing directly to storage.
Remove BTreeMap from state machine — RocksDB is now the single
source of truth for user data.

- proto/watch.proto: AetherWatch service with WatchRequest/WatchResponse
- src/watch/mod.rs: WatchManager with broadcast channel fan-out
- src/api/watch.rs: gRPC WatchService implementation
- src/api/kv.rs: KvService routes writes through raft.client_write()
- src/raft/state_machine.rs: removed BTreeMap, all reads/writes via RocksDB
- src/storage/rocksdb.rs: added clear_default_cf() for snapshot restore

Refs #78
@slow2342
slow2342 merged commit fbc7008 into main Jun 9, 2026
7 of 9 checks passed
@slow2342
slow2342 deleted the feat/watch branch June 9, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant