redic-sentinels 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 54d236a916888c25a0413816ec6e2c649100db9c
4
+ data.tar.gz: 62b9e67398198edc52ce30b6956692eeb7f0c7da
5
+ SHA512:
6
+ metadata.gz: adb8e3aa13617616c2c3979b41ec105956b0473c3d0c16acdc5537b2a36fd5f31c22aef9ad68c8bc68899820bcf3e04ccd2224dd7d859035a7e476e3484ce651
7
+ data.tar.gz: 3c5b8d27b12d9585c2a11b2d8c7e924ed5260102c6ebf66b063a40718cae546d06a2234e577d492c82463335c1081243eb1bbad52cdfc62ea3739a484f7faac9
data/.coveralls.yml ADDED
@@ -0,0 +1,2 @@
1
+ service_name: travis-ci
2
+ repo_token: 8rCtoRCoqltnTE2aJCleoW2QEaRBNutwr
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ redic-sentinels
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.3.0
data/.travis.yml ADDED
@@ -0,0 +1,16 @@
1
+ sudo: true
2
+ language: ruby
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0
6
+ - 2.1
7
+ - 2.2
8
+ - 2.3.0
9
+ - 2.4.0
10
+ - jruby
11
+ before_install:
12
+ - gem install bundler
13
+ services:
14
+ - redis-server
15
+ before_script:
16
+ - bundle exec rake redis:start:all
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in redic-sentinels.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Gabriel Naiman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # Redic::Sentinels
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/redic-sentinels.svg)](https://rubygems.org/gems/redic-sentinels)
4
+ [![Build Status](https://travis-ci.org/gabynaiman/redic-sentinels.svg?branch=master)](https://travis-ci.org/gabynaiman/redic-sentinels)
5
+ [![Coverage Status](https://coveralls.io/repos/gabynaiman/redic-sentinels/badge.svg?branch=master)](https://coveralls.io/r/gabynaiman/redic-sentinels?branch=master)
6
+ [![Code Climate](https://codeclimate.com/github/gabynaiman/redic-sentinels.svg)](https://codeclimate.com/github/gabynaiman/redic-sentinels)
7
+ [![Dependency Status](https://gemnasium.com/gabynaiman/redic-sentinels.svg)](https://gemnasium.com/gabynaiman/redic-sentinels)
8
+
9
+ Redic::Sentinels is a wrapper for the Redis client that fetches configuration details from sentinels.
10
+
11
+ Based on [soveran/redisent](https://github.com/soveran/redisent)
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'redic-sentinels'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install redic-sentinels
28
+
29
+ ## Usage
30
+
31
+ ```ruby
32
+ sentinels = [
33
+ 'localhost:26379',
34
+ 'localhost:26380',
35
+ 'localhost:26381'
36
+ ]
37
+
38
+ redis = Redic::Sentinels.new sentinels: sentinels,
39
+ master_name: 'mymaster',
40
+ db: 1, # optional (default: 0)
41
+ password: 'pass' # optional
42
+
43
+ redis.call 'PING' # => 'PONG'
44
+ ```
45
+
46
+ ## Contributing
47
+
48
+ Bug reports and pull requests are welcome on GitHub at https://github.com/gabynaiman/redic-sentinels.
49
+
50
+ ## License
51
+
52
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
53
+
data/Rakefile ADDED
@@ -0,0 +1,68 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:spec) do |t|
5
+ t.libs << 'spec'
6
+ t.pattern = 'spec/**/*_spec.rb'
7
+ t.verbose = false
8
+ t.warning = false
9
+ t.loader = nil if ENV['TEST']
10
+ ENV['TEST'], ENV['LINE'] = ENV['TEST'].split(':') if ENV['TEST'] && !ENV['LINE']
11
+ t.options = ''
12
+ t.options << "--name=/#{ENV['NAME']}/ " if ENV['NAME']
13
+ t.options << "-l #{ENV['LINE']} " if ENV['LINE'] && ENV['TEST']
14
+ end
15
+
16
+ task :console do
17
+ require 'pry'
18
+ require 'redic-sentinels'
19
+ ARGV.clear
20
+ Pry.start
21
+ end
22
+
23
+ task default: :spec
24
+
25
+ namespace :redis do
26
+
27
+ REDIS_CONFIGURATIONS = Dir['config/*.conf'].map { |f| File.basename(f,'.conf')[6..-1] }
28
+
29
+ def start_redis(config)
30
+ args = config.start_with?('sentinel') ? '--sentinel' : ''
31
+ sh "sudo redis-server config/redis-#{config}.conf #{args}"
32
+ rescue => ex
33
+ puts "Cant start #{config}: #{ex.message}"
34
+ end
35
+
36
+ def stop_redis(config)
37
+ pidfile = File.expand_path "/tmp/redic-sentinels-#{config}.pid"
38
+ pid = File.read pidfile
39
+ sh "sudo kill -s TERM #{pid}"
40
+ rescue => ex
41
+ puts "Cant stop #{config}: #{ex.message}"
42
+ end
43
+
44
+ desc 'Start Redis Server for specific configuration (CONFIG=master)'
45
+ task :start do
46
+ start_redis ENV.fetch('CONFIG').downcase
47
+ end
48
+
49
+ namespace :start do
50
+ desc 'Start Redis Server for all configurations'
51
+ task :all do
52
+ REDIS_CONFIGURATIONS.each { |c| start_redis c }
53
+ end
54
+ end
55
+
56
+ desc 'Stop Redis Server for specific configuration (CONFIG=master)'
57
+ task :stop do
58
+ stop_redis ENV.fetch('CONFIG').downcase
59
+ end
60
+
61
+ namespace :stop do
62
+ desc 'Stop Redis Server for all configurations'
63
+ task :all do
64
+ REDIS_CONFIGURATIONS.each { |c| stop_redis c }
65
+ end
66
+ end
67
+
68
+ end