Class: Norikra::Client
- Inherits:
-
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: Admin, CLI, Event, Field, Query, Target
Constant Summary
collapse
- RPC_DEFAULT_PORT =
26571
- TIMEOUT_OPTIONS =
[:connect_timeout, :send_timeout, :receive_timeout]
- VERSION =
"0.1.5"
Instance Method Summary
collapse
-
#close(target) ⇒ Object
-
#deregister(query_name) ⇒ Object
-
#event(query_name) ⇒ Object
-
#fields(target) ⇒ Object
-
#initialize(host = 'localhost', port = RPC_DEFAULT_PORT, opts = {}) ⇒ Client
constructor
A new instance of Client.
-
#modify(target, auto_field) ⇒ Object
-
#open(target, fields = nil, auto_field = true) ⇒ Object
-
#queries ⇒ Object
-
#register(query_name, query_group, query_expression) ⇒ Object
-
#reserve(target, field, type) ⇒ Object
-
#see(query_name) ⇒ Object
-
#send(target, events) ⇒ Object
-
#sweep(query_group = nil) ⇒ Object
-
#targets ⇒ Object
Constructor Details
#initialize(host = 'localhost', port = RPC_DEFAULT_PORT, opts = {}) ⇒ Client
Returns a new instance of Client.
15
16
17
18
19
20
21
|
# File 'lib/norikra/client.rb', line 15
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
31
32
33
|
# File 'lib/norikra/client.rb', line 31
def close(target)
@client.call(:close, target)
end
|
#deregister(query_name) ⇒ Object
47
48
49
|
# File 'lib/norikra/client.rb', line 47
def deregister(query_name)
@client.call(:deregister, query_name)
end
|
#event(query_name) ⇒ Object
64
65
66
|
# File 'lib/norikra/client.rb', line 64
def event(query_name)
@client.call(:event, query_name)
end
|
#fields(target) ⇒ Object
51
52
53
|
# File 'lib/norikra/client.rb', line 51
def fields(target)
@client.call(:fields, target)
end
|
#modify(target, auto_field) ⇒ Object
35
36
37
|
# File 'lib/norikra/client.rb', line 35
def modify(target, auto_field)
@client.call(:modify, target, auto_field)
end
|
#open(target, fields = nil, auto_field = true) ⇒ Object
27
28
29
|
# File 'lib/norikra/client.rb', line 27
def open(target, fields=nil, auto_field=true)
@client.call(:open, target, fields, auto_field)
end
|
#queries ⇒ Object
39
40
41
|
# File 'lib/norikra/client.rb', line 39
def queries
@client.call(:queries)
end
|
#register(query_name, query_group, query_expression) ⇒ Object
43
44
45
|
# File 'lib/norikra/client.rb', line 43
def register(query_name, query_group, query_expression)
@client.call(:register, query_name, query_group, query_expression)
end
|
#reserve(target, field, type) ⇒ Object
55
56
57
|
# File 'lib/norikra/client.rb', line 55
def reserve(target, field, type)
@client.call(:reserve, target, field, type)
end
|
#see(query_name) ⇒ Object
69
70
71
|
# File 'lib/norikra/client.rb', line 69
def see(query_name)
@client.call(:see, query_name)
end
|
#send(target, events) ⇒ Object
59
60
61
|
# File 'lib/norikra/client.rb', line 59
def send(target, events)
@client.call(:send, target, events)
end
|
#sweep(query_group = nil) ⇒ Object
74
75
76
|
# File 'lib/norikra/client.rb', line 74
def sweep(query_group=nil)
@client.call(:sweep, query_group)
end
|
#targets ⇒ Object
23
24
25
|
# File 'lib/norikra/client.rb', line 23
def targets
@client.call(:targets) end
|