Sha256: 55838423cbf27742da78a783f57bf670aa1e041efb176474cbf4b5a37e81f9b8

Contents?: true

Size: 1.27 KB

Versions: 11

Compression:

Stored size: 1.27 KB

Contents

module Eye::Group::Call

  # :update_config, :start, :stop, :restart, :unmonitor, :monitor, :break_chain, :delete, :signal, :user_command
  def send_call(call)
    info "call: #{call[:method]}"

    case call[:command]
      when :delete
        delete
      when :break_chain
        break_chain
      else
        user_schedule(call)
    end
  end

  def update_config(cfg)
    @config = cfg
    @full_name = nil
  end

  def start
    chained_call command: :start
  end

  def stop
    fast_call command: :stop
  end

  def restart
    chained_call command: :restart
  end

  def delete
    fast_call command: :delete
    terminate
  end

  def monitor
    chained_call command: :monitor
  end

  def unmonitor
    fast_call command: :unmonitor
  end

  def signal(sig)
    fast_call command: :signal, args: [sig]
  end

  def user_command(cmd)
    fast_call command: :user_command, args: [cmd]
  end

  def break_chain
    info 'break chain'
    scheduler_clear_pending_list
    @chain_breaker = true
  end

private

  def fast_call(call)
    command = call[:command]
    args = call[:args]
    info "send to all processes #{command} #{args.present? ? args * ',' : nil}"

    @processes.each do |process|
      process.send_call(call) unless process.skip_group_action?(command)
    end
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
eye-0.10.1.pre lib/eye/group/call.rb
eye-0.10.0 lib/eye/group/call.rb
eye-0.10.0.alpha2 lib/eye/group/call.rb
eye-0.10.0.alpha lib/eye/group/call.rb
eye-0.9.4.nosigar lib/eye/group/call.rb
eye-0.9.4 lib/eye/group/call.rb
eye-0.9.3 lib/eye/group/call.rb
eye-0.9.2.nosigar lib/eye/group/call.rb
eye-0.9.2 lib/eye/group/call.rb
eye-0.9.1 lib/eye/group/call.rb
eye-0.9.pre lib/eye/group/call.rb