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.
- 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
-
Write timestamps (#326).
get,get_with_timeout,try_get,get_latestandget_latest_with_timeoutreturnStamped<T>: the value is.value, its write time.stamp(). -
Issue #212: Removed
SyncProducer::try_set,SyncProducer::try_set_value, andSyncError::SetTimeout. Every built-in buffer overwrites rather than refusing a write, so these APIs duplicatedset()andset_value()without providing distinct behavior.
0.6.0 - 2026-09-18
AimDbHandle::shutdown(&self),shutdown_timeout(&self, _)andis_closed(). The shutdown contract a foreign-language binding needs —&self, idempotent, safe during a publish, and anis_closedthat never takes the shutdown's lock — pinned bytests/shutdown_contract_test.rs.detach(self)anddetach_timeout(self, _)are unchanged and delegate.tracingno longer pullsdep:tracing(design 050 §10.4): that arm now reaches the crate throughaimdb_core::__private, as thelogarm already did. Both features stay — they select the arms.- A
logfeature, mirroringaimdb-core's (design 050). Thelog_*macros are#[macro_export]ed, so their#[cfg(feature = "log")]arm is resolved against this crate —aimdb-core/logon its own would leave this crate's call sites unrouted. It forwards and adds nothing else; nologdependency is needed here, because the macro reaches the crate throughaimdb_core::__private.
- 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 fordetach(self). Costs one atomic increment per publish.
- A timed-out
detach_timeoutno longer strands a thread. The wait used a helper thread parked injoin(), and ajoin()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. Dropno longer blocks. It attempted a 5-second emergency shutdown, so a handle dropped withoutdetach()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. Calldetach()when you need to know the thread is down.detach_timeoutdocuments 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 withRuntimeShutdown.AimDbSyncExt::attachno longer spins, and can no longer hang. The constructor polled aMutex<Option<Handle>>on a 1 ms sleep while the runtime thread filled it — and that thread returns early ifRuntime::new()fails, so the wait never ended. It now takes the same channel-and-blocking_recvshapeAimDbBuilderSyncExt::attachhas always used: a runtime thread that dies drops its sender, which closes the channel, which ends the wait withSyncError::AttachFailed.- A startup failure now carries its cause. Both constructors' channels carry
a
Result, so a failedRuntime::new()or a failedbuild()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_timeoutparks 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 onrecv_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.
- 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, andenter()/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.AimDbHandledrops from six loose fields to two, so releasing state inherited across aforkcan 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 ofErr(ForkedChild), and the refusal lands on the firstset()/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 afterdetach— so it holds aRuntimeRefwhose 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 adetachin this process from a child that released its inherited handle, and the two need opposite answers.waiter.rsis retired —enter()returns the handle it existed to wrap.
fork()safety. A child offorkinherits every handle, producer and consumer the parent held, and none of the runtime thread that makes them work — so itsset()used to returnOkinto 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 newSyncError::ForkedChildonce the process has forked since then.detachandDroprelease the runtime thread'sJoinHandlerather than joining a thread this process does not have, which panicked insidestd. Detection is a lazily registeredpthread_atforkhandler, 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 asksSyncProducer::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'spanic = "abort"turns any panic into the whole process dying. Documented with its two limits:block_onstill 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(()), orRuntimeShutdown/ForkedChild. It is the checkset()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 itsAimDbHandlesits behind.SyncError::kind(). Returnsaimdb_core::DbErrorKindrather 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. TheDbarm delegates, so a buffer that is merely empty classifies identically whether it is reached through this facade or throughaimdb-coredirectly.SyncProducer<T: Settable>::set_value/try_set_value/set_value_at(design 041 §3.4, featuredata-contracts).set()took a fully constructedT, so every outside-the-thread caller hand-assembled the struct;set_value(value)constructs viaT::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_valuestamp the caller'sSystemTime(crate is std-only). New optional dependency:aimdb-data-contracts(featuresettable), behind the newdata-contractsfeature — the contracts crate gains nosyncfeature (dependency direction unchanged).
SyncError::AttachFailedcarries aDbErrorinstead of aString. The field is nowsource: DbErrorrather thanmessage: 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 reportedDbErrorKind::Internal, even though the message said otherwise.SyncError::kind()now delegates to the cause, so that case classifies asConfiguration. TheDisplayoutput is unchanged in substance, and the cause is exposed throughstd::error::Error::source.SyncErroris#[non_exhaustive]. Downstream exhaustive matches now need a wildcard arm; match onkind()instead where you only need to know what to do. This is what makes every futureSyncErrorvariant additive rather than breaking.- Issue #131:
AimDbSyncExtextends the non-genericaimdb_core::AimDb; internal handles drop theTokioAdaptertype parameter. - Issue #200: the internal channel bridge to the
tokiothread is gone — blocking calls now call the runtime directly using theblock_onseam. API implications:SyncProducer::set_with_timeoutremoved- Capacity-related API removed:
AimDbBuilderSyncExt::producer_with_capacity/consumer_with_capacityand theDEFAULT_SYNC_CHANNEL_CAPACITYconstant are gone. SyncConsumer:get,try_get,get_with_timeout,get_latest, andget_latest_with_timeoutnow take&mut self(was&self)SyncConsumerno longer implementsCloneorSync(stillSend).BufferLaggednow reaches callers ofget,get_with_timeout, andtry_getasSyncError::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). Callinghandle.consumer()twice gives two independent cursors, so each one sees every value (fan-out). Code that mechanically replacesclone()withconsumer()therefore changes behaviour with no compile error. To keep split semantics, share one consumer asArc<Mutex<SyncConsumer<T>>>.
attach()updated to destructure the(AimDb<TokioAdapter>, AimDbRunner)tuple returned byAimDbBuilder::build()after issue #88, and to drive the runner inside the runtime thread viatokio::select!against the shutdown signal. No public API change.
0.5.0 - 2026-02-21
- Dependency Update: Updated
aimdb-coreandaimdb-tokio-adapterdependencies to 0.5.0
0.4.0 - 2025-12-25
- Dependency Update: Updated
aimdb-coreandaimdb-tokio-adapterdependencies to 0.4.0
0.3.0 - 2025-12-15
- Breaking: Producer/Consumer API: All methods now require a record key parameter:
producer::<T>(key)instead ofproducer::<T>()consumer::<T>(key)instead ofconsumer::<T>()producer_with_capacity::<T>(key, capacity)instead ofproducer_with_capacity::<T>(capacity)consumer_with_capacity::<T>(key, capacity)instead ofconsumer_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
- Updated to support async
build()method inaimdb-core - Compatible with new connector builder pattern
0.1.0 - 2025-11-06
- 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