feat(shared): SdkCallCx, Services bundle, ServiceEventEmitter trait shape
Foundation for the v1.1.x stateful SDK services. Lands the shape only:
- SdkCallCx — per-call context plumbed into every future service
trait method (app_id, principal, execution/request ids, trigger
depth slots).
- Services — empty non_exhaustive bundle; v1.1.1 (KV) adds the first
field, subsequent PRs follow.
- ServiceEventEmitter — async trait future services emit through;
real outbox-backed impl lands with triggers in v1.1.1. NoopEventEmitter
is the v1.1.0 default.
No behaviour change. Subsequent commits in this PR plumb these types
through executor-core and the orchestrator dispatch path.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
38
crates/shared/src/services.rs
Normal file
38
crates/shared/src/services.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
//! `Services` — bundle of stateful SDK service handles plumbed from the
|
||||
//! host binary into every Rhai execution.
|
||||
//!
|
||||
//! v1.1.0 ships this struct empty. Subsequent PRs in the v1.1.x series
|
||||
//! add one field per service:
|
||||
//!
|
||||
//! ```ignore
|
||||
//! pub kv: Arc<dyn KvService>, // v1.1.1
|
||||
//! pub docs: Arc<dyn DocsService>, // v1.1.2
|
||||
//! pub http: Arc<dyn HttpService>, // v1.1.4
|
||||
//! // …
|
||||
//! ```
|
||||
//!
|
||||
//! The bundle is cheap to clone (`Arc` per service) and is constructed
|
||||
//! once at startup in the picloud binary. The executor takes it by
|
||||
//! reference per invocation, hands it (alongside an `SdkCallCx`) to
|
||||
//! `executor-core::sdk::register_all`, which wires the corresponding
|
||||
//! Rhai `::` namespace per service.
|
||||
//!
|
||||
//! `#[non_exhaustive]` so adding fields is a non-breaking change for
|
||||
//! consumers that only *pattern-match* a `&Services`; only crates that
|
||||
//! *construct* a `Services` (in practice, just the picloud binary) need
|
||||
//! to update their constructor when new services land.
|
||||
|
||||
/// SDK service bundle. See module docs for the lifecycle and the v1.1.x
|
||||
/// expansion plan.
|
||||
#[non_exhaustive]
|
||||
#[derive(Default)]
|
||||
pub struct Services {}
|
||||
|
||||
impl Services {
|
||||
/// Construct an empty bundle. Replaced by a fielded `::new(...)`
|
||||
/// once the first service (KV, v1.1.1) lands.
|
||||
#[must_use]
|
||||
pub fn new() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user