norikra-client-jruby 0.0.9-java → 0.1.0-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 742acdfe054dfdb6cce4b55d94fcea2fae7179d5
4
- data.tar.gz: 0cc945ef6b4deed710cfc883c584bad0a8909824
3
+ metadata.gz: 10de160e6bd3033f77a96ede852709beead02f7f
4
+ data.tar.gz: 4e1e01377dc51eec87228bf840f466b43df87f9b
5
5
  SHA512:
6
- metadata.gz: 14aa9b34b25f7efc0af012416431836972420b21da13f0589ebc7cfe43253bb573c67a9be45a06f93f9fb84975e2bb5d89072452bf357eea07be7311925bd2a0
7
- data.tar.gz: b1b2ddabd14eb7b9d898daadbc1c8f71d394f57aec6320976e497a85a0a26591081eb9da42feed3523bcd92f0a878ce8f6e5cf78068b72cb17ad54fd9e32f4a2
6
+ metadata.gz: e59b012082cef26e8c780e78271781aef4d65a60e6120e880dcd791cbfd06fb5b8572b78c7c9ae63165758595d07cb8978fa366a46bc3fb6650c346c8403e657
7
+ data.tar.gz: 2383ce078a4532bef29bd68d2538ddfbd98901e6e48414d52ea090d91174bfc70c2b5b1956ed26d0867ed64018e83ae276f0d23cdb1bd529e38db43317348dae
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  This is the client library implementation for Norikra, and its handy CLI commands.
4
4
 
5
5
  `Norikra` is CEP server, based on Esper. You can install `gem install norikra` on your JRuby.
6
- For more information, see https://github.com/tagomoris/norikra .
6
+ For more information, see http://norikra.github.io .
7
7
 
8
8
  Command `norikra-client` and module `Norikra::Client` are provided for both of CRuby and JRuby.
9
9
 
@@ -19,10 +19,11 @@ Command `norikra-client` have some subcommands.
19
19
  norikra-client -h
20
20
  Commands:
21
21
  norikra-client event CMD ...ARGS # send/fetch events
22
- norikra-client help [COMMAND] # Describe available commands or one specific command
23
22
  norikra-client query CMD ...ARGS # manage queries
24
23
  norikra-client target CMD ...ARGS # manage targets
25
- norikra-client typedef CMD ...ARGS # manage table field/datatype definitions
24
+ norikra-client field CMD ...ARGS # manage table field/datatype definitions
25
+
26
+ norikra-client help [COMMAND] # Describe available commands or one specific command
26
27
 
27
28
  Options:
28
29
  [--host=HOST]
@@ -41,17 +42,130 @@ In your programs, you can operate Norikra with Norikra::Client instances.
41
42
  client = Norikra::Client.new # connect to localhost:26571
42
43
  # client = Norikra::Client.new(hostname, portnum)
43
44
 
44
- ### Instance methods
45
+ ## API
45
46
 
46
- TBD
47
+ ### Norikra::Client.new(host, port, options={})
47
48
 
48
- ## Versions
49
+ Instanciate with server's hostname and port number.
50
+
51
+ require 'norikra-client'
52
+ client = Norikra::Client.new('norikra.server.local', 26571)
53
+
54
+ Timeout options are available:
55
+
56
+ client = Norikra::Client.new(
57
+ 'norikra.server.local',
58
+ 26571,
59
+ connect_timeout: 3, send_timeout: 1, receive_timeout: 3
60
+ )
61
+
62
+ ### Norikra::Client#targets
63
+
64
+ Returns list of hashes, which contains `name`(string) and `auto_fields`(true/false) of each targets.
65
+
66
+ client.targets #=> [{'name' => "demo", 'auto_field' => false}, {'name' => "sample", 'auto_field' => true}]
67
+
68
+ ### Norikra::Client#open(target_name, fields=nil, auto_field=true)
69
+
70
+ Create new target on norikra server, to put events and queries. Returns true or false (successfully created, or already exists).
71
+
72
+ client.open('sample') #=> true
73
+
74
+ Without fields, the specified target will be opend as 'lazy' mode, and actually opend when first input event arrived. Default field set will be determined at that time.
75
+
76
+ With field definitions, `#open()` creates the target and actually opens it immediately.
77
+
78
+ client.open('sample', {id:'long', name:'string', age:'int', email:'string'})
79
+
80
+ Fiels specified on `#open()` are configured as default field set.
81
+
82
+ `auto_field` means which fields in arrived events are automatically added on field list, or not. Default is true.
83
+ `auto_field: true` helps you to know What fields input event streams have. You can watch fields list on norikra, and write queries. But in cases your input streams have great many field name patterns, norikra returns long list of field names. That is not understandable. In these cases, you should specify `auto_field false`.
84
+
85
+ In spite of `auto_field false`, norikra server adds fields which are used in registered queries automatically.
86
+
87
+ ### Norikra::Client#close
88
+
89
+ Close the specified target. Norikra server stops all queries with that target.
90
+
91
+ client.close('sample') #=> true
92
+
93
+ ### Norikra::Client#modify(target_name, auto_field)
94
+
95
+ Modify the specified target configuration of auto_field.
96
+
97
+ client.modify('sample', false) #=> true
98
+
99
+ ### Norikra::Client#queries
100
+
101
+ Returns a list of hashes which contains `name`, `group`, `expression` and `targets` of registered queries.
49
102
 
50
- TBD
103
+ client.queries #=> [{'name' => 'q1', 'group' => nil, 'expression' => 'select count(*) from sample ...', 'targets' => ['sample']}]
51
104
 
52
- ## TODO
105
+ Attributes of query:
106
+ * `name`: the name of query, that must be unique on norikra server
107
+ * `group`: the group name of query to be used in `sweep` call to fetch all events of queries with same `group` name (nil: default)
108
+ * `expression`: SQL expression
109
+ * `targets`: list of targets, which are referred in this SQL (2 or more targets by JOINs and SubQueries)
110
+
111
+ ### Norikra::Client#register(query_name, query_group, query_expression)
112
+
113
+ Add query to norikra server. Query will be started immediately if all required targets/fields exists. If not, query actually starts when events arrived with all required fields.
114
+
115
+ client.register('q1', nil, 'select count(*) from sample.win:time_batch(1 min) where age >= 20') #=> true
116
+
117
+ ### Norikra::Client#deregister(query_name)
118
+
119
+ Stop and remove specified query immediately.
120
+
121
+ client.deregister('q1') #=> true
122
+
123
+ ### Norikra::Client#fields(target)
124
+
125
+ Returns the list of fields definitions, which contains `name`(string), `type`(string) and `optional`(true/false).
126
+
127
+ client.fields('sample') #=> [{'name' => 'id', 'type' => 'int', 'optional' => false}, ...]
128
+
129
+ NOTE: Hashes and arrays are just returned as 'hash' and 'array'. Nested fields and these types are not returned to client.
130
+
131
+ ### Norikra::Client#reserve(target, field_name, type)
132
+
133
+ Specify the type of field, which not arrived yet.
134
+
135
+ client.reserve('sample', 'phone', 'string') #=> true
136
+
137
+ This api is useful for fields, which has int data at a time, and has string data at the other time. Norikra determines fields' type at the first time with that field, and format input data by determined type.
138
+ If you want to parse as int for a field but that field's value may be either String or Integer, you should do `reserve()` to determine it as `int`.
139
+
140
+ ### Norikra::Client#send(target, events)
141
+
142
+ Send list of input events into norikra server.
143
+
144
+ client.send('sample', [record1, record2, record3])
145
+
146
+ Members of events should be hash instance, which has a field at least.
147
+ Field values must be able to be serialized with MessagePack. Safe with String, Integer, Float, true/false/nil, Hash and Array.
148
+
149
+ ### Norikra::Client#event(query_name)
150
+
151
+ Fetch events of specified query's output. Returns a list of `[time, event]`.
152
+
153
+ client.event('q1') #=> [ [1383297109,{"count(*)":50}], [1383297169,{"count(*)":37}], ... ]
154
+
155
+ The first value of returned pairs is the time of output event as unix time (seconds from epoch).
156
+ The second value is output record of query as Hash.
157
+
158
+ ### Norikra::Client#sweep(query_group=nil)
159
+
160
+ Fetch all output events of queries of specified group. `query_group: nil` means default query group. Returns Hash instance like `'query_name' => [list of output (same as #event)]`
161
+
162
+ client.fetch() #=> for default group
163
+ client.fetch('my_secret_group')
164
+
165
+ ## Versions
53
166
 
54
- * TBD
167
+ * v0.1.0:
168
+ * First release for production
55
169
 
56
170
  ## Copyright
57
171
 
@@ -1,5 +1,5 @@
1
1
  module Norikra
2
2
  class Client
3
- VERSION = "0.0.9"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: norikra-client-jruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: java
6
6
  authors:
7
7
  - TAGOMORI Satoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-24 00:00:00.000000000 Z
11
+ date: 2013-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack-rpc-over-http-jruby