async-container icon indicating copy to clipboard operation
async-container copied to clipboard

PoC: Introduce async-container executable

Open webgago opened this issue 3 years ago • 2 comments

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

  • New feature.

Contribution

webgago avatar Oct 20 '22 18:10 webgago

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.

ioquatix avatar Oct 21 '22 02:10 ioquatix

@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 avatar Oct 21 '22 05:10 webgago

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?

webgago avatar Nov 22 '22 14:11 webgago

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.

ioquatix avatar Feb 24 '24 08:02 ioquatix