Coding 2022-09-29
All right, I had some fun yesterday, time to have a bit more.
Right now, the definition I want to mess with is RuntimeAction = typing.Callable[[], typing.Awaitable[tuple[_result.Result, typing.Mapping[str, str]]]]. I want it to look more like Task = typing.Callable[[Something], typing.Awaitable[_result.Result]], where Something is an interface that takes a stream name and a stream.
So, since this stuff is pretty tightly wedded to trio internals, then we have that the "stream" argument must be a trio.abc.ReceiveStream, and there are a few operations that I want to support using them. One is for calling code to enter a stream name, and block until that stream completes, then cache and return the result. The other is to have some kind of "wrapper" implementation of the interface, that has a "prefix" that it adds to calls of the underlying implementation. So, let's suppose that stream names are non-empty tuples of strings.
And...
I got distracted by other things. So, let's plan this for later:
- New module defining the interface, and two implementations: Concrete and wrapper.
- Interface handles associating the streams to a key, and caching their data. Consumers of the interface should not interact with the stream directly after they pass it in.
- Call it StreamMultiplexer or something.
- The module goes in core.
I think this all makes sense. At least, I think so now. We'll see about later.
Good night.