unmbt/ciallo/runtime does not have a README file

    Clock

    pub(open) trait Clock {
    fn now_micros(Self) -> Int64
    fn now_ms(Self) -> Int64 = _
    }

    可移植单调/墙钟微秒与毫秒时钟抽象(真实时间戳保留 Int64)

    HealthCheck

    pub(open) trait HealthCheck {
    fn check_name(Self) -> String
    async fn check(Self) -> HealthStatus
    }

    HttpClient

    pub(open) trait HttpClient {
    async fn send(Self, req :
    Request
    ) ->
    Response
    raise RuntimeError
    }

    可移植出站 HTTP 客户端抽象

    KvStore

    pub(open) trait KvStore {
    async fn get(Self, key : StringView) -> String? raise RuntimeError
    async fn put(Self, key : StringView, value : StringView, ttl_sec? : Int) -> Unit raise RuntimeError
    async fn delete(Self, key : StringView) -> Unit raise RuntimeError
    }

    可移植键值存储抽象

    Lifecycle

    pub(open) trait Lifecycle {
    fn lifecycle_name(Self) -> String
    async fn on_start(Self) -> Unit
    async fn on_stop(Self) -> Unit
    }

    统一拓扑启停生命周期契约(Native 收到 SIGTERM 按依赖逆序优雅释放;Workers 模式可被 Tree-shake)

    RuntimeError

    pub(all) suberror RuntimeError {
    Unavailable(String)
    IoFailure(String)
    Timeout(String)
    } derive(Eq,
    Debug
    )

    ContextKey

    pub struct ContextKey[T] {
    // private fields
    }

    零反射、零 unsafe 强类型上下文键(支持在定义 Key 时绑定 ctx.require 缺失状态码,如鉴权 401、租户头 400)

    ContextKey::ContextKey

    fn[T] ContextKey::ContextKey(name : String, missing_status? : Int, missing_detail? : String) -> ContextKey[T]

    ContextKey::missing_detail

    fn[T] ContextKey::missing_detail(self : ContextKey[T]) -> String?

    ContextKey::missing_status

    fn[T] ContextKey::missing_status(self : ContextKey[T]) -> Int

    ContextKey::name

    fn[T] ContextKey::name(self : ContextKey[T]) -> String

    ContextKey::new

    fn[T] ContextKey::new(name : String, missing_status? : Int, missing_detail? : String) -> ContextKey[T]

    ContextStore

    pub struct ContextStore {
    // private fields
    }

    内部类型擦除存储容器(供 Env、Context 与 App providers 复用,零反射且读后立即清槽防 GC 泄漏)

    ContextStore::ContextStore

    fn ContextStore::ContextStore() -> ContextStore

    ContextStore::clone

    ContextStore::contains

    fn[T] ContextStore::contains(self : ContextStore, key : ContextKey[T]) -> Bool

    ContextStore::get

    fn[T] ContextStore::get(self : ContextStore, key : ContextKey[T]) -> T?

    ContextStore::merge_from

    fn ContextStore::merge_from(self : ContextStore, other : ContextStore, allow_override? : Bool) -> String?

    合并另一个容器;若检测到重复键且 allow_override=false,返回冲突键名

    ContextStore::set

    fn[T] ContextStore::set(self : ContextStore, key : ContextKey[T], value : T) -> Unit

    Env

    pub struct Env {
    // private fields
    }

    运行期纯只读环境变量与宿主绑定容器(Native 启动构建一次零拷贝共享,JS Workers 按请求零开销包装宿主 env)

    Env::Env

    fn Env::Env(vars? : Map[String, String]) -> Env

    Env::get_binding

    fn[T] Env::get_binding(self : Env, key : ContextKey[T]) -> T?

    Env::get_var

    fn Env::get_var(self : Env, key : StringView) -> String?

    Env::require_var

    fn Env::require_var(self : Env, key : StringView) -> String raise RuntimeError

    Env::with_binding

    fn[T] Env::with_binding(self : Env, key : ContextKey[T], value : T) -> Env

    纯函数式派生包含新绑定的只读 Env(绝不修改原 Env 实例,供适配器按连接安全注入 remote_addr_key)

    EnvBuilder

    pub struct EnvBuilder {
    // private fields
    }

    组装期环境变量与宿主绑定构建器(构建完成后生成运行期纯只读 Env,根除 Native 多协程跨请求状态污染)

    EnvBuilder::EnvBuilder

    fn EnvBuilder::EnvBuilder(vars? : Map[String, String]) -> EnvBuilder

    EnvBuilder::bind

    fn[T] EnvBuilder::bind(self : EnvBuilder, key : ContextKey[T], value : T) -> EnvBuilder

    EnvBuilder::build

    fn EnvBuilder::build(self : EnvBuilder) -> Env

    EnvBuilder::set_var

    fn EnvBuilder::set_var(self : EnvBuilder, key : StringView, value : StringView) -> EnvBuilder

    ExecutionContext

    pub struct ExecutionContext {
    // private fields
    }

    请求级异步任务托管上下文(Native 走任务组收尾,JS Workers 透传 ctx.waitUntil)

    ExecutionContext::ExecutionContext

    fn ExecutionContext::ExecutionContext(schedule_fn? : (async () -> Unit) -> Unit) -> ExecutionContext

    ExecutionContext::drain_background

    async fn ExecutionContext::drain_background(self : ExecutionContext) -> Unit

    ExecutionContext::has_scheduler

    fn ExecutionContext::has_scheduler(self : ExecutionContext) -> Bool

    ExecutionContext::wait_until

    fn ExecutionContext::wait_until(self : ExecutionContext, task : async () -> Unit) -> Unit

    FixedClock

    pub struct FixedClock {
    // private fields
    }

    impl Clock for FixedClock

    FixedClock::FixedClock

    fn FixedClock::FixedClock(start_micros? : Int64, step_micros? : Int64) -> FixedClock

    FixedClock::advance

    fn FixedClock::advance(self : FixedClock, delta_micros : Int64) -> Unit

    HealthStatus

    pub(all) struct HealthStatus {
    name : String
    ok : Bool
    detail : String?
    elapsed_micros : Int64
    } derive(Eq,
    Debug
    ,
    ToJson
    )

    标准就绪探针契约(供 CapabilityBundle 注册与 ciallo-actuator /readyz 并行聚合)

    HealthStatus::to_json

    automatically derived

    MemoryKv

    pub struct MemoryKv {
    // private fields
    }

    impl KvStore for MemoryKv

    MemoryKv::MemoryKv

    fn MemoryKv::MemoryKv() -> MemoryKv

    MockHttpClient

    pub struct MockHttpClient {
    // private fields
    }

    TraceContext

    pub(all) struct TraceContext {
    trace_id : String
    span_id : String
    parent_span_id : String?
    sampled : Bool
    tracestate : String?
    } derive(Eq,
    Debug
    )

    W3C Trace Context (traceparent / tracestate) 全链路贯通上下文

    TraceContext::child_span

    fn TraceContext::child_span(self : TraceContext, clock : &Clock) -> TraceContext

    TraceContext::new_root

    fn TraceContext::new_root(clock : &Clock) -> TraceContext

    TraceContext::to_traceparent

    fn TraceContext::to_traceparent(self : TraceContext) -> String

    parse_traceparent

    fn parse_traceparent(header : StringView) -> TraceContext?

    Source Files