# Changelog

All notable changes to this project will be documented in this file.

## [0.1.0] - 2025-11-30

### Added

- **ClusterNode**: Node registration and leader election via etcd
  - Automatic leader election using etcd's `campaign`/`proclaim` APIs
  - Lease-based heartbeat with configurable TTL
  - Graceful shutdown with leadership resignation
  - Health status tracking (`Healthy`, `Unhealthy`, `Unknown`)

- **ClusterNodeBuilder**: Fluent builder API for `ClusterNode` configuration
  - Optional metrics collector integration
  - Configurable metrics update interval

- **ServiceDiscovery**: Reactive cluster state observation
  - Event subscription via `subscribe()` for push-based notifications
  - Watch channels via `watch_nodes()` and `watch_leader()` for efficient state observation
  - Lock-free O(1) reads via `nodes()` and `leader()`
  - Convenience helpers: `wait_for_nodes()`, `wait_for_leader()`, `wait_ready()`

- **ClusterEvent**: Comprehensive event types for cluster state changes
  - `NodeJoined(Node)` / `NodeLeft(Node)` / `NodeUpdated { old, new }`
  - `LeaderElected(Node)` / `LeaderLost`
  - `Ready` / `Disconnected` / `Reconnected`

- **MetricsCollector** trait: Pluggable metrics collection for nodes
  - `NoopMetricsCollector`: Default no-op implementation
  - `SystemMetricsCollector`: CPU, memory, load average (requires `system-metrics` feature)
  - `CompositeMetricsCollector`: Combine multiple metric sources

- **Node metadata**: Schema-less JSON metadata for weighted load balancing
  - Standard metadata keys in `metadata_keys` module
  - Support for custom application-specific metrics

- **Resilient connectivity**
  - Exponential backoff on etcd connection failures (1s → 30s max)
  - Automatic reconnection after network partitions

### Features

- `system-metrics`: Enables `SystemMetricsCollector` with `sysinfo` dependency

### Dependencies

- `etcd-client` 0.17 for etcd v3 API
- `tokio` 1.x for async runtime
- `serde` / `serde_json` for serialization
- `tracing` for structured logging
- `thiserror` for error handling
- `sysinfo` 0.33 (optional, for `system-metrics` feature)

[0.1.0]: https://github.com/rgushel/photon-etcd-cluster/releases/tag/v0.1.0
