Class: Norikra::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/norikra/client.rb,
lib/norikra/client/cli.rb,
lib/norikra/client/version.rb

Defined Under Namespace

Modules: CLIUtil Classes: CLI, Event, Field, Query, Target

Constant Summary collapse

RPC_DEFAULT_PORT =
26571
TIMEOUT_OPTIONS =
[:connect_timeout, :send_timeout, :receive_timeout]
VERSION =
"0.0.4"

Instance Method Summary collapse

Constructor Details

#initialize(host = 'localhost', port = RPC_DEFAULT_PORT, opts = {}) ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
15
16
# File 'lib/norikra/client.rb', line 10

def initialize(host='localhost', port=RPC_DEFAULT_PORT, opts={})
  @client = MessagePack::RPCOverHTTP::Client.new("http://#{host}:#{port}/")

  @client.connect_timeout = opts[:connect_timeout] if opts.has_key?(:connect_timeout) && @client.respond_to?('connect_timeout='.to_sym)
  @client.send_timeout    = opts[:send_timeout]    if opts.has_key?(:send_timeout)    && @client.respond_to?('send_timeout='.to_sym)
  @client.receive_timeout = opts[:receive_timeout] if opts.has_key?(:receive_timeout) && @client.respond_to?('receive_timeout='.to_sym)
end

Instance Method Details

#close(target) ⇒ Object



26
27
28
# File 'lib/norikra/client.rb', line 26

def close(target)
  @client.call(:close, target)
end

#deregister(query_name) ⇒ Object



38
39
40
# File 'lib/norikra/client.rb', line 38

def deregister(query_name)
  @client.call(:deregister, query_name)
end

#event(query_name) ⇒ Object

[time, event], …


55
56
57
# File 'lib/norikra/client.rb', line 55

def event(query_name)
  @client.call(:event, query_name)
end

#fields(target) ⇒ Object



42
43
44
# File 'lib/norikra/client.rb', line 42

def fields(target)
  @client.call(:fields, target)
end

#open(target, fields = nil) ⇒ Object



22
23
24
# File 'lib/norikra/client.rb', line 22

def open(target, fields=nil)
  @client.call(:open, target, fields)
end

#queriesObject



30
31
32
# File 'lib/norikra/client.rb', line 30

def queries
  @client.call(:queries)
end

#register(query_name, query_expression) ⇒ Object



34
35
36
# File 'lib/norikra/client.rb', line 34

def register(query_name, query_expression)
  @client.call(:register, query_name, query_expression)
end

#reserve(target, field, type) ⇒ Object



46
47
48
# File 'lib/norikra/client.rb', line 46

def reserve(target, field, type)
  @client.call(:reserve, target, field, type)
end

#send(target, events) ⇒ Object



50
51
52
# File 'lib/norikra/client.rb', line 50

def send(target, events)
  @client.call(:send, target, events)
end

#sweepObject

=> [ [time, event], … ]



60
61
62
# File 'lib/norikra/client.rb', line 60

def sweep
  @client.call(:sweep)
end

#targetsObject



18
19
20
# File 'lib/norikra/client.rb', line 18

def targets
  @client.call(:targets)
end