katzer / mruby-shelf

Modular webserver interface for mruby
MIT License
24 stars 4 forks source link

Ways to run background jobs #4

Open rguiscard opened 5 months ago

rguiscard commented 5 months ago

Is there an easy way to run background job (blocking or non-blocking is fine; maybe use fiber;) similar to ActiveJob in Rails? I understand it may not fit what mruby-shelf does, but it does provide some convenience. For example, a way to insert a middleware which will be called every 1 second or so. The simplehttpserver seems able to run in non-blocking mode, but I don't see how it works with mruby-shelf in non-blocking mode.

One use case that a mruby application periodically reads values from sensors (temperature, humidity, etc.) and provides a web interface for user. It keeps records of measurements for every second. Users can use web browser to get these records occasionally.

Thanks.

katzer commented 4 months ago

Hi @rguiscard I see your use case but where's the connection between background jobs and mruby-shelf? The external webserver needs to listen in non-blocking mode, some background job can collect data independent of the lifecycle of the webserver and whenever a user requests comes in, the webserver will call the rack app to get the response.