README.markdown in tennis-jobs-0.3.0 vs README.markdown in tennis-jobs-0.3.1

- old
+ new

@@ -12,11 +12,11 @@ - Serializers: `.serialize(loader:)` - Helpers for defering method calls: `object.defer.method(*arguments)` **Extra** -- A `GenericSerializer` handling classes and ActiveRecord objects +- A `Tennis::Serializer::Generic` handling classes and ActiveRecord objects ## Configuration The background job require a group of processes to handle the tasks you want to do asynchronously. Tennis uses YAML configuration file in order to launch thoses @@ -55,11 +55,11 @@ BeforeFork = -> { ActiveRecord::Base.connection_pool.disconnect! rescue nil } AfterFork = -> { ActiveRecord::Base.establish_connection } end class MyClass - include GenericWorker + include Tennis::Worker::Generic set_option :before_fork, WorkerHelpers::BeforeFork set_option :after_fork, WorkerHelpers::AfterFork set_option :handler, Sneakers::Handlers::MaxretryWithoutErrors @@ -77,17 +77,17 @@ ## Examples Those examples are what we wish to achieve. The name of the queue is the name of the class by default and can be reset -using sneakers' `YourClass.worker.from_queue` method. +using `set_option :queue_name, "your-queue-name"`. ### Hooks ``` ruby class MyClass - include GenericWorker + include Tennis::Worker::Generic before do puts "Before processing" end @@ -109,11 +109,11 @@ the `message` as argument. It should return a string. The loader will be used when the message is poped from the RabbitMQ queue. ``` ruby class MyClass - include GenericWorker + include Tennis::Worker::Generic serialize loader: ->(message){ JSON.parse(message) }, dumper: ->(message){ JSON.generate(message) } work do |message| @@ -129,13 +129,13 @@ # => one: 1, two: foo ``` ``` ruby class MyClass - include GenericWorker + include Tennis::Worker::Generic - serialize GenericSerializer.new + serialize Tennis::Serializer::Generic.new work do |message| klass, active_record_object = message puts "Classes can be passed: #{klass.name} - #{klass.class}" puts "Active record object can be passed too: #{active_record_object}" @@ -152,11 +152,11 @@ Any class method can be defered: ``` ruby class MyClass - include DeferableWorker + include Tennis::Worker::Deferable def self.my_method(user) puts "Running my method on #{user}" end end @@ -167,11 +167,11 @@ An ActiveRecord::Base instance can be the receiver if it has an `id`: ``` ruby class MyModel < ActiveRecord::Base - include DeferableWorker + include Tennis::Worker::Deferable def my_method puts "Running my method on #{self}" end end @@ -185,10 +185,10 @@ `on_success` keyword. You must return `ack!` or `reject!` here as in a Sneakers' `work` method. ``` ruby class MyModel < ActiveRecord::Base - include DeferableWorker + include Tennis::Worker::Deferable on_error do |exception| puts "I just saved the day handling a #{exception}" reject! end