hirlite 0.0.1.3 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/hirlite_ext/rlite.c +0 -3
- data/lib/hirlite/connection.rb +64 -0
- data/lib/hirlite/rlite.rb +5 -2
- data/lib/hirlite/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6438f8e71c00a0088e572db6afc4c7e4d9f45fbe
|
4
|
+
data.tar.gz: e73519a70326bb1b5348e721f20f74e2c897c056
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 572064e64e3910a85a0f78076c95adb1fcad9d2fc4aed55039b203bd87eea9c8ab238fe82e3bd908de751df3627fa2b861bb7c87c4d19252aa85dd55c24edf8d
|
7
|
+
data.tar.gz: 3f8a2d8509c6fb564dcfd94b4e52a08e6926eb8a64703e943b7d4060e100b50decaad5fccdb818acc6cd580f561462de08704506b1293ab8bb9aab8f9fc4e699
|
data/ext/hirlite_ext/rlite.c
CHANGED
@@ -243,9 +243,6 @@ static VALUE createDecodedString(char *str, size_t len) {
|
|
243
243
|
|
244
244
|
static VALUE reply_to_value(rliteReply *reply) {
|
245
245
|
if (reply->type == RLITE_REPLY_STATUS || reply->type == RLITE_REPLY_STRING) {
|
246
|
-
if (reply->type == RLITE_REPLY_STATUS && reply->len == 2 && memcmp(reply->str, "OK", 2) == 0) {
|
247
|
-
return Qtrue;
|
248
|
-
}
|
249
246
|
return createDecodedString(reply->str, reply->len);
|
250
247
|
}
|
251
248
|
if (reply->type == RLITE_REPLY_NIL) {
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require "redis/connection/registry"
|
2
|
+
require "redis/errors"
|
3
|
+
require "hirlite"
|
4
|
+
require "timeout"
|
5
|
+
|
6
|
+
class Rlite
|
7
|
+
module Connection
|
8
|
+
class Hirlite
|
9
|
+
|
10
|
+
def self.connect(config)
|
11
|
+
connection = ::Hirlite::Rlite.new
|
12
|
+
connect_timeout = (config.fetch(:connect_timeout, 0) * 1_000_000).to_i
|
13
|
+
|
14
|
+
if config[:scheme] == "unix"
|
15
|
+
connection.connect_unix(config[:path], connect_timeout)
|
16
|
+
else
|
17
|
+
connection.connect(config[:host], config[:port], connect_timeout)
|
18
|
+
end
|
19
|
+
|
20
|
+
instance = new(connection)
|
21
|
+
instance.timeout = config[:timeout]
|
22
|
+
instance
|
23
|
+
rescue Errno::ETIMEDOUT
|
24
|
+
raise TimeoutError
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize(connection)
|
28
|
+
@connection = connection
|
29
|
+
end
|
30
|
+
|
31
|
+
def connected?
|
32
|
+
@connection && @connection.connected?
|
33
|
+
end
|
34
|
+
|
35
|
+
def timeout=(timeout)
|
36
|
+
# Hirlite works with microsecond timeouts
|
37
|
+
@connection.timeout = Integer(timeout * 1_000_000)
|
38
|
+
end
|
39
|
+
|
40
|
+
def disconnect
|
41
|
+
@connection.disconnect
|
42
|
+
@connection = nil
|
43
|
+
end
|
44
|
+
|
45
|
+
def write(command)
|
46
|
+
@connection.write(command.flatten(1))
|
47
|
+
rescue Errno::EAGAIN
|
48
|
+
raise TimeoutError
|
49
|
+
end
|
50
|
+
|
51
|
+
def read
|
52
|
+
reply = @connection.read
|
53
|
+
reply = CommandError.new(reply.message) if reply.is_a?(RuntimeError)
|
54
|
+
reply
|
55
|
+
rescue Errno::EAGAIN
|
56
|
+
raise TimeoutError
|
57
|
+
rescue RuntimeError => err
|
58
|
+
raise ProtocolError.new(err.message)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
Redis::Connection.drivers << Rlite::Connection::Hirlite
|
data/lib/hirlite/rlite.rb
CHANGED
@@ -8,11 +8,14 @@ module Hirlite
|
|
8
8
|
|
9
9
|
def write(command)
|
10
10
|
super
|
11
|
-
@responses.push
|
11
|
+
@responses.push read_ext
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
14
|
+
def read_ruby
|
15
15
|
@responses.shift
|
16
16
|
end
|
17
|
+
|
18
|
+
alias_method :read_ext, :read
|
19
|
+
alias_method :read, :read_ruby
|
17
20
|
end
|
18
21
|
end
|
data/lib/hirlite/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hirlite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Waisbrot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- ext/hirlite_ext/hirlite_ext.h
|
68
68
|
- ext/hirlite_ext/rlite.c
|
69
69
|
- lib/hirlite.rb
|
70
|
+
- lib/hirlite/connection.rb
|
70
71
|
- lib/hirlite/rlite.rb
|
71
72
|
- lib/hirlite/version.rb
|
72
73
|
- vendor/rlite/Makefile
|