Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/workerd/io/io-channels/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ macro_rules! kj_conversions {
&self.0
}
}

// A `KjRc` is a pointer to the C++ object, which moving the reference doesn't move. A
// bridge requires a Rust type that holds a channel and that C++ borrows mutably to be
// `Unpin`.
impl Unpin for $name {}
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/workerd/server/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Bazel labels: `//src/workerd/server:workerd`, `//src/workerd/server:workerd-cli`
| `run.rs` | `run()` / `test()` / `bench()`: bind sockets, start the inspector (before any isolate exists), build the graph, start the listeners (not for a config the `Reporter` refuses), drain (after the config's `shutdownDelayMs`, which a second drain signal cuts short; at once for a signal that came while it started), control-fd events, the check that every `--directory-path` / `--external-addr` override named a service |
| `bench.rs` | `workerd bench`'s options and report (`io/bench.capnp`): a group for each `bench()` handler `run::bench` runs (through the factory's `worker_bench`), progress logged as `workerd test` logs it, the environment, and the report as a table or as JSON |
| `config.rs` | `Server`: the service graph from the config in three passes (actor configs, construction, link); `Factory`, the Rust owner of the C++ `WorkerFactory`; `Reporter`, which attributes a deployment's config errors to it; resolves channel tokens and debug-port requests |
| `channels.rs` | The handles C++ holds and the runtime reaches into the server through: `SubrequestChannel` (an `Rc<dyn Channel>`), `ActorClassChannel` (an `Rc<dyn ActorClass>`), `ChannelFactory` (a worker's `LinkedChannels`), `WorkerStub`, and the `Weak` back-pointers (`ServerHandle`, `ActorNamespaceHandle`, `ActorHooks`). Single-threaded |
| `channels.rs` | The handles C++ holds and the runtime reaches into the server through: `SubrequestChannel` (an `Rc<dyn Channel>` or a C++ channel), `ActorClassChannel` (an `Rc<dyn ActorClass>` or a C++ class), `DynamicChannels` (a dynamic worker's source's channels), `ChannelFactory` (a worker's `LinkedChannels`), `WorkerStub`, and the `Weak` back-pointers (`ServerHandle`, `ActorNamespaceHandle`, `ActorHooks`). Single-threaded |
| `bindings.rs` | `compile_bindings` / `loopback_globals`: `Worker.bindings` and `ctx.exports` to the `Globals` message and the channel tables the link stage fills |
| `worker.rs` | `WorkerService`: compiled through the factory, `PendingLink` designators resolved into `LinkedChannels` once every service exists; entrypoints, actor classes, the I/O channel table requests see |
| `actor.rs` | `ActorNamespace` / `ActorContainer`: actor lifecycle, facets, idle shutdown, eviction, and the sweep that drops long-idle `ActorContainer`s. The sweep keeps a container anything but its map holds (a stub or a request, each a `Client`; an eviction in progress), so nothing else holds one strongly: back-pointers to a container are `Weak`. A root actor with an onHibernate handler retires instead of shutting down at once: once it is idle, `try_evict` spawns `retire_actor`, which runs the handler, then shuts the actor down. The container owns the task (`retirement`), so canceling the eviction or idle timer that started it doesn't cancel it. Requests and evictions that arrive meanwhile wait for it, then reach a new instance, or get its error if it failed and broke the container. A request the handler makes to its own object waits too, until the handler's wall-clock budget cuts the handler off. Only `abort` cancels a running handler, with or without a reason; a cluster drain aborts every actor. A cluster node whose lease has lapsed doesn't start a retirement. Docker containers, their registry and the cleanup join at shutdown are the factory's (`-actor.c++`) |
Expand Down
9 changes: 0 additions & 9 deletions src/workerd/server/factory/worker-factory-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,6 @@ class CompiledWorker::Impl final: public kj::Refcounted, private kj::TaskSet::Er
kj::Own<capnp::MallocMessageBuilder> flagsArena;
// A dynamic worker's source: its `env`, its tails and the content its script points into.
kj::Maybe<DynamicWorkerSource> dynamicSource;
// A dynamic worker's I/O channel tables, numbered as the runtime numbers channels: the
// subrequest table starts with `IoContext::SPECIAL_SUBREQUEST_CHANNEL_COUNT` slots for the
// global outbound (or a null outbound when the source gave none), then the capabilities the
// `env` held in cap-table order; actor classes and RPC channels start from zero. The Rust
// channel factory serves the numbers past these tables (the worker's own `ctx.exports`). Empty
// for a config worker, whose whole table is the Rust side's.
kj::Vector<kj::Rc<IoChannelFactory::SubrequestChannel>> subrequestChannels;
kj::Vector<kj::Rc<IoChannelFactory::ActorClassChannel>> actorClassChannels;
kj::Vector<kj::Rc<IoChannelFactory::RpcChannel>> rpcChannels;
kj::Maybe<kj::String> accessBlobHeader;
bool isDynamic = false;

Expand Down
Loading
Loading