core-async

camdez 2025-03-25T03:00:55.853679Z

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!

camdez 2025-03-25T13:52:19.971549Z

@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.

Alex Miller (Clojure team) 2025-03-25T15:27:06.309419Z

command-proc (sync) and inject (async) send commands to the control channel of a proc (with name ::flow/control)

Alex Miller (Clojure team) 2025-03-25T15:27:24.031689Z

or at least that is the idea

Alex Miller (Clojure team) 2025-03-25T15:30:43.170259Z

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

camdez 2025-03-25T15:37:42.288969Z

@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?

camdez 2025-03-25T15:41:10.383889Z

Or do they simply arrive as normal messages? In which case I suspect this might not yet be implemented in what has been released.

Alex Miller (Clojure team) 2025-03-25T15:41:15.707279Z

it's returned from start

Alex Miller (Clojure team) 2025-03-25T15:41:32.977659Z

oh you're asking different question

camdez 2025-03-25T15:41:50.560319Z

Yes, at the process level

camdez 2025-03-25T15:41:58.075369Z

Is what I’m wondering about

Alex Miller (Clojure team) 2025-03-25T15:42:34.531439Z

I guess control messages are visible to the proc but not to the function?

camdez 2025-03-25T15:47:39.495849Z

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?

Alex Miller (Clojure team) 2025-03-25T15:48:24.726389Z

yeah, you would need a custom proc impl right now to do something with custom control messages

👍 1
Alex Miller (Clojure team) 2025-03-25T15:50:12.761989Z

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

camdez 2025-03-25T15:50:50.269629Z

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.

Alex Miller (Clojure team) 2025-03-25T15:51:21.611319Z

I think these are reasonable things to want :)

camdez 2025-03-25T15:52:07.710039Z

Fantastic. Well, as always, I greatly appreciate your time and efforts in the community.

Alex Miller (Clojure team) 2025-03-25T15:52:30.330409Z

I'll give that feedback to Rich, thx

🙂 2
2025-04-08T17:42:33.173639Z

custom commands (via command-proc) are gone, please create and use regular inputs if your procs need command flow

2025-03-25T03:26:13.962349Z

I am not sure if it is correctly wired up though in the code though

2025-03-25T03:29:13.807429Z

It might end up getting sent to the transition arity of a process created with prpc