redis-client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +190 -0
  3. data/CHANGELOG.md +3 -0
  4. data/Gemfile +23 -0
  5. data/Gemfile.lock +67 -0
  6. data/LICENSE.md +21 -0
  7. data/README.md +347 -0
  8. data/Rakefile +86 -0
  9. data/ext/redis_client/hiredis/extconf.rb +54 -0
  10. data/ext/redis_client/hiredis/hiredis_connection.c +696 -0
  11. data/ext/redis_client/hiredis/vendor/.gitignore +9 -0
  12. data/ext/redis_client/hiredis/vendor/.travis.yml +131 -0
  13. data/ext/redis_client/hiredis/vendor/CHANGELOG.md +364 -0
  14. data/ext/redis_client/hiredis/vendor/CMakeLists.txt +165 -0
  15. data/ext/redis_client/hiredis/vendor/COPYING +29 -0
  16. data/ext/redis_client/hiredis/vendor/Makefile +308 -0
  17. data/ext/redis_client/hiredis/vendor/README.md +664 -0
  18. data/ext/redis_client/hiredis/vendor/adapters/ae.h +130 -0
  19. data/ext/redis_client/hiredis/vendor/adapters/glib.h +156 -0
  20. data/ext/redis_client/hiredis/vendor/adapters/ivykis.h +84 -0
  21. data/ext/redis_client/hiredis/vendor/adapters/libev.h +179 -0
  22. data/ext/redis_client/hiredis/vendor/adapters/libevent.h +175 -0
  23. data/ext/redis_client/hiredis/vendor/adapters/libuv.h +117 -0
  24. data/ext/redis_client/hiredis/vendor/adapters/macosx.h +115 -0
  25. data/ext/redis_client/hiredis/vendor/adapters/qt.h +135 -0
  26. data/ext/redis_client/hiredis/vendor/alloc.c +86 -0
  27. data/ext/redis_client/hiredis/vendor/alloc.h +91 -0
  28. data/ext/redis_client/hiredis/vendor/appveyor.yml +24 -0
  29. data/ext/redis_client/hiredis/vendor/async.c +887 -0
  30. data/ext/redis_client/hiredis/vendor/async.h +147 -0
  31. data/ext/redis_client/hiredis/vendor/async_private.h +75 -0
  32. data/ext/redis_client/hiredis/vendor/dict.c +352 -0
  33. data/ext/redis_client/hiredis/vendor/dict.h +126 -0
  34. data/ext/redis_client/hiredis/vendor/fmacros.h +12 -0
  35. data/ext/redis_client/hiredis/vendor/hiredis-config.cmake.in +13 -0
  36. data/ext/redis_client/hiredis/vendor/hiredis.c +1174 -0
  37. data/ext/redis_client/hiredis/vendor/hiredis.h +336 -0
  38. data/ext/redis_client/hiredis/vendor/hiredis.pc.in +12 -0
  39. data/ext/redis_client/hiredis/vendor/hiredis_ssl-config.cmake.in +13 -0
  40. data/ext/redis_client/hiredis/vendor/hiredis_ssl.h +157 -0
  41. data/ext/redis_client/hiredis/vendor/hiredis_ssl.pc.in +12 -0
  42. data/ext/redis_client/hiredis/vendor/net.c +612 -0
  43. data/ext/redis_client/hiredis/vendor/net.h +56 -0
  44. data/ext/redis_client/hiredis/vendor/read.c +739 -0
  45. data/ext/redis_client/hiredis/vendor/read.h +129 -0
  46. data/ext/redis_client/hiredis/vendor/sds.c +1289 -0
  47. data/ext/redis_client/hiredis/vendor/sds.h +278 -0
  48. data/ext/redis_client/hiredis/vendor/sdsalloc.h +44 -0
  49. data/ext/redis_client/hiredis/vendor/sockcompat.c +248 -0
  50. data/ext/redis_client/hiredis/vendor/sockcompat.h +92 -0
  51. data/ext/redis_client/hiredis/vendor/ssl.c +544 -0
  52. data/ext/redis_client/hiredis/vendor/test.c +1401 -0
  53. data/ext/redis_client/hiredis/vendor/test.sh +78 -0
  54. data/ext/redis_client/hiredis/vendor/win32.h +56 -0
  55. data/lib/redis-client.rb +3 -0
  56. data/lib/redis_client/buffered_io.rb +149 -0
  57. data/lib/redis_client/config.rb +174 -0
  58. data/lib/redis_client/connection.rb +86 -0
  59. data/lib/redis_client/hiredis_connection.rb +78 -0
  60. data/lib/redis_client/pooled.rb +86 -0
  61. data/lib/redis_client/resp3.rb +225 -0
  62. data/lib/redis_client/sentinel_config.rb +134 -0
  63. data/lib/redis_client/version.rb +5 -0
  64. data/lib/redis_client.rb +438 -0
  65. data/redis-client.gemspec +34 -0
  66. metadata +125 -0
data/Rakefile ADDED
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/extensiontask"
5
+ require "rake/testtask"
6
+ require 'rubocop/rake_task'
7
+
8
+ RuboCop::RakeTask.new
9
+
10
+ gemspec = Gem::Specification.load("redis-client.gemspec")
11
+ Rake::ExtensionTask.new do |ext|
12
+ ext.name = "hiredis_connection"
13
+ ext.ext_dir = "ext/redis_client/hiredis"
14
+ ext.lib_dir = "lib/redis_client"
15
+ ext.gem_spec = gemspec
16
+ CLEAN.add("#{ext.ext_dir}/vendor/*.{a,o}")
17
+ end
18
+
19
+ Rake::TestTask.new(:test) do |t|
20
+ t.libs << "test"
21
+ t.libs << "lib"
22
+ t.test_files = FileList["test/**/*_test.rb"]
23
+ end
24
+
25
+ namespace :hiredis do
26
+ task :download do
27
+ version = "1.0.2"
28
+ archive_path = "tmp/hiredis-#{version}.tar.gz"
29
+ url = "https://github.com/redis/hiredis/archive/refs/tags/v#{version}.tar.gz"
30
+ system("curl", "-L", url, out: archive_path) or raise "Downloading of #{url} failed"
31
+ system("rm", "-rf", "ext/redis_client/hiredis/vendor/")
32
+ system("mkdir", "-p", "ext/redis_client/hiredis/vendor/")
33
+ system("tar", "xvzf", archive_path, "-C", "ext/redis_client/hiredis/vendor", "--strip-components", "1")
34
+ system("rm", "-rf", "ext/redis_client/hiredis/vendor/examples")
35
+ end
36
+ end
37
+
38
+ namespace :benchmark do
39
+ task :record do
40
+ system("rm -rf tmp/*.benchmark")
41
+ %w(single pipelined).each do |suite|
42
+ %i[ruby yjit hiredis].each do |mode|
43
+ output_path = "benchmark/#{suite}_#{mode}.md"
44
+ File.open(output_path, "w+") do |output|
45
+ output.puts("ruby: `#{RUBY_DESCRIPTION}`\n\n")
46
+ output.puts("redis-server: `#{`redis-server -v`.strip}`\n\n")
47
+ output.puts
48
+ output.flush
49
+ env = {}
50
+ args = []
51
+ args << "--yjit" if mode == :yjit
52
+ env["DRIVER"] = "hiredis" if mode == :hiredis
53
+ system(env, RbConfig.ruby, *args, "benchmark/#{suite}.rb", out: output)
54
+ end
55
+
56
+ skipping = false
57
+ output = File.readlines(output_path).reject do |line|
58
+ if skipping
59
+ if line == "Comparison:\n"
60
+ skipping = false
61
+ true
62
+ else
63
+ skipping
64
+ end
65
+ else
66
+ skipping = true if line.start_with?("Warming up ---")
67
+ skipping
68
+ end
69
+ end
70
+ File.write(output_path, output.join)
71
+ end
72
+ end
73
+ end
74
+ end
75
+
76
+ if RUBY_PLATFORM == "java"
77
+ task default: %i[test rubocop]
78
+ else
79
+ task default: %i[compile test rubocop]
80
+ end
81
+
82
+ if ENV["DRIVER"] == "hiredis"
83
+ task ci: %i[compile test]
84
+ else
85
+ task ci: %i[test]
86
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mkmf"
4
+
5
+ if RUBY_ENGINE == "ruby"
6
+ hiredis_dir = File.expand_path('vendor', __dir__)
7
+
8
+ make_program = with_config("make-prog", ENV["MAKE"])
9
+ make_program ||= case RUBY_PLATFORM
10
+ when /mswin/
11
+ 'nmake'
12
+ when /(bsd|solaris)/
13
+ 'gmake'
14
+ else
15
+ 'make'
16
+ end
17
+
18
+ openssl_include, openssl_lib = dir_config("openssl")
19
+
20
+ openssl_include ||= dir_config("opt").first
21
+ &.split(File::PATH_SEPARATOR)
22
+ &.detect { |dir| dir.include?("openssl") }
23
+
24
+ openssl_lib ||= dir_config("opt").last
25
+ &.split(File::PATH_SEPARATOR)
26
+ &.detect { |dir| dir.include?("openssl") }
27
+
28
+ if (!openssl_include || !openssl_lib) && !have_header("openssl/ssl.h")
29
+ raise "OpenSSL library could not be found. You might want to use --with-openssl-dir=<dir> option to specify the " \
30
+ "prefix where OpenSSL is installed."
31
+ end
32
+
33
+ Dir.chdir(hiredis_dir) do
34
+ flags = %(CFLAGS="-I#{openssl_include}" SSL_LDFLAGS="-L#{openssl_lib}") if openssl_lib
35
+ success = system("#{make_program} static USE_SSL=1 #{flags}")
36
+ raise "Building hiredis failed" unless success
37
+ end
38
+
39
+ $CFLAGS << " -I#{hiredis_dir}"
40
+ $LDFLAGS << " #{hiredis_dir}/libhiredis.a #{hiredis_dir}/libhiredis_ssl.a -lssl -lcrypto"
41
+ $CFLAGS << " -O3"
42
+ $CFLAGS << " -std=c99 "
43
+
44
+ if ENV["EXT_PEDANTIC"]
45
+ $CFLAGS << " -Werror"
46
+ end
47
+
48
+ $CFLAGS << " -Wno-declaration-after-statement" # Older compilers
49
+ $CFLAGS << " -Wno-compound-token-split-by-macro" # Older rubies on macos
50
+
51
+ create_makefile("redis_client/hiredis_connection")
52
+ else
53
+ File.write("Makefile", dummy_makefile($srcdir).join)
54
+ end