gloo icon indicating copy to clipboard operation
gloo copied to clipboard

Feature request: async gloo worker example

Open gilescope opened this issue 3 years ago • 3 comments

Summary

Current gloo worker examples are all synchronous. It would be good to provide an example of using it in as async friendly way as possible. It maybe that we need to adapt the current gloo worker design to be more async friendly (passing worker scope around could be problematic for being able to return messages back from inside async functions?).

Motivation

If people want to use async then this example will make it easier for them to get started and will show them a good path. Otherwise people will fumble in the dark and it will take them a long time.

Detailed Explanation

I don't know how this would look like alas... is there any prior art / examples that we can look at?

Unresolved Questions

Ideally dodge having to make an async runtime choice - just pick one in the example.

gilescope avatar Aug 25 '22 07:08 gilescope

E.g. I'm assuming that in a worker received fn, it's probably not a great idea to do async_std::task::block_on( to kick off being async...

gilescope avatar Aug 25 '22 08:08 gilescope

You should be able to use WorkerScope::send_future to spawn a task.

passing worker scope around could be problematic.

You can choose to return a message for send_future and send back output in fn update() lifecycle event or clone WorkerScope to respond to bridges directly in the future.

futursolo avatar Sep 04 '22 11:09 futursolo

You can clone worker scope? Ok that makes life easier!!!

gilescope avatar Sep 04 '22 18:09 gilescope