Passing data between child processes? #2
ash-jc-allen
started this conversation in
Ideas
Replies: 1 comment 3 replies
-
I've actually just added a small section to the README addressing this issue: https://github.com/spatie/fork#returning-data In summary: this package offers a simple way of communication from the child to the parent, with a size limitation of 1024 bytes. If you need anything more than that, you'll want to use some kind of persistent layer like a cache, Redis, database, filesystem, … We've done this intentionally to keep the design of the package simple. On top of that, you can get individual child output in the after method: $results = Fork::new()
->after(
parent: fn (int $i) => echo $i, // 1, 2 and 3
)
->run(
fn () => 1,
fn () => 2,
fn () => 3,
); I haven't looked deep into your implementation, but maybe this is enough to solve you problem? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey! I've been giving this package a little try-out and threw together a quick little proof-of-concept package that you can use for adding loading spinners to Artisan commands (https://github.com/ash-jc-allen/laravel-command-spinner). I basically trigger one process to handle the loading spinner animation and one process to carry out the actual code that someone wants to run (e.g. - fetching data from an API).
The loading spinner seems to work really nicely on the surface, but I'm not too keen on how I'm managing the state of whether it should be spinning or not. I'm having to use the cache to toggle the spinner's state because it's the only way I could think of being able to share data between the 2 child processes that I'm spawning.
I don't know if you're open to ideas (or if it's something that's even possible), but It'd be pretty cool if there was a way of sharing data between the two processes. So, I'd then be able to stop the loading spinner in one child process after the other code has finished executing in another child process.
Maybe this is something that's already possible and I didn't realise? Or maybe it's not possible at all? I'd love to hear your thoughts on it though if you had any cool ideas 😄
Beta Was this translation helpful? Give feedback.
All reactions