Skip to content

mobmewireless/async_service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

AsyncService provides an abstraction for workers/daemons that processes work from a queue. Often an AsyncService::Worker will get work from a queue, process it and push the result back into another queue.

You can also take a look at SyncService which provides abstractions for synchronous SOA.

Install

$ gem install async_service

Creating a Worker

class CalculatorMachine < AsyncService::Worker
  # You need to set a service name
  @service_name = 'in.mobme.calculator_machine'

  # This function is called on run
  def work
    loop do
      queue.remove("work_queue") do |item|
        result = item[:a] + item[:b]

        queue.add("result_queue", result)
      end
      sleep 5
    end
  end
end

calculator = CalculatorMachine.new
calculator.run

About

AsyncService is a library to create asynchronous SOA daemons

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages