A friend and I spent a couple hours over the weekend pair programming and kicking the tires on c.c.a.flow. We’re both pretty excited about it but ended up with a couple questions we couldn’t get to the bottom of in the time we had and I wonder if anyone here could lend any insight:
1. The docs for c.c.a.flow/command-proc mention that it’s possible to send “process-specific command”(s) to individual processes, but we couldn’t figure out how to receive these. Is this implemented today? (Does this possibly mean commands specific to a custom implementation of c.c.a.f.spi/ProcLauncher, or does it mean I can send a command like ::foo/reset that a given process can handle, regardless of the underlying ProcLauncher?)
2. Are there per process error and report connections / ports that can be tapped into? How can these be accessed? Are they connections (`:conn` entries) or ports (channels)? In Alex’s FnConf talk (https://youtu.be/A7CcTaVC1d4?si=gSRXIZd6uBHKe3Jn&t=1998) there’s a slide showing a diagram of process “wiring” that seems to imply this is possible.
Thanks!
@hiredman Thanks for the response. That is, indeed, the function I’m talking about. When sending a command to a process, the 2-arity “transition” function did not seem to receive the command (I printed all received transition messages). I assume that’s what you mean by “prpc”. Did not seem to work.
command-proc (sync) and inject (async) send commands to the control channel of a proc (with name ::flow/control)
or at least that is the idea
every proc has ::flow/error and ::flow/report output ports but those are all the f same flow error and report channel (returned from flow start). we've had some discussion about whether to put proc identifiers in those messages, I don't remember if Rich did that work already or if that is still todo/under consideration
@alexmiller Thank you. On the latter piece, I can confirm that (at least) the error messages contain a :pid.
On the former, I’m unsure how a proc reads from that ::flow/control channel. Will it be passed to the :init (arity-1) function via the arg-map parameter? Or is it more like ::flow/in-ports / ::flow/out-ports where the process returns a channel itself in the :describe operation?
Or do they simply arrive as normal messages? In which case I suspect this might not yet be implemented in what has been released.
it's returned from start
oh you're asking different question
Yes, at the process level
Is what I’m wondering about
I guess control messages are visible to the proc but not to the function?
That appears, to me, to be correct, but I haven’t gone through the code all that carefully. So a custom implementation of spi/ProcLauncher would be necessary to access those control messages today, if I understand correctly.
That is what motivated the part of my original question where I asked about “commands specific to a custom implementation”—perhaps, semantically, control messages are meant to be handled by different implementations of spi/ProcLauncher s, and not exactly “process-specific” (as the docs say), but rather process-launcher-specific?
yeah, you would need a custom proc impl right now to do something with custom control messages
you can of course make your own control ins and give them to all the procs and do whatever you want, although I don't think you get the priority level with that
Totally fair. I think I see utility in being able to implement control messages easily for procs (running via the default launcher). … yep, you anticipated my question, so I suppose I’ll leave it there. Ability to jump the queue of “normal” messages seems valuable.
I think these are reasonable things to want :)
Fantastic. Well, as always, I greatly appreciate your time and efforts in the community.
I'll give that feedback to Rich, thx
custom commands (via command-proc) are gone, please create and use regular inputs if your procs need command flow
https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async/flow.clj#L138
I am not sure if it is correctly wired up though in the code though
It might end up getting sent to the transition arity of a process created with prpc