Class: Qswarm::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/qswarm/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(agent, name, args, &block) ⇒ Connection

Returns a new instance of Connection.



5
6
7
8
9
10
11
12
# File 'lib/qswarm/connection.rb', line 5

def initialize(agent, name, args, &block)
  @agent      = agent
  @name       = name
  @args       = args
  @on_connect = block_given? ? block : false

  @format     = args[:format] || :raw
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



3
4
5
# File 'lib/qswarm/connection.rb', line 3

def format
  @format
end

Instance Method Details

#emit(payload) ⇒ Object



14
15
16
# File 'lib/qswarm/connection.rb', line 14

def emit(payload)
  @agent.emit(@name, :payload => OpenStruct.new(:raw => payload, :format => @format))
end

#runObject



22
23
# File 'lib/qswarm/connection.rb', line 22

def run
end

#sink(args, payload) ⇒ Object



18
19
20
# File 'lib/qswarm/connection.rb', line 18

def sink(args, payload)
  Qswarm.logger.info ">>> #{payload.raw}"
end