karma 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -1
- data/karma.gemspec +1 -1
- data/lib/karma/connection.rb +1 -2
- data/lib/karma/tree.rb +62 -16
- data/lib/karma/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 860c7072d383b2f0df2bd5081b684ec52eaee1fb2f64ad0f8b9a509d20a6d6a3
|
4
|
+
data.tar.gz: e613fda887fc1eaaed56e4f6c91b12fda7c5c3aa533397999e3fd4bdb492889a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c919d5c03d9bff217f4120b11eef87504e9c2075d58f50690d8e0c6b50bbb861a6a8adae692b1b971b6335a1ceee5592798a79f4ea1aa16e8cd97e93a411f13
|
7
|
+
data.tar.gz: a97afe1720c288bbead08419fa2173417f5ea33532addfb072e4acfe85775151d8630ded3dc0ec4e73fb0c9973a1431dcc2a29ce38f2ccd249220481d7f93632
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
karma (0.1.
|
4
|
+
karma (0.1.5)
|
5
|
+
connection_pool (~> 2.4.1)
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
8
9
|
specs:
|
9
10
|
ast (2.4.2)
|
11
|
+
connection_pool (2.4.1)
|
10
12
|
json (2.6.3)
|
11
13
|
language_server-protocol (3.17.0.3)
|
12
14
|
minitest (5.18.1)
|
data/karma.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.require_paths = ["lib"]
|
30
30
|
|
31
31
|
# Uncomment to register a new dependency of your gem
|
32
|
-
|
32
|
+
spec.add_dependency "connection_pool", "~> 2.4.1"
|
33
33
|
|
34
34
|
# For more information and examples about making a new gem, check out our
|
35
35
|
# guide at: https://bundler.io/guides/creating_gem.html
|
data/lib/karma/connection.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Karma
|
2
2
|
class Connection
|
3
3
|
def initialize
|
4
|
-
@maxlen = 4096
|
5
4
|
end
|
6
5
|
|
7
6
|
def send_and_read(request)
|
@@ -33,8 +32,8 @@ module Karma
|
|
33
32
|
|
34
33
|
def read
|
35
34
|
connect do |conn|
|
36
|
-
response = conn.recv(@maxlen)
|
37
35
|
begin
|
36
|
+
response = conn.readline
|
38
37
|
OpenStruct.new(JSON.parse(response))
|
39
38
|
rescue => e
|
40
39
|
return OpenStruct.new({
|
data/lib/karma/tree.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
+
require 'connection_pool'
|
2
|
+
|
1
3
|
module Karma
|
2
4
|
class Tree
|
3
5
|
def initialize
|
4
|
-
@connection =
|
5
|
-
|
6
|
+
@connection = ConnectionPool.new(size: 5, timeout: 0.5) do
|
7
|
+
Connection.new
|
8
|
+
end
|
9
|
+
@tree_name = nil
|
6
10
|
end
|
7
11
|
|
8
12
|
def tree(name)
|
@@ -14,14 +18,20 @@ module Karma
|
|
14
18
|
request = {
|
15
19
|
command: 'ping'
|
16
20
|
}
|
17
|
-
|
21
|
+
|
22
|
+
@connection.with do |conn|
|
23
|
+
conn.send_and_read(request)
|
24
|
+
end
|
18
25
|
end
|
19
26
|
|
20
27
|
def trees
|
21
28
|
request = {
|
22
29
|
command: 'trees'
|
23
30
|
}
|
24
|
-
|
31
|
+
|
32
|
+
@connection.with do |conn|
|
33
|
+
conn.send_and_read(request)
|
34
|
+
end
|
25
35
|
end
|
26
36
|
|
27
37
|
def create(name)
|
@@ -29,7 +39,10 @@ module Karma
|
|
29
39
|
command: 'create',
|
30
40
|
tree_name: name
|
31
41
|
}
|
32
|
-
|
42
|
+
|
43
|
+
@connection.with do |conn|
|
44
|
+
conn.send_and_read(request)
|
45
|
+
end
|
33
46
|
end
|
34
47
|
|
35
48
|
def drop(name)
|
@@ -37,7 +50,10 @@ module Karma
|
|
37
50
|
command: 'drop',
|
38
51
|
tree_name: name
|
39
52
|
}
|
40
|
-
|
53
|
+
|
54
|
+
@connection.with do |conn|
|
55
|
+
conn.send_and_read(request)
|
56
|
+
end
|
41
57
|
end
|
42
58
|
|
43
59
|
def dump(name)
|
@@ -45,21 +61,30 @@ module Karma
|
|
45
61
|
command: 'dump',
|
46
62
|
tree_name: name
|
47
63
|
}
|
48
|
-
|
64
|
+
|
65
|
+
@connection.with do |conn|
|
66
|
+
conn.send_and_read(request)
|
67
|
+
end
|
49
68
|
end
|
50
69
|
|
51
70
|
def dump_all
|
52
71
|
request = {
|
53
72
|
command: 'dump_all'
|
54
73
|
}
|
55
|
-
|
74
|
+
|
75
|
+
@connection.with do |conn|
|
76
|
+
conn.send_and_read(request)
|
77
|
+
end
|
56
78
|
end
|
57
79
|
|
58
80
|
def dumps
|
59
81
|
request = {
|
60
82
|
command: 'dumps'
|
61
83
|
}
|
62
|
-
|
84
|
+
|
85
|
+
@connection.with do |conn|
|
86
|
+
conn.send_and_read(request)
|
87
|
+
end
|
63
88
|
end
|
64
89
|
|
65
90
|
def load(name)
|
@@ -67,7 +92,10 @@ module Karma
|
|
67
92
|
command: 'load',
|
68
93
|
tree_name: name
|
69
94
|
}
|
70
|
-
|
95
|
+
|
96
|
+
@connection.with do |conn|
|
97
|
+
conn.send_and_read(request)
|
98
|
+
end
|
71
99
|
end
|
72
100
|
|
73
101
|
def increment(**args)
|
@@ -75,7 +103,10 @@ module Karma
|
|
75
103
|
command: 'increment',
|
76
104
|
tree_name: @tree_name
|
77
105
|
}.merge!(args)
|
78
|
-
|
106
|
+
|
107
|
+
@connection.with do |conn|
|
108
|
+
conn.send_and_read(request)
|
109
|
+
end
|
79
110
|
end
|
80
111
|
|
81
112
|
def decrement(**args)
|
@@ -83,7 +114,10 @@ module Karma
|
|
83
114
|
command: 'decrement',
|
84
115
|
tree_name: @tree_name
|
85
116
|
}.merge!(args)
|
86
|
-
|
117
|
+
|
118
|
+
@connection.with do |conn|
|
119
|
+
conn.send_and_read(request)
|
120
|
+
end
|
87
121
|
end
|
88
122
|
|
89
123
|
def sum(**args)
|
@@ -91,7 +125,10 @@ module Karma
|
|
91
125
|
command: 'sum',
|
92
126
|
tree_name: @tree_name
|
93
127
|
}.merge!(args)
|
94
|
-
|
128
|
+
|
129
|
+
@connection.with do |conn|
|
130
|
+
conn.send_and_read(request)
|
131
|
+
end
|
95
132
|
end
|
96
133
|
|
97
134
|
def find(**args)
|
@@ -99,7 +136,10 @@ module Karma
|
|
99
136
|
command: 'find',
|
100
137
|
tree_name: @tree_name
|
101
138
|
}.merge!(args)
|
102
|
-
|
139
|
+
|
140
|
+
@connection.with do |conn|
|
141
|
+
conn.send_and_read(request)
|
142
|
+
end
|
103
143
|
end
|
104
144
|
|
105
145
|
def reset(**args)
|
@@ -107,7 +147,10 @@ module Karma
|
|
107
147
|
command: 'reset',
|
108
148
|
tree_name: @tree_name,
|
109
149
|
}.merge!(args)
|
110
|
-
|
150
|
+
|
151
|
+
@connection.with do |conn|
|
152
|
+
conn.send_and_read(request)
|
153
|
+
end
|
111
154
|
end
|
112
155
|
|
113
156
|
def delete(**args)
|
@@ -115,7 +158,10 @@ module Karma
|
|
115
158
|
command: 'delete',
|
116
159
|
tree_name: @tree_name,
|
117
160
|
}.merge!(args)
|
118
|
-
|
161
|
+
|
162
|
+
@connection.with do |conn|
|
163
|
+
conn.send_and_read(request)
|
164
|
+
end
|
119
165
|
end
|
120
166
|
end
|
121
167
|
end
|
data/lib/karma/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: karma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Fedorov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
12
|
-
dependencies:
|
11
|
+
date: 2023-07-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: connection_pool
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.4.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.4.1
|
13
27
|
description: Ruby client for the Karma key-counter database
|
14
28
|
email:
|
15
29
|
- creadone@gmail.com
|