some temporal learnings

temporal doesn’t have an official sdk in rust, but they have one in go, python, and typescript. so thursday afternoon, i started creating one from scratch with the grpc protobuf. what’s left is you basically need to create a state machine when processing temporal events and workflows (because workflows have to be replayable and deterministic). and i know that in rust, all async code gets compiled into a state machine, so you could write your own future to do temporal replays, which will let you write normal “async” rust code, and you would get a valid temporal workflow processor.

so anyway, turns out temporal already kinda does that. they actually base all of their sdks off of a rust “core” which does exactly what i’m doing, just obviously more refined. but they compile that and use FFI from go, python, and typescript, to do all their workflow processing with rust because of the same reasons i was doing it: you can use rust to create/manage your “state machine”

but i learned a lot about temporal. basically their whole thing is they have a “workflow” server, where each workflow maintains a rigid history of events. but the contract is supposed to be that for any workflow worker, when it picks up an event for a workflow, it needs to be able to deterministically rebuild the state from the order of events. which i guess that’s how it gets a lot of its resiliency and such and why some workflows can live for very long and be run off of any worker.

but what was really cool is that, since everything was a future, i could use thigns like futures::join! and futures::select! and everything still worked and felt really natural. i wonder why they never bothered to publish a rust sdk for temporal.