redis-client 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/Gemfile +1 -2
  4. data/Gemfile.lock +1 -2
  5. data/README.md +5 -9
  6. data/Rakefile +41 -22
  7. data/lib/redis_client/version.rb +1 -1
  8. data/lib/redis_client.rb +1 -6
  9. data/redis-client.gemspec +2 -4
  10. metadata +6 -56
  11. data/.rubocop.yml +0 -191
  12. data/ext/redis_client/hiredis/export.clang +0 -2
  13. data/ext/redis_client/hiredis/export.gcc +0 -7
  14. data/ext/redis_client/hiredis/extconf.rb +0 -69
  15. data/ext/redis_client/hiredis/hiredis_connection.c +0 -708
  16. data/ext/redis_client/hiredis/vendor/.gitignore +0 -9
  17. data/ext/redis_client/hiredis/vendor/.travis.yml +0 -131
  18. data/ext/redis_client/hiredis/vendor/CHANGELOG.md +0 -364
  19. data/ext/redis_client/hiredis/vendor/CMakeLists.txt +0 -165
  20. data/ext/redis_client/hiredis/vendor/COPYING +0 -29
  21. data/ext/redis_client/hiredis/vendor/Makefile +0 -308
  22. data/ext/redis_client/hiredis/vendor/README.md +0 -664
  23. data/ext/redis_client/hiredis/vendor/adapters/ae.h +0 -130
  24. data/ext/redis_client/hiredis/vendor/adapters/glib.h +0 -156
  25. data/ext/redis_client/hiredis/vendor/adapters/ivykis.h +0 -84
  26. data/ext/redis_client/hiredis/vendor/adapters/libev.h +0 -179
  27. data/ext/redis_client/hiredis/vendor/adapters/libevent.h +0 -175
  28. data/ext/redis_client/hiredis/vendor/adapters/libuv.h +0 -117
  29. data/ext/redis_client/hiredis/vendor/adapters/macosx.h +0 -115
  30. data/ext/redis_client/hiredis/vendor/adapters/qt.h +0 -135
  31. data/ext/redis_client/hiredis/vendor/alloc.c +0 -86
  32. data/ext/redis_client/hiredis/vendor/alloc.h +0 -91
  33. data/ext/redis_client/hiredis/vendor/appveyor.yml +0 -24
  34. data/ext/redis_client/hiredis/vendor/async.c +0 -887
  35. data/ext/redis_client/hiredis/vendor/async.h +0 -147
  36. data/ext/redis_client/hiredis/vendor/async_private.h +0 -75
  37. data/ext/redis_client/hiredis/vendor/dict.c +0 -352
  38. data/ext/redis_client/hiredis/vendor/dict.h +0 -126
  39. data/ext/redis_client/hiredis/vendor/fmacros.h +0 -12
  40. data/ext/redis_client/hiredis/vendor/hiredis-config.cmake.in +0 -13
  41. data/ext/redis_client/hiredis/vendor/hiredis.c +0 -1174
  42. data/ext/redis_client/hiredis/vendor/hiredis.h +0 -336
  43. data/ext/redis_client/hiredis/vendor/hiredis.pc.in +0 -12
  44. data/ext/redis_client/hiredis/vendor/hiredis_ssl-config.cmake.in +0 -13
  45. data/ext/redis_client/hiredis/vendor/hiredis_ssl.h +0 -157
  46. data/ext/redis_client/hiredis/vendor/hiredis_ssl.pc.in +0 -12
  47. data/ext/redis_client/hiredis/vendor/net.c +0 -612
  48. data/ext/redis_client/hiredis/vendor/net.h +0 -56
  49. data/ext/redis_client/hiredis/vendor/read.c +0 -739
  50. data/ext/redis_client/hiredis/vendor/read.h +0 -129
  51. data/ext/redis_client/hiredis/vendor/sds.c +0 -1289
  52. data/ext/redis_client/hiredis/vendor/sds.h +0 -278
  53. data/ext/redis_client/hiredis/vendor/sdsalloc.h +0 -44
  54. data/ext/redis_client/hiredis/vendor/sockcompat.c +0 -248
  55. data/ext/redis_client/hiredis/vendor/sockcompat.h +0 -92
  56. data/ext/redis_client/hiredis/vendor/ssl.c +0 -544
  57. data/ext/redis_client/hiredis/vendor/test.c +0 -1401
  58. data/ext/redis_client/hiredis/vendor/test.sh +0 -78
  59. data/ext/redis_client/hiredis/vendor/win32.h +0 -56
  60. data/lib/redis_client/hiredis_connection.rb +0 -93
@@ -1,78 +0,0 @@
1
- #!/bin/sh -ue
2
-
3
- REDIS_SERVER=${REDIS_SERVER:-redis-server}
4
- REDIS_PORT=${REDIS_PORT:-56379}
5
- REDIS_SSL_PORT=${REDIS_SSL_PORT:-56443}
6
- TEST_SSL=${TEST_SSL:-0}
7
- SKIPS_AS_FAILS=${SKIPS_AS_FAILS-:0}
8
- SSL_TEST_ARGS=
9
- SKIPS_ARG=
10
-
11
- tmpdir=$(mktemp -d)
12
- PID_FILE=${tmpdir}/hiredis-test-redis.pid
13
- SOCK_FILE=${tmpdir}/hiredis-test-redis.sock
14
-
15
- if [ "$TEST_SSL" = "1" ]; then
16
- SSL_CA_CERT=${tmpdir}/ca.crt
17
- SSL_CA_KEY=${tmpdir}/ca.key
18
- SSL_CERT=${tmpdir}/redis.crt
19
- SSL_KEY=${tmpdir}/redis.key
20
-
21
- openssl genrsa -out ${tmpdir}/ca.key 4096
22
- openssl req \
23
- -x509 -new -nodes -sha256 \
24
- -key ${SSL_CA_KEY} \
25
- -days 3650 \
26
- -subj '/CN=Hiredis Test CA' \
27
- -out ${SSL_CA_CERT}
28
- openssl genrsa -out ${SSL_KEY} 2048
29
- openssl req \
30
- -new -sha256 \
31
- -key ${SSL_KEY} \
32
- -subj '/CN=Hiredis Test Cert' | \
33
- openssl x509 \
34
- -req -sha256 \
35
- -CA ${SSL_CA_CERT} \
36
- -CAkey ${SSL_CA_KEY} \
37
- -CAserial ${tmpdir}/ca.txt \
38
- -CAcreateserial \
39
- -days 365 \
40
- -out ${SSL_CERT}
41
-
42
- SSL_TEST_ARGS="--ssl-host 127.0.0.1 --ssl-port ${REDIS_SSL_PORT} --ssl-ca-cert ${SSL_CA_CERT} --ssl-cert ${SSL_CERT} --ssl-key ${SSL_KEY}"
43
- fi
44
-
45
- cleanup() {
46
- set +e
47
- kill $(cat ${PID_FILE})
48
- rm -rf ${tmpdir}
49
- }
50
- trap cleanup INT TERM EXIT
51
-
52
- cat > ${tmpdir}/redis.conf <<EOF
53
- daemonize yes
54
- pidfile ${PID_FILE}
55
- port ${REDIS_PORT}
56
- bind 127.0.0.1
57
- unixsocket ${SOCK_FILE}
58
- EOF
59
-
60
- if [ "$TEST_SSL" = "1" ]; then
61
- cat >> ${tmpdir}/redis.conf <<EOF
62
- tls-port ${REDIS_SSL_PORT}
63
- tls-ca-cert-file ${SSL_CA_CERT}
64
- tls-cert-file ${SSL_CERT}
65
- tls-key-file ${SSL_KEY}
66
- EOF
67
- fi
68
-
69
- cat ${tmpdir}/redis.conf
70
- ${REDIS_SERVER} ${tmpdir}/redis.conf
71
-
72
- # Wait until we detect the unix socket
73
- while [ ! -S "${SOCK_FILE}" ]; do sleep 1; done
74
-
75
- # Treat skips as failures if directed
76
- [ "$SKIPS_AS_FAILS" = 1 ] && SKIPS_ARG="--skips-as-fails"
77
-
78
- ${TEST_PREFIX:-} ./hiredis-test -h 127.0.0.1 -p ${REDIS_PORT} -s ${SOCK_FILE} ${SSL_TEST_ARGS} ${SKIPS_ARG}
@@ -1,56 +0,0 @@
1
- #ifndef _WIN32_HELPER_INCLUDE
2
- #define _WIN32_HELPER_INCLUDE
3
- #ifdef _MSC_VER
4
-
5
- #include <winsock2.h> /* for struct timeval */
6
-
7
- #ifndef inline
8
- #define inline __inline
9
- #endif
10
-
11
- #ifndef strcasecmp
12
- #define strcasecmp stricmp
13
- #endif
14
-
15
- #ifndef strncasecmp
16
- #define strncasecmp strnicmp
17
- #endif
18
-
19
- #ifndef va_copy
20
- #define va_copy(d,s) ((d) = (s))
21
- #endif
22
-
23
- #ifndef snprintf
24
- #define snprintf c99_snprintf
25
-
26
- __inline int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap)
27
- {
28
- int count = -1;
29
-
30
- if (size != 0)
31
- count = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
32
- if (count == -1)
33
- count = _vscprintf(format, ap);
34
-
35
- return count;
36
- }
37
-
38
- __inline int c99_snprintf(char* str, size_t size, const char* format, ...)
39
- {
40
- int count;
41
- va_list ap;
42
-
43
- va_start(ap, format);
44
- count = c99_vsnprintf(str, size, format, ap);
45
- va_end(ap);
46
-
47
- return count;
48
- }
49
- #endif
50
- #endif /* _MSC_VER */
51
-
52
- #ifdef _WIN32
53
- #define strerror_r(errno,buf,len) strerror_s(buf,len,errno)
54
- #endif /* _WIN32 */
55
-
56
- #endif /* _WIN32_HELPER_INCLUDE */
@@ -1,93 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "redis_client/hiredis_connection.so"
4
- require "redis_client/connection_mixin"
5
-
6
- class RedisClient
7
- class HiredisConnection
8
- include ConnectionMixin
9
-
10
- class << self
11
- def ssl_context(ssl_params)
12
- HiredisConnection::SSLContext.new(
13
- ca_file: ssl_params[:ca_file],
14
- ca_path: ssl_params[:ca_path],
15
- cert: ssl_params[:cert],
16
- key: ssl_params[:key],
17
- hostname: ssl_params[:hostname],
18
- )
19
- end
20
- end
21
-
22
- class SSLContext
23
- def initialize(ca_file: nil, ca_path: nil, cert: nil, key: nil, hostname: nil)
24
- if (error = init(ca_file, ca_path, cert, key, hostname))
25
- raise error
26
- end
27
- end
28
- end
29
-
30
- def initialize(config, connect_timeout:, read_timeout:, write_timeout:)
31
- self.connect_timeout = connect_timeout
32
- self.read_timeout = read_timeout
33
- self.write_timeout = write_timeout
34
-
35
- if config.path
36
- connect_unix(config.path)
37
- else
38
- connect_tcp(config.host, config.port)
39
- end
40
-
41
- if config.ssl
42
- init_ssl(config.ssl_context)
43
- end
44
- end
45
-
46
- def connect_timeout=(timeout)
47
- self.connect_timeout_us = timeout ? (timeout * 1_000_000).to_i : 0
48
- @connect_timeout = timeout
49
- end
50
-
51
- def read_timeout=(timeout)
52
- self.read_timeout_us = timeout ? (timeout * 1_000_000).to_i : 0
53
- @read_timeout = timeout
54
- end
55
-
56
- def write_timeout=(timeout)
57
- self.write_timeout_us = timeout ? (timeout * 1_000_000).to_i : 0
58
- @write_timeout = timeout
59
- end
60
-
61
- def read(timeout = nil)
62
- if timeout.nil?
63
- _read
64
- else
65
- previous_timeout = @read_timeout
66
- self.read_timeout = timeout
67
- begin
68
- _read
69
- ensure
70
- self.read_timeout = previous_timeout
71
- end
72
- end
73
- rescue SystemCallError, IOError => error
74
- raise ConnectionError, error.message
75
- end
76
-
77
- def write(command)
78
- _write(command)
79
- flush
80
- rescue SystemCallError, IOError => error
81
- raise ConnectionError, error.message
82
- end
83
-
84
- def write_multi(commands)
85
- commands.each do |command|
86
- _write(command)
87
- end
88
- flush
89
- rescue SystemCallError, IOError => error
90
- raise ConnectionError, error.message
91
- end
92
- end
93
- end