reindexer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b1356871b0a5fd7b52535aeccfd3e89321f52258f35bd2af5095364e5cfb0033
4
+ data.tar.gz: bff0c1f6e1aa496457f92a882990c976969bbb6eba507f1c8d1ef3bc622e5976
5
+ SHA512:
6
+ metadata.gz: 8b7787b34cc55fdee044122bddaabeaa6a381ccffda43e02f97e638b1d3b78f37721a9c408ba1c170575452f7fae586890326586f58cb915726c1dde5d4f6205
7
+ data.tar.gz: 5b90659aa0e305003f7697d70cf5ac6f7faf7752695d9580fe0fc0549e0cef17d66d51ba6679a925aaf3915b856eae8bdd02b7f109b5dfe81aa52843b110bdb6
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+ ### Added
data/LICENSE.txt ADDED
@@ -0,0 +1,15 @@
1
+ Apache-2.0
2
+
3
+ Copyright 2021 Andrei Subbota
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ [![Gem](https://img.shields.io/gem/v/reindexer.svg)](https://rubygems.org/gems/reindexer/)
2
+ ![Reindexer](https://github.com/numbata/reindexer-ruby/actions/workflows/main.yml/badge.svg)
3
+
4
+ # Reindexer
5
+
6
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/reindexer`. To experiment with that code, run `bin/console` for an interactive prompt.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'reindexer'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install reindexer
23
+
24
+ ## Usage
25
+
26
+ client = ReindexerGrpc::Client.new('grpc://reindexer:16534')
27
+
28
+ client.create_database(db_name: 'test_db')
29
+ client.open_namespace(db_name: 'test_db', storage_options: {ns_name: 'items'})
30
+ client.add_index(db_name: 'test_db', ns_name: 'items', definition: {
31
+ name: 'id',
32
+ json_paths: ['id'],
33
+ index_type: 'hash',
34
+ field_type: 'int',
35
+ options: {
36
+ is_pk: true,
37
+ is_array: false,
38
+ is_dense: false,
39
+ is_sparse: false,
40
+ collate_mode: 'CollateUTF8Mode',
41
+ sort_order_labled: '',
42
+ config: ''
43
+ },
44
+ expire_after: nil
45
+ })
46
+
47
+ client.modify_item([
48
+ {db_name: 'test_db', ns_name: 'items', mode: :UPSERT, data: JSON.dump(id: 1, name: 'Name')},
49
+ {db_name: 'test_db', ns_name: 'items', mode: :UPSERT, data: JSON.dump(id: 2, name: 'BestName')}
50
+ ])
51
+ stream = client.select_sql(db_name: 'test_db', sql: 'SELECT * FROM items', output_flags: {with_rank: true})
52
+
53
+
54
+ ## Development
55
+
56
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
57
+
58
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
59
+
60
+ ## Contributing
61
+
62
+ Bug reports and pull requests are welcome on GitHub at https://github.com/numbata/reindexer-ruby.
63
+
64
+ ## License
65
+
66
+ The gem is available as open source under the terms of the [Apache-2.0](https://opensource.org/licenses/Apache-2.0)
@@ -0,0 +1,345 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: reindexer-grpc.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ Google::Protobuf::DescriptorPool.generated_pool.build do
7
+ add_file("reindexer-grpc.proto", :syntax => :proto3) do
8
+ add_message "reindexer.grpc.ErrorResponse" do
9
+ optional :code, :enum, 1, "reindexer.grpc.ErrorResponse.ErrorCode"
10
+ optional :what, :string, 2
11
+ end
12
+ add_enum "reindexer.grpc.ErrorResponse.ErrorCode" do
13
+ value :errCodeOK, 0
14
+ value :errCodeParseSQL, 1
15
+ value :errCodeQueryExec, 2
16
+ value :errCodeParams, 3
17
+ value :errCodeLogic, 4
18
+ value :errCodeParseJson, 5
19
+ value :errCodeParseDSL, 6
20
+ value :errCodeConflict, 7
21
+ value :errCodeParseBin, 8
22
+ value :errCodeForbidden, 9
23
+ value :errCodeWasRelock, 10
24
+ value :errCodeNotValid, 11
25
+ value :errCodeNetwork, 12
26
+ value :errCodeNotFound, 13
27
+ value :errCodeStateInvalidated, 14
28
+ value :errCodeBadTransaction, 15
29
+ value :errCodeOutdatedWAL, 16
30
+ value :errCodeNoWAL, 17
31
+ value :errCodeDataHashMismatch, 18
32
+ value :errCodeTimeout, 19
33
+ value :errCodeCanceled, 20
34
+ value :errCodeTagsMissmatch, 21
35
+ value :errCodeReplParams, 22
36
+ value :errCodeNamespaceInvalidated, 23
37
+ value :errCodeParseMsgPack, 24
38
+ value :errCodeParseProtobuf, 25
39
+ end
40
+ add_message "reindexer.grpc.CreateDatabaseRequest" do
41
+ optional :dbName, :string, 1
42
+ end
43
+ add_message "reindexer.grpc.CloseNamespaceRequest" do
44
+ optional :dbName, :string, 1
45
+ optional :nsName, :string, 2
46
+ end
47
+ add_message "reindexer.grpc.DropNamespaceRequest" do
48
+ optional :dbName, :string, 1
49
+ optional :nsName, :string, 2
50
+ end
51
+ add_message "reindexer.grpc.TruncateNamespaceRequest" do
52
+ optional :dbName, :string, 1
53
+ optional :nsName, :string, 2
54
+ end
55
+ add_message "reindexer.grpc.IndexOptions" do
56
+ optional :isPk, :bool, 1
57
+ optional :isArray, :bool, 2
58
+ optional :isDense, :bool, 3
59
+ optional :isSparse, :bool, 4
60
+ optional :rtreeType, :enum, 5, "reindexer.grpc.IndexOptions.RTreeType"
61
+ optional :collateMode, :enum, 6, "reindexer.grpc.IndexOptions.CollateMode"
62
+ optional :sortOrdersTable, :string, 7
63
+ optional :config, :string, 8
64
+ end
65
+ add_enum "reindexer.grpc.IndexOptions.RTreeType" do
66
+ value :Linear, 0
67
+ value :Quadratic, 1
68
+ value :Greene, 2
69
+ value :RStar, 3
70
+ end
71
+ add_enum "reindexer.grpc.IndexOptions.CollateMode" do
72
+ value :CollateNoneMode, 0
73
+ value :CollateASCIIMode, 1
74
+ value :CollateUTF8Mode, 2
75
+ value :CollateNumericMode, 3
76
+ value :CollateCustomMode, 4
77
+ end
78
+ add_message "reindexer.grpc.Index" do
79
+ optional :name, :string, 1
80
+ repeated :jsonPaths, :string, 2
81
+ optional :indexType, :string, 3
82
+ optional :fieldType, :string, 4
83
+ optional :options, :message, 5, "reindexer.grpc.IndexOptions"
84
+ optional :expireAfter, :int64, 6
85
+ end
86
+ add_message "reindexer.grpc.AddIndexRequest" do
87
+ optional :dbName, :string, 1
88
+ optional :nsName, :string, 2
89
+ optional :definition, :message, 3, "reindexer.grpc.Index"
90
+ end
91
+ add_message "reindexer.grpc.UpdateIndexRequest" do
92
+ optional :dbName, :string, 1
93
+ optional :nsName, :string, 2
94
+ optional :definition, :message, 3, "reindexer.grpc.Index"
95
+ end
96
+ add_message "reindexer.grpc.DropIndexRequest" do
97
+ optional :dbName, :string, 1
98
+ optional :nsName, :string, 2
99
+ optional :definition, :message, 3, "reindexer.grpc.Index"
100
+ end
101
+ add_message "reindexer.grpc.SchemaDefinition" do
102
+ optional :nsName, :string, 1
103
+ optional :jsonData, :string, 2
104
+ end
105
+ add_message "reindexer.grpc.SetSchemaRequest" do
106
+ optional :dbName, :string, 1
107
+ optional :schemaDefinitionRequest, :message, 2, "reindexer.grpc.SchemaDefinition"
108
+ end
109
+ add_message "reindexer.grpc.ModifyItemRequest" do
110
+ optional :dbName, :string, 1
111
+ optional :nsName, :string, 2
112
+ optional :mode, :enum, 3, "reindexer.grpc.ModifyMode"
113
+ optional :encodingType, :enum, 4, "reindexer.grpc.EncodingType"
114
+ optional :data, :bytes, 5
115
+ end
116
+ add_message "reindexer.grpc.Query" do
117
+ optional :encdoingType, :enum, 1, "reindexer.grpc.EncodingType"
118
+ optional :data, :bytes, 2
119
+ end
120
+ add_message "reindexer.grpc.OutputFlags" do
121
+ optional :encodingType, :enum, 1, "reindexer.grpc.EncodingType"
122
+ optional :withItemID, :bool, 2
123
+ optional :withNsID, :bool, 3
124
+ optional :withRank, :bool, 4
125
+ optional :withJoinedItems, :bool, 5
126
+ end
127
+ add_message "reindexer.grpc.SelectSqlRequest" do
128
+ optional :dbName, :string, 1
129
+ optional :sql, :string, 2
130
+ optional :flags, :message, 3, "reindexer.grpc.OutputFlags"
131
+ end
132
+ add_message "reindexer.grpc.SelectRequest" do
133
+ optional :dbName, :string, 1
134
+ optional :query, :message, 2, "reindexer.grpc.Query"
135
+ optional :flags, :message, 3, "reindexer.grpc.OutputFlags"
136
+ end
137
+ add_message "reindexer.grpc.DeleteRequest" do
138
+ optional :dbName, :string, 1
139
+ optional :query, :message, 2, "reindexer.grpc.Query"
140
+ optional :flags, :message, 3, "reindexer.grpc.OutputFlags"
141
+ end
142
+ add_message "reindexer.grpc.UpdateRequest" do
143
+ optional :dbName, :string, 1
144
+ optional :query, :message, 2, "reindexer.grpc.Query"
145
+ optional :flags, :message, 3, "reindexer.grpc.OutputFlags"
146
+ end
147
+ add_message "reindexer.grpc.QueryResultsResponse" do
148
+ optional :data, :bytes, 1
149
+ optional :options, :message, 2, "reindexer.grpc.QueryResultsResponse.QueryResultsOptions"
150
+ optional :errorResponse, :message, 3, "reindexer.grpc.ErrorResponse"
151
+ end
152
+ add_message "reindexer.grpc.QueryResultsResponse.QueryResultsOptions" do
153
+ optional :totalItems, :int64, 1
154
+ optional :queryTotalItems, :int64, 2
155
+ optional :cacheEnabled, :bool, 3
156
+ optional :explain, :string, 4
157
+ end
158
+ add_message "reindexer.grpc.ConnectOptions" do
159
+ optional :expectedClusterID, :int64, 1
160
+ optional :openNamespaces, :bool, 2
161
+ optional :allowNamespaceErrors, :bool, 3
162
+ optional :autorepair, :bool, 4
163
+ optional :disableReplication, :bool, 5
164
+ optional :storageType, :enum, 6, "reindexer.grpc.StorageType"
165
+ end
166
+ add_message "reindexer.grpc.ConnectRequest" do
167
+ optional :url, :string, 1
168
+ optional :dbName, :string, 2
169
+ optional :login, :string, 3
170
+ optional :password, :string, 4
171
+ optional :connectOpts, :message, 5, "reindexer.grpc.ConnectOptions"
172
+ end
173
+ add_message "reindexer.grpc.StorageOptions" do
174
+ optional :nsName, :string, 1
175
+ optional :enabled, :bool, 2
176
+ optional :dropOnFileFormatError, :bool, 3
177
+ optional :createIfMissing, :bool, 4
178
+ optional :verifyChecksums, :bool, 5
179
+ optional :fillCache, :bool, 6
180
+ optional :sync, :bool, 7
181
+ optional :slaveMode, :bool, 8
182
+ optional :autorepair, :bool, 9
183
+ end
184
+ add_message "reindexer.grpc.OpenNamespaceRequest" do
185
+ optional :dbName, :string, 1
186
+ optional :storageOptions, :message, 2, "reindexer.grpc.StorageOptions"
187
+ end
188
+ add_message "reindexer.grpc.EnumNamespacesOptions" do
189
+ optional :filter, :string, 1
190
+ optional :withClosed, :bool, 2
191
+ optional :onlyNames, :bool, 3
192
+ optional :hideSystems, :bool, 4
193
+ end
194
+ add_message "reindexer.grpc.EnumNamespacesRequest" do
195
+ optional :dbName, :string, 1
196
+ optional :options, :message, 2, "reindexer.grpc.EnumNamespacesOptions"
197
+ end
198
+ add_message "reindexer.grpc.EnumDatabasesRequest" do
199
+ end
200
+ add_message "reindexer.grpc.Namespace" do
201
+ optional :dbName, :string, 1
202
+ optional :name, :string, 2
203
+ optional :storageOptions, :message, 3, "reindexer.grpc.StorageOptions"
204
+ repeated :indexesDefinitions, :message, 4, "reindexer.grpc.Index"
205
+ optional :isTemporary, :bool, 5
206
+ end
207
+ add_message "reindexer.grpc.AddNamespaceRequest" do
208
+ optional :dbName, :string, 1
209
+ optional :namespace, :message, 2, "reindexer.grpc.Namespace"
210
+ end
211
+ add_message "reindexer.grpc.EnumNamespacesResponse" do
212
+ repeated :namespacesDefinitions, :message, 1, "reindexer.grpc.Namespace"
213
+ optional :errorResponse, :message, 2, "reindexer.grpc.ErrorResponse"
214
+ end
215
+ add_message "reindexer.grpc.EnumDatabasesResponse" do
216
+ repeated :names, :string, 1
217
+ optional :errorResponse, :message, 2, "reindexer.grpc.ErrorResponse"
218
+ end
219
+ add_message "reindexer.grpc.MetadataResponse" do
220
+ optional :metadata, :string, 1
221
+ optional :errorResponse, :message, 2, "reindexer.grpc.ErrorResponse"
222
+ end
223
+ add_message "reindexer.grpc.Metadata" do
224
+ optional :nsName, :string, 1
225
+ optional :key, :string, 2
226
+ optional :value, :string, 3
227
+ end
228
+ add_message "reindexer.grpc.GetMetaRequest" do
229
+ optional :dbName, :string, 1
230
+ optional :metadata, :message, 2, "reindexer.grpc.Metadata"
231
+ end
232
+ add_message "reindexer.grpc.PutMetaRequest" do
233
+ optional :dbName, :string, 1
234
+ optional :metadata, :message, 2, "reindexer.grpc.Metadata"
235
+ end
236
+ add_message "reindexer.grpc.EnumMetaRequest" do
237
+ optional :dbName, :string, 1
238
+ optional :nsName, :string, 2
239
+ end
240
+ add_message "reindexer.grpc.MetadataKeysResponse" do
241
+ repeated :keys, :string, 1
242
+ optional :errorResponse, :message, 2, "reindexer.grpc.ErrorResponse"
243
+ end
244
+ add_message "reindexer.grpc.CommitTransactionRequest" do
245
+ optional :id, :int64, 1
246
+ end
247
+ add_message "reindexer.grpc.RollbackTransactionRequest" do
248
+ optional :id, :int64, 1
249
+ end
250
+ add_message "reindexer.grpc.TransactionIdResponse" do
251
+ optional :status, :message, 1, "reindexer.grpc.ErrorResponse"
252
+ optional :id, :int64, 2
253
+ end
254
+ add_message "reindexer.grpc.AddTxItemRequest" do
255
+ optional :id, :int64, 1
256
+ optional :mode, :enum, 2, "reindexer.grpc.ModifyMode"
257
+ optional :encodingType, :enum, 3, "reindexer.grpc.EncodingType"
258
+ optional :data, :bytes, 4
259
+ end
260
+ add_message "reindexer.grpc.BeginTransactionRequest" do
261
+ optional :dbName, :string, 1
262
+ optional :nsName, :string, 2
263
+ end
264
+ add_message "reindexer.grpc.GetProtobufSchemaRequest" do
265
+ optional :dbName, :string, 1
266
+ repeated :namespaces, :string, 2
267
+ end
268
+ add_message "reindexer.grpc.ProtobufSchemaResponse" do
269
+ optional :proto, :string, 1
270
+ optional :errorResponse, :message, 2, "reindexer.grpc.ErrorResponse"
271
+ end
272
+ add_enum "reindexer.grpc.ModifyMode" do
273
+ value :UPSERT, 0
274
+ value :INSERT, 1
275
+ value :UPDATE, 2
276
+ value :DELETE, 3
277
+ end
278
+ add_enum "reindexer.grpc.EncodingType" do
279
+ value :JSON, 0
280
+ value :CJSON, 1
281
+ value :MSGPACK, 2
282
+ value :PROTOBUF, 3
283
+ end
284
+ add_enum "reindexer.grpc.StorageType" do
285
+ value :StorageTypeLevelDB, 0
286
+ value :StorageTypeRocksDB, 1
287
+ end
288
+ end
289
+ end
290
+
291
+ module Reindexer
292
+ module Grpc
293
+ ErrorResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.ErrorResponse").msgclass
294
+ ErrorResponse::ErrorCode = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.ErrorResponse.ErrorCode").enummodule
295
+ CreateDatabaseRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.CreateDatabaseRequest").msgclass
296
+ CloseNamespaceRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.CloseNamespaceRequest").msgclass
297
+ DropNamespaceRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.DropNamespaceRequest").msgclass
298
+ TruncateNamespaceRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.TruncateNamespaceRequest").msgclass
299
+ IndexOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.IndexOptions").msgclass
300
+ IndexOptions::RTreeType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.IndexOptions.RTreeType").enummodule
301
+ IndexOptions::CollateMode = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.IndexOptions.CollateMode").enummodule
302
+ Index = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.Index").msgclass
303
+ AddIndexRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.AddIndexRequest").msgclass
304
+ UpdateIndexRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.UpdateIndexRequest").msgclass
305
+ DropIndexRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.DropIndexRequest").msgclass
306
+ SchemaDefinition = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.SchemaDefinition").msgclass
307
+ SetSchemaRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.SetSchemaRequest").msgclass
308
+ ModifyItemRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.ModifyItemRequest").msgclass
309
+ Query = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.Query").msgclass
310
+ OutputFlags = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.OutputFlags").msgclass
311
+ SelectSqlRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.SelectSqlRequest").msgclass
312
+ SelectRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.SelectRequest").msgclass
313
+ DeleteRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.DeleteRequest").msgclass
314
+ UpdateRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.UpdateRequest").msgclass
315
+ QueryResultsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.QueryResultsResponse").msgclass
316
+ QueryResultsResponse::QueryResultsOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.QueryResultsResponse.QueryResultsOptions").msgclass
317
+ ConnectOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.ConnectOptions").msgclass
318
+ ConnectRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.ConnectRequest").msgclass
319
+ StorageOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.StorageOptions").msgclass
320
+ OpenNamespaceRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.OpenNamespaceRequest").msgclass
321
+ EnumNamespacesOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.EnumNamespacesOptions").msgclass
322
+ EnumNamespacesRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.EnumNamespacesRequest").msgclass
323
+ EnumDatabasesRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.EnumDatabasesRequest").msgclass
324
+ Namespace = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.Namespace").msgclass
325
+ AddNamespaceRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.AddNamespaceRequest").msgclass
326
+ EnumNamespacesResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.EnumNamespacesResponse").msgclass
327
+ EnumDatabasesResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.EnumDatabasesResponse").msgclass
328
+ MetadataResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.MetadataResponse").msgclass
329
+ Metadata = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.Metadata").msgclass
330
+ GetMetaRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.GetMetaRequest").msgclass
331
+ PutMetaRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.PutMetaRequest").msgclass
332
+ EnumMetaRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.EnumMetaRequest").msgclass
333
+ MetadataKeysResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.MetadataKeysResponse").msgclass
334
+ CommitTransactionRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.CommitTransactionRequest").msgclass
335
+ RollbackTransactionRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.RollbackTransactionRequest").msgclass
336
+ TransactionIdResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.TransactionIdResponse").msgclass
337
+ AddTxItemRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.AddTxItemRequest").msgclass
338
+ BeginTransactionRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.BeginTransactionRequest").msgclass
339
+ GetProtobufSchemaRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.GetProtobufSchemaRequest").msgclass
340
+ ProtobufSchemaResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.ProtobufSchemaResponse").msgclass
341
+ ModifyMode = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.ModifyMode").enummodule
342
+ EncodingType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.EncodingType").enummodule
343
+ StorageType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("reindexer.grpc.StorageType").enummodule
344
+ end
345
+ end
@@ -0,0 +1,50 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: reindexer-grpc.proto for package 'reindexer.grpc'
3
+
4
+ require 'grpc'
5
+ require 'reindexer-grpc_pb'
6
+
7
+ module Reindexer
8
+ module Grpc
9
+ module Reindexer
10
+ # Reindexer service definition.
11
+ class Service
12
+
13
+ include ::GRPC::GenericService
14
+
15
+ self.marshal_class_method = :encode
16
+ self.unmarshal_class_method = :decode
17
+ self.service_name = 'reindexer.grpc.Reindexer'
18
+
19
+ rpc :Connect, ::Reindexer::Grpc::ConnectRequest, ::Reindexer::Grpc::ErrorResponse
20
+ rpc :CreateDatabase, ::Reindexer::Grpc::CreateDatabaseRequest, ::Reindexer::Grpc::ErrorResponse
21
+ rpc :OpenNamespace, ::Reindexer::Grpc::OpenNamespaceRequest, ::Reindexer::Grpc::ErrorResponse
22
+ rpc :AddNamespace, ::Reindexer::Grpc::AddNamespaceRequest, ::Reindexer::Grpc::ErrorResponse
23
+ rpc :CloseNamespace, ::Reindexer::Grpc::CloseNamespaceRequest, ::Reindexer::Grpc::ErrorResponse
24
+ rpc :DropNamespace, ::Reindexer::Grpc::DropNamespaceRequest, ::Reindexer::Grpc::ErrorResponse
25
+ rpc :TruncateNamespace, ::Reindexer::Grpc::TruncateNamespaceRequest, ::Reindexer::Grpc::ErrorResponse
26
+ rpc :AddIndex, ::Reindexer::Grpc::AddIndexRequest, ::Reindexer::Grpc::ErrorResponse
27
+ rpc :UpdateIndex, ::Reindexer::Grpc::UpdateIndexRequest, ::Reindexer::Grpc::ErrorResponse
28
+ rpc :DropIndex, ::Reindexer::Grpc::DropIndexRequest, ::Reindexer::Grpc::ErrorResponse
29
+ rpc :SetSchema, ::Reindexer::Grpc::SetSchemaRequest, ::Reindexer::Grpc::ErrorResponse
30
+ rpc :EnumNamespaces, ::Reindexer::Grpc::EnumNamespacesRequest, ::Reindexer::Grpc::EnumNamespacesResponse
31
+ rpc :EnumDatabases, ::Reindexer::Grpc::EnumDatabasesRequest, ::Reindexer::Grpc::EnumDatabasesResponse
32
+ rpc :ModifyItem, stream(::Reindexer::Grpc::ModifyItemRequest), stream(::Reindexer::Grpc::ErrorResponse)
33
+ rpc :SelectSql, ::Reindexer::Grpc::SelectSqlRequest, stream(::Reindexer::Grpc::QueryResultsResponse)
34
+ rpc :Select, ::Reindexer::Grpc::SelectRequest, stream(::Reindexer::Grpc::QueryResultsResponse)
35
+ rpc :Update, ::Reindexer::Grpc::UpdateRequest, stream(::Reindexer::Grpc::QueryResultsResponse)
36
+ rpc :Delete, ::Reindexer::Grpc::DeleteRequest, stream(::Reindexer::Grpc::QueryResultsResponse)
37
+ rpc :GetMeta, ::Reindexer::Grpc::GetMetaRequest, ::Reindexer::Grpc::MetadataResponse
38
+ rpc :PutMeta, ::Reindexer::Grpc::PutMetaRequest, ::Reindexer::Grpc::ErrorResponse
39
+ rpc :EnumMeta, ::Reindexer::Grpc::EnumMetaRequest, ::Reindexer::Grpc::MetadataKeysResponse
40
+ rpc :GetProtobufSchema, ::Reindexer::Grpc::GetProtobufSchemaRequest, ::Reindexer::Grpc::ProtobufSchemaResponse
41
+ rpc :BeginTransaction, ::Reindexer::Grpc::BeginTransactionRequest, ::Reindexer::Grpc::TransactionIdResponse
42
+ rpc :AddTxItem, stream(::Reindexer::Grpc::AddTxItemRequest), stream(::Reindexer::Grpc::ErrorResponse)
43
+ rpc :CommitTransaction, ::Reindexer::Grpc::CommitTransactionRequest, ::Reindexer::Grpc::ErrorResponse
44
+ rpc :RollbackTransaction, ::Reindexer::Grpc::RollbackTransactionRequest, ::Reindexer::Grpc::ErrorResponse
45
+ end
46
+
47
+ Stub = Service.rpc_stub_class
48
+ end
49
+ end
50
+ end
data/lib/reindexer.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'reindexer/version'
4
+ require 'reindexer/client'
5
+
6
+ module Reindexer
7
+ end
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../reindexer-grpc_services_pb'
4
+ require 'json'
5
+
6
+ module Reindexer
7
+ class Client
8
+ DEFAULT_PORT = 16534
9
+
10
+ attr_reader :connection, :config
11
+
12
+ def self.build_request_name(name)
13
+ name.to_s.gsub(/(.)([A-Z])/, '\1_\2').downcase.to_sym
14
+ end
15
+
16
+ ::Reindexer::Grpc::Reindexer::Service.rpc_descs.each do |rpc_name, rpc_desc|
17
+ stream_input = rpc_desc.bidi_streamer? || rpc_desc.client_streamer?
18
+ request_name = build_request_name(rpc_name)
19
+
20
+ if stream_input
21
+ request_klassname = rpc_desc.input.type
22
+
23
+ define_method(request_name) do |options_enum = []|
24
+ request = options_enum
25
+ .map { |options| build_grpc_request(request_klassname, **options) }
26
+
27
+ grpc_call(request_name.to_sym, request)
28
+ end
29
+ else
30
+ request_klassname = rpc_desc.input
31
+
32
+ define_method(request_name) do |**options|
33
+ request = build_grpc_request(request_klassname, **options)
34
+ grpc_call(request_name.to_sym, request)
35
+ end
36
+ end
37
+ end
38
+
39
+ def initialize(options)
40
+ @config = parse_config(options)
41
+ @connection = ::Reindexer::Grpc::Reindexer::Stub.new(
42
+ "#{config[:host]}:#{config[:port] || DEFAULT_PORT}",
43
+ :this_channel_is_insecure
44
+ )
45
+ end
46
+
47
+ private
48
+
49
+ def json_adapter
50
+ @json_adapter ||= config.fetch(:adapter, JSON)
51
+ end
52
+
53
+ def parse_config(options)
54
+ case options
55
+ when String
56
+ uri = URI(options)
57
+ {
58
+ host: uri.host,
59
+ port: uri.port,
60
+ scheme: uri.scheme.to_sym,
61
+ database: uri.path.gsub(%r{^/}, '')
62
+ }
63
+ when Hash
64
+ config.slice(:host, :port, :scheme, :database, :json_adapter)
65
+ else
66
+ raise 'Can not parse Reindexer config'
67
+ end
68
+ end
69
+
70
+ def grpc_call(grpc_method, request)
71
+ @connection.send(grpc_method, request)
72
+ end
73
+
74
+ def build_grpc_request(request_klass, **options)
75
+ request_options = request_klass.descriptor.each_with_object({}) do |field_descriptor, accum|
76
+ name = field_descriptor.name
77
+ key_name = [name.to_sym, self.class.build_request_name(name)].find { |n| options.key?(n) }
78
+ next if key_name.nil?
79
+
80
+ accum[name] = build_grpc_option_value(field_descriptor, options[key_name])
81
+ end
82
+
83
+ request_klass.new(**request_options)
84
+ end
85
+
86
+ def build_grpc_option_value(field_descriptor, value)
87
+ type = field_descriptor.type
88
+
89
+ if type == :message
90
+ build_grpc_request(field_descriptor.subtype.msgclass, **value)
91
+ elsif field_descriptor.name == :data && type == :bytes
92
+ json_adapter.dump(value)
93
+ else
94
+ value
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Reindexer
4
+ REINDEXER_VERSION = '3.0.0'
5
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Reindexer
4
+ VERSION = '0.0.1'
5
+ end
metadata ADDED
@@ -0,0 +1,198 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: reindexer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andrei Subbota
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-05-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: grpc
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: multi_json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.15'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: google-protobuf
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.15'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.15'
55
+ - !ruby/object:Gem::Dependency
56
+ name: grpc-tools
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry-byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.9'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.9'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '12.3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '12.3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-performance
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.10'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.10'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-rake
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.5'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.5'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '2.2'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '2.2'
153
+ description: A client that allows to interact with the Reindexer document-oriented
154
+ database
155
+ email:
156
+ - subbota@gmail.com
157
+ executables: []
158
+ extensions: []
159
+ extra_rdoc_files:
160
+ - CHANGELOG.md
161
+ - README.md
162
+ files:
163
+ - CHANGELOG.md
164
+ - LICENSE.txt
165
+ - README.md
166
+ - lib/reindexer-grpc_pb.rb
167
+ - lib/reindexer-grpc_services_pb.rb
168
+ - lib/reindexer.rb
169
+ - lib/reindexer/client.rb
170
+ - lib/reindexer/reindexer_version.rb
171
+ - lib/reindexer/version.rb
172
+ homepage: https://github.com/numbata/reindexer-ruby
173
+ licenses:
174
+ - Apache-2.0
175
+ metadata:
176
+ bug_tracker_uri: https://github.com/numbata/reindexer-ruby/issues
177
+ changelog_uri: https://github.com/numbata/reindexer-ruby/blob/master/CHANGELOG.md
178
+ source_code_uri: https://github.com/numbata/reindexer-ruby
179
+ post_install_message:
180
+ rdoc_options: []
181
+ require_paths:
182
+ - lib
183
+ required_ruby_version: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '2'
188
+ required_rubygems_version: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ requirements: []
194
+ rubygems_version: 3.1.4
195
+ signing_key:
196
+ specification_version: 4
197
+ summary: Reindexer GRPC-client
198
+ test_files: []