class Citrus::Components::PushScheduler

PushScheduler

Public Class Methods

new(app, args={}) click to toggle source

Initialize the component

@param [Object] app @param [Hash] args

# File lib/citrus/components/push_scheduler.rb, line 23
def initialize app, args={}
  @app = app
  @scheduler = get_scheduler app, args
end

Public Instance Methods

after_start(&block) click to toggle source

Component lifecycle callback

# File lib/citrus/components/push_scheduler.rb, line 29
def after_start &block
  if @scheduler.respond_to? :start
    @scheduler.start &block
  else
    EM.next_tick { block.call } if block_given?
  end
end
schedule(req_id, route, msg, recvs, args, &block) click to toggle source

Schedule how the message to send

@param [Integer] req_id @param [String] route @param [Hash] msg @param [Array] recvs @param [Hash] args

# File lib/citrus/components/push_scheduler.rb, line 53
def schedule req_id, route, msg, recvs, args, &block
  if @scheculer.respond_to? :schedule
    @scheduler.schedule req_id, route, msg, recvs, args, &block
  else
  end
end
stop(&block) click to toggle source

Component lifecycle callback

# File lib/citrus/components/push_scheduler.rb, line 38
def stop &block
  if @scheduler.respond_to? :stop
    @scheduler.stop &block
  else
    EM.next_tick { block.call } if block_given?
  end
end

Private Instance Methods

get_scheduler(app, args={}) click to toggle source

Get scheduler

@param [Object] app @param [Hash] args

@private

# File lib/citrus/components/push_scheduler.rb, line 68
def get_scheduler app, args={}
  scheduler = args[:scheduler] || Citrus::PushSchedulers::Direct
  scheduler.new app, args
end