Sha256: 73f8395375f6a4de29dd9f7e6ca47269f9e729db3a358d0ae9968af333ee7998

Contents?: true

Size: 663 Bytes

Versions: 4

Compression:

Stored size: 663 Bytes

Contents

# A shim for submitting jobs to the queue. Accepts a connection
# (something that responds to `#send_message`)
# and the serializer (something that responds to `#serialize`) to
# convert the job into the string that will be put in the queue.
class Sqewer::Submitter < Struct.new(:connection, :serializer)
  
  # Returns a default Submitter, configured with the default connection
  # and the default serializer.
  def self.default
    new(Sqewer::Connection.default, Sqewer::Serializer.default)
  end
  
  def submit!(*jobs, **kwargs_for_send)
    jobs.each do | job |
      connection.send_message(serializer.serialize(job), **kwargs_for_send)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sqewer-2.0.2 lib/sqewer/submitter.rb
sqewer-2.0.1 lib/sqewer/submitter.rb
sqewer-2.0.0 lib/sqewer/submitter.rb
sqewer-1.0.0 lib/sqewer/submitter.rb