How can I hide the execution of my plugins with Celluloid?

My question should help me on the right track.

I am developing a ruby ​​application with a parallel structure celluloid. Here's what it looks like:

activity

I have plugins. I want to run them at the same time and wait for the last to finish. I have an abstract class called PluginFramethat is inherited by the whole plugin and which also provides a method run.

  • My idea was to do SupervisionGroup, but is this the right idea?
  • How to start SupervisionGroupand wait for the end of all members of the group?
  • It is recommended to create a separate class PluginPoolto manage the pool of plugins?
  • pool, . ?
+4
1

, , , .

, , , .

, .

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)
+4

Source: https://habr.com/ru/post/1525585/


All Articles