Engines
Every worker runs in a WorkManager Runtime actor, and the mime_type given to CreateWorker picks the actor type and its engine. This page covers the three engines the workers in this repo use. The WorkManager documents each engine in full: Engine System, DotNet DLL Workers and NativeDll Workers.
| Worker | MIME type | Engine | Runtime actor |
|---|---|---|---|
| HttpGet (default) | application/x-dotnet-dll |
DotNetDllEngine |
DotnetDllWorker |
| HttpGet (native build) | application/x-native-dll |
NativeDllEngine |
NativeDllWorker |
| Hello, GetTime | application/x-python |
PythonEngine |
PythonWorker |
Managed and native: one worker class
HttpGet ships one worker class per build, both deriving from WorkerBase<JsonNode, HttpGetResult> and both calling the same HttpGetWorkerLogic:
Managed (HttpGetWorker) |
Native (HttpGetWorkerNative) |
|
|---|---|---|
| Project | Virtufin.Worker.HttpGet.Managed |
Virtufin.Worker.HttpGet.Native (PublishAot), compiling the managed project's logic and codec files by link |
| Nupkg layout | lib/net11.0/HttpGetWorker.dll |
runtimes/<rid>/native/libHttpGetWorker.so (linux-x64, linux-arm64) |
| How the engine finds it | the assembly's one public IWorker type with a parameterless constructor |
the Process and FreeResult exports named in the nuspec |
| Entry point | IWorker.ProcessAsync, called directly |
[UnmanagedCallersOnly] Process/FreeResult, delegating to AotNative<HttpGetWorkerNative> from Virtufin.Worker.Host |
| Dependencies | resolved from the nuspec when the Runtime loads it, at the latest Virtufin.* versions |
compiled into the .so |
AotNative<T> decodes the protobuf CloudEvent, calls the wrapped worker's ProcessAsync and encodes the outputs as a CloudEventBatch, so the worker class itself is the same code under either engine. WorkerBase turns an exception in ProcessAsync into an error response (com.virtufin.<type>.error on wrk.<type>.error) under both.
Default to managed. It needs no cross-build, picks up library fixes at load time, and an exception fails only the message. Pick native only with a reason to: the .so runs in the Runtime process with no sandbox, so a crash in it takes the Runtime pod down with every worker it hosts, and it must come from a fully trusted source. HttpGet reads its configuration per call, so its two builds behave identically.
Python
Hello and GetTime are wheels holding one worker.py plus a Requires-Dist manifest. At load time the engine installs the wheel's dependencies (virtufin-* from the org index, the rest from the public index) and starts a python3 child process that calls the module-level Process(cloud_event). A crash in the child process restarts it; it never reaches the Runtime pod.
Which workers share a topic
Each worker subscribes its own topics; its command topic (wrk.<type>.command.{worker_id}) is unique to it. Every worker on a shared input topic gets every message, so a managed and a native HttpGet can run side by side on the same input for a comparison. For a switch-over, create the new worker, check it handles messages, then delete the old one.
See also
- Worker Author Guide: the files a new worker needs
- Packaging Modes: managed, native and both in one nupkg
- Build Script: how
virtufin-worker buildproduces each layout