ffi-hiredis_vip-core 0.1.0.pre4 → 0.1.0.pre5

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: 663a312faeb9876f597a3d3ec243a78a6f8a1a1a
4
- data.tar.gz: 03c4726d35b3a48335f2f52c7da6e5da5de43c00
3
+ metadata.gz: 9c17d4474aa30be236e4162762f77dfa70ec2705
4
+ data.tar.gz: f0e287223d98ecb2094c48a8dcca9f030834615a
5
5
  SHA512:
6
- metadata.gz: 29af71e9d5f9fee7fd73f7df585d17df858390b126eca07b923b76f6e96c89f2e93427c20da8268c6eaa4b973efb6bde5caea4941daa10994089b60d85efee34
7
- data.tar.gz: 19adb10cc75ecee01a98df7d5b1874bb47d29a64e15931dc2f9bcc56cc8cad4784d319261c293093d71ef6e2c07925fa6e08240452e2756aada88c62eca02441
6
+ metadata.gz: 9e1c4480814a6faca36e99bf9caca3ca2a31682d722fc9bfb80bf22bea422c0246810f8f21addfd4f3c18c518b3781355f23f05f94dae83c6eed684f200d7d71
7
+ data.tar.gz: e3e356414bc3f70ea7fe22a003b8e2d18c7f935348921543689dc80a617c02125692103cf92e2e2f494cff3699c2c590a7bf08f15134a90c77110f5c61d64765
@@ -9,6 +9,8 @@ module FFI
9
9
  extend ::FFI::Library
10
10
  ffi_lib_flags :now, :global
11
11
 
12
+ class ConnectionError < RuntimeError; end
13
+
12
14
  ##
13
15
  # ffi-rzmq-core for reference
14
16
  #
@@ -50,11 +52,13 @@ module FFI
50
52
  if HIREDIS_VIP_LIB_PATHS.any? {|path|
51
53
  File.file? File.join(path, "libhiredis_vip.#{FFI::Platform::LIBSUFFIX}")}
52
54
  warn "Unable to load this gem. The libhiredis_vip library exists, but cannot be loaded."
55
+ warn "Set HIREDIS_VIP_LIB_PATH if custom load path is desired"
53
56
  warn "If this is Windows:"
54
57
  warn "- Check that you have MSVC runtime installed or statically linked"
55
58
  warn "- Check that your DLL is compiled for #{FFI::Platform::ADDRESS_SIZE} bit"
56
59
  else
57
60
  warn "Unable to load this gem. The libhiredis_vip library (or DLL) could not be found."
61
+ warn "Set HIREDIS_VIP_LIB_PATH if custom load path is desired"
58
62
  warn "If this is a Windows platform, make sure libhiredis_vip.dll is on the PATH."
59
63
  warn "If the DLL was built with mingw, make sure the other two dependent DLLs,"
60
64
  warn "libgcc_s_sjlj-1.dll and libstdc++6.dll, are also on the PATH."
@@ -70,6 +74,9 @@ module FFI
70
74
  :HIRCLUSTER_FLAG_ADD_OPENSLOT, 0x2000, #/* The flag to decide whether add open slot for master node. (10000000000000) */
71
75
  :HIRCLUSTER_FLAG_ROUTE_USE_SLOTS, 0x4000 # /* The flag to decide whether add open slot for master node. (100000000000000) */
72
76
 
77
+ RedisConnectionType = enum :REDIS_CONN_TCP, 0,
78
+ :REDIS_CONN_UNIX, 1
79
+
73
80
  RedisReplyType = enum :REDIS_REPLY_STRING, 1,
74
81
  :REDIS_REPLY_ARRAY, 2,
75
82
  :REDIS_REPLY_INTEGER, 3,
@@ -91,6 +98,28 @@ module FFI
91
98
  :tv_usec, :long
92
99
  end
93
100
 
101
+ class RedisTcpStruct < ::FFI::Struct
102
+ layout :host, :string,
103
+ :source_addr, :string,
104
+ :port, :int
105
+ end
106
+
107
+ class RedisUnixStruct < ::FFI::Struct
108
+ layout :path, :string
109
+ end
110
+
111
+ class RedisContext < ::FFI::Struct
112
+ layout :err, :int,
113
+ :errstr, [:char, 128],
114
+ :fd, :int,
115
+ :flags, :int,
116
+ :obuf, :string,
117
+ :connection_type, RedisConnectionType,
118
+ :timeval, :pointer,
119
+ :tcp, RedisTcpStruct,
120
+ :unix_sock, RedisUnixStruct
121
+ end
122
+
94
123
  class RedisReply < ::FFI::Struct
95
124
  layout :type, ::FFI::HiredisVip::Core::RedisReplyType,
96
125
  :integer, :long_long,
@@ -121,7 +150,12 @@ module FFI
121
150
  end
122
151
 
123
152
  def self.connect(host, port)
124
- ::FFI::AutoPointer.new(::FFI::HiredisVip::Core.redisConnect(host, port), ::FFI::HiredisVip::Core.method(:redisFree))
153
+ redis_context = ::FFI::HiredisVip::Core.redisConnect(host, port)
154
+ redis_context_reply = ::FFI::HiredisVip::Core::RedisContext.new(redis_context)
155
+
156
+ raise ::FFI::HiredisVip::Core::ConnectionError, redis_context_reply[:errstr] unless redis_context_reply[:err] == 0
157
+
158
+ ::FFI::AutoPointer.new(redis_context, ::FFI::HiredisVip::Core.method(:redisFree))
125
159
  end
126
160
 
127
161
  def self.cluster_command(cluster_context, command, *args)
@@ -1,7 +1,7 @@
1
1
  module FFI
2
2
  module HiredisVip
3
3
  module Core
4
- VERSION = "0.1.0.pre4"
4
+ VERSION = "0.1.0.pre5"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-hiredis_vip-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre4
4
+ version: 0.1.0.pre5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Dewitt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-28 00:00:00.000000000 Z
11
+ date: 2016-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi