ruby - How can I parallize the execution of my plugins with Celluloid? -
my question should me on right way.
i'm developing ruby application concurrent framework celluloid
. here how looks like:
i have plugins. want run them concurrently , wait until last 1 has finished. i've abstract class, called pluginframe
, inherited plugin , provides run
method.
- my idea make
supervisiongroup
, right idea? - how can run
supervisiongroup
, wait until group members have finished? - it's idea make separate
pluginpool
class, manage pool of plugins? - it's interesting me limit
pool
size, 2 or 3 plugins run @ same time.how can achieve this?
you need supervisor if plugins might crash , want celluloid restart them.
what want simple using pools , futures.
to have shared pool plugins need new actor that.
class pluginrunner include celluloid def run(plugin) plugin.run end end plugin_runner = pluginrunner.pool(size: 4) plugins = [lastfmplugin, twitterplugin] results = plugins.map {|p| plugin_runner.future.run(p) }.map(&:value) persist_results(results)
Comments
Post a Comment