socketry / async-container

Scalable multi-thread multi-process containers for Ruby.
MIT License
81 stars 4 forks source link

PoC: Introduce async-container executable #26

Closed webgago closed 8 months ago

webgago commented 2 years ago

The idea is pretty straightforward. I find this quite handy to have such tool like this:

> cat ./script.rb

before do |container, options|
  Console.logger.info(self, "=> Preparing workers...", options)
end

run do |instance, container, options|
  logger.info instance, "working..."

  loop do
    sleep 1
    if rand < 0.2
      raise "random error"
    end
  end
end

> async-container --count 5 --forked --restart ./script.rb 

What do you think about this?

P.S I'm gonna work on this a bit more.

Types of Changes

Contribution

ioquatix commented 2 years ago

It's a neat idea, I would only suggest we consider whether we should have this in the same gem, since the executable would be installed in every dependency, but honestly, I don't have a strong opinion about it yet.

webgago commented 2 years ago

@ioquatix yeah, That's what I was thinking, too. I believe it's better to make a separate gem. I put pretty much everything inside the Command to minimise impact to the gem. But it's definitely better to move code to proper files/classes. How do we go about this idea? Do you mind creating a new repo for me?

webgago commented 2 years ago

Hi @ioquatix

I've implemented a separate gem - https://github.com/webgago/async-runner Do you think it's worth moving it to socketry organisation?

ioquatix commented 9 months ago

I might revisit this specific proposal, but I've introduced https://github.com/socketry/async-service which manages one or more service classes being run using async-container.