Skip to content

Latest commit

 

History

History
247 lines (206 loc) · 14.3 KB

CHANGELOG.md

File metadata and controls

247 lines (206 loc) · 14.3 KB

Changelog - aimdb-sync

All notable changes to the aimdb-sync crate will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Breaking — typed record keys (design 063)

  • Producer and consumer factories take typed names and infer their payload type. Names are declared before builder and handle calls.

0.7.0 - 2026-11-03

Changed (breaking)

  • Write timestamps (#326). get, get_with_timeout, try_get, get_latest and get_latest_with_timeout return Stamped<T>: the value is .value, its write time .stamp().

  • Issue #212: Removed SyncProducer::try_set, SyncProducer::try_set_value, and SyncError::SetTimeout. Every built-in buffer overwrites rather than refusing a write, so these APIs duplicated set() and set_value() without providing distinct behavior.

0.6.0 - 2026-09-18

Added

  • AimDbHandle::shutdown(&self), shutdown_timeout(&self, _) and is_closed(). The shutdown contract a foreign-language binding needs — &self, idempotent, safe during a publish, and an is_closed that never takes the shutdown's lock — pinned by tests/shutdown_contract_test.rs. detach(self) and detach_timeout(self, _) are unchanged and delegate.
  • tracing no longer pulls dep:tracing (design 050 §10.4): that arm now reaches the crate through aimdb_core::__private, as the log arm already did. Both features stay — they select the arms.
  • A log feature, mirroring aimdb-core's (design 050). The log_* macros are #[macro_export]ed, so their #[cfg(feature = "log")] arm is resolved against this crate — aimdb-core/log on its own would leave this crate's call sites unrouted. It forwards and adds nothing else; no log dependency is needed here, because the macro reaches the crate through aimdb_core::__private.

Changed

  • A shutdown releases the database, where dropping the handle used to. The runtime holds it weakly; the handle owns the strong reference and drops it after the join. That closes the buffers, so a consumer parked in get() is woken and the publish after is refused. Unchanged for detach(self). Costs one atomic increment per publish.

Fixed

  • A timed-out detach_timeout no longer strands a thread. The wait used a helper thread parked in join(), and a join() cannot be cancelled — so an expired timeout left that thread blocked for the life of the process, one per timed-out detach. The runtime thread now holds a liveness channel open for exactly as long as it runs; the caller waits on that instead, so there is no second thread to reclaim. Disconnection is the completion event, which covers a normal return, an early return and a panic alike.
  • Drop no longer blocks. It attempted a 5-second emergency shutdown, so a handle dropped without detach() could stall a destructor for five seconds and log from inside it — including during unwinding, or inside a C++ destructor across an FFI boundary. It now signals shutdown and releases the thread, which is what actually causes cleanup; a destructor cannot report failure anyway, so blocking bought nothing the caller could act on. Call detach() when you need to know the thread is down.
  • detach_timeout documents what a timeout leaves behind — the signal was delivered, the thread stops on its own, the handle is consumed, and surviving producers and consumers keep working until it stops and then fail with RuntimeShutdown.
  • AimDbSyncExt::attach no longer spins, and can no longer hang. The constructor polled a Mutex<Option<Handle>> on a 1 ms sleep while the runtime thread filled it — and that thread returns early if Runtime::new() fails, so the wait never ended. It now takes the same channel-and-blocking_recv shape AimDbBuilderSyncExt::attach has always used: a runtime thread that dies drops its sender, which closes the channel, which ends the wait with SyncError::AttachFailed.
  • A startup failure now carries its cause. Both constructors' channels carry a Result, so a failed Runtime::new() or a failed build() reports why instead of only that it happened — previously the reason reached the log sink and nothing else, which for an FFI consumer meant a status code and an empty explanation.
  • detach_timeout parks instead of polling. The wait used a 10 ms sleep loop, so every shutdown paid up to 10 ms it did not need and the timeout was rounded up to the next tick. It now blocks on recv_timeout.
  • Both Mutex::lock().unwrap() sites are gone, with the mutex they guarded. A poisoned lock could panic out of the blocking surface, which across an FFI boundary is undefined behaviour rather than an error.

Changed

  • The runtime thread is one value, and the fork() check is unavoidable. Runtime (internal) now holds the Tokio handle, the database and the fork generation, and enter()/db() are the only routes to them — so a publish or a read cannot be written that skips the check. Previously the same fact was copied into three types and checked at nine call sites that each had to opt in; four defects in one review pass were all instances of someone forgetting to. AimDbHandle drops from six loose fields to two, so releasing state inherited across a fork can no longer be half-done. No API signature changed, and producers and consumers still hold a weak reference, so a handle's lifetime still governs. One behaviour did: handle.producer() in a forked child now returns a producer instead of Err(ForkedChild), and the refusal lands on the first set()/try_set() instead. Creating a producer touches neither the database nor the runtime thread, so this matches what an unregistered key has always done there; nothing can be published either way. A consumer needs a Tokio handle that outlives the runtime — buffered data stays readable after detach — so it holds a RuntimeRef whose handle is private to the runtime module and reachable only through a checked accessor, rather than a bare field beside a guard. That view carries its runtime's fork generation rather than inferring it from a weak reference: once the runtime is gone, a failed upgrade cannot tell a detach in this process from a child that released its inherited handle, and the two need opposite answers. waiter.rs is retired — enter() returns the handle it existed to wrap.

Added

  • fork() safety. A child of fork inherits every handle, producer and consumer the parent held, and none of the runtime thread that makes them work — so its set() used to return Ok into a buffer nobody drains. The runtime now records the fork generation it was built in, and every route to it — a publish, a read, a subscribe — refuses with the new SyncError::ForkedChild once the process has forked since then. detach and Drop release the runtime thread's JoinHandle rather than joining a thread this process does not have, which panicked inside std. Detection is a lazily registered pthread_atfork handler, so the check on the publish path is one relaxed atomic load, and a program that never attaches never installs a handler. A database the child attaches itself after forking is unaffected — the guard is a generation counter, not a poison flag. The detection itself stays internal: a facade asks SyncProducer::check() rather than the generation counter, so the semver commitment is to the question and not to the mechanism.
  • A panic-freedom contract on the blocking surface. The crate is compiled under deny(clippy::unwrap_used, clippy::expect_used, clippy::panic) outside its own tests, so "a panic here is a bug, not an error channel" is checked rather than remembered. There were no violations left to fix — the last two went with the mutex removed in #226 — so this is a ratchet, not a cleanup. It matters most across an FFI boundary, where unwinding is undefined behaviour and a consumer's panic = "abort" turns any panic into the whole process dying. Documented with its two limits: block_on still panics if called from inside a Tokio runtime, and the guarantee stops at this crate's edge.
  • SyncProducer::check(). Answers "can a publish through this producer still reach the database?" without publishing — Ok(()), or RuntimeShutdown / ForkedChild. It is the check set() already performs, exposed rather than duplicated, so the answer cannot drift from what a publish would find. It takes no lock, which is what makes it usable from a facade whose own teardown holds the lock its AimDbHandle sits behind.
  • SyncError::kind(). Returns aimdb_core::DbErrorKind rather than a kind of its own, so a caller — an FFI layer above all — has one set of actions for the whole stack instead of one per crate. The Db arm delegates, so a buffer that is merely empty classifies identically whether it is reached through this facade or through aimdb-core directly.
  • SyncProducer<T: Settable>::set_value/try_set_value/set_value_at (design 041 §3.4, feature data-contracts). set() took a fully constructed T, so every outside-the-thread caller hand-assembled the struct; set_value(value) constructs via T::set(value, timestamp) and sends in one call — blocking (set_value), non-blocking (try_set_value), or with an explicit timestamp for replay/testing (set_value_at). set_value/try_set_value stamp the caller's SystemTime (crate is std-only). New optional dependency: aimdb-data-contracts (feature settable), behind the new data-contracts feature — the contracts crate gains no sync feature (dependency direction unchanged).

Changed (breaking)

  • SyncError::AttachFailed carries a DbError instead of a String. The field is now source: DbError rather than message: String. Flattening the cause to a string threw away its classification one layer below where it is useful: a startup that failed because the record graph was misconfigured still reported DbErrorKind::Internal, even though the message said otherwise. SyncError::kind() now delegates to the cause, so that case classifies as Configuration. The Display output is unchanged in substance, and the cause is exposed through std::error::Error::source.
  • SyncError is #[non_exhaustive]. Downstream exhaustive matches now need a wildcard arm; match on kind() instead where you only need to know what to do. This is what makes every future SyncError variant additive rather than breaking.
  • Issue #131: AimDbSyncExt extends the non-generic aimdb_core::AimDb; internal handles drop the TokioAdapter type parameter.
  • Issue #200: the internal channel bridge to the tokio thread is gone — blocking calls now call the runtime directly using the block_on seam. API implications:
    • SyncProducer::set_with_timeout removed
    • Capacity-related API removed: AimDbBuilderSyncExt::producer_with_capacity/consumer_with_capacity and the DEFAULT_SYNC_CHANNEL_CAPACITY constant are gone.
    • SyncConsumer: get, try_get, get_with_timeout, get_latest, and get_latest_with_timeout now take &mut self (was &self)
    • SyncConsumer no longer implements Clone or Sync (still Send).
    • BufferLagged now reaches callers of get, get_with_timeout, and try_get as SyncError::Db(DbError::BufferLagged { .. }); the old forwarding task swallowed it.
    • Migration. The replacement for a cloned consumer is a second handle.consumer() — but note that it is not a like-for-like swap. Cloning in 0.5.0 shared one stream, so each clone got a share of the values (split). Calling handle.consumer() twice gives two independent cursors, so each one sees every value (fan-out). Code that mechanically replaces clone() with consumer() therefore changes behaviour with no compile error. To keep split semantics, share one consumer as Arc<Mutex<SyncConsumer<T>>>.

Changed

  • attach() updated to destructure the (AimDb<TokioAdapter>, AimDbRunner) tuple returned by AimDbBuilder::build() after issue #88, and to drive the runner inside the runtime thread via tokio::select! against the shutdown signal. No public API change.

0.5.0 - 2026-02-21

Changed

  • Dependency Update: Updated aimdb-core and aimdb-tokio-adapter dependencies to 0.5.0

0.4.0 - 2025-12-25

Changed

  • Dependency Update: Updated aimdb-core and aimdb-tokio-adapter dependencies to 0.4.0

0.3.0 - 2025-12-15

Changed

  • Breaking: Producer/Consumer API: All methods now require a record key parameter:
    • producer::<T>(key) instead of producer::<T>()
    • consumer::<T>(key) instead of consumer::<T>()
    • producer_with_capacity::<T>(key, capacity) instead of producer_with_capacity::<T>(capacity)
    • consumer_with_capacity::<T>(key, capacity) instead of consumer_with_capacity::<T>(capacity)
  • Breaking: Record Registration API: Updated all test code to use new key-based configure<T>(key, |reg| ...) API
  • All integration tests now specify explicit record keys (e.g., "test.data") per new RecordId/RecordKey architecture

0.2.0 - 2025-11-20

Changed

  • Updated to support async build() method in aimdb-core
  • Compatible with new connector builder pattern

0.1.0 - 2025-11-06

Added

  • Initial release of synchronous API wrapper for AimDB
  • Blocking wrapper around async AimDB core
  • Thread-safe synchronous record access
  • Automatic Tokio runtime management
  • Ideal for gradual migration from sync to async
  • Type-safe synchronous record operations
  • Compatible with existing synchronous codebases