mshard 0.6.1 → 0.7.0

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
  SHA256:
3
- metadata.gz: af238f64f52c0c36e7b42ebd1e841cac26d0c9484f20977d0d8e126874879256
4
- data.tar.gz: 54029b26089daaca48c4d4bc130235d93c5321304fc5fed6fe3e22f624f13bc9
3
+ metadata.gz: 0ce179b6ef6576d2dc2fd36969467a4abe3cefdd370f8441abb79abc8b322099
4
+ data.tar.gz: '0828489a9cd19625b367a8601794d6c8419ae4b1cb43d2390e13444f4701e1ef'
5
5
  SHA512:
6
- metadata.gz: d16eccc0f2bb2eff473fa521dc4493894c4dda217239b3eee5b70c96ceb5e34093b2bfdbb1618c446ada6b3a3bb2160c754bf2f24a994d30110734b3445fc9cf
7
- data.tar.gz: 9ea83010984fad616f675ddff46fcf604d634c9184bdc6a4cbffd9277eb834ddbb4faa96ea5ab3d4f8f06d6597fa7553ef7c562a194e81a6e9f91a7f7cda44a7
6
+ metadata.gz: 2be0b0a7363f4ac4c70e37412f20a73e90d5c5d41e7092a4d1190c22b9cd6c57cbc17f8c0486f9d419edde0026c905917444f69590e692951e444c23be039faf
7
+ data.tar.gz: 91c3f288a1a0d278ba63d9f8ab809a50a25e8ea6b46a337d6e94cf63e5d2656c9274f446a41726538a82552765833569ee26c8a9addda09452e19fc382fe1353
data/Gemfile.lock CHANGED
@@ -1,9 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mshard (0.6.1)
4
+ mshard (0.7.0)
5
+ hiredis
5
6
  httparty
6
7
  no_proxy_fix
8
+ redis
9
+ redis-namespace
7
10
  slack-notifier
8
11
  thor
9
12
 
@@ -37,6 +40,7 @@ GEM
37
40
  guard-rubocop (1.3.0)
38
41
  guard (~> 2.0)
39
42
  rubocop (~> 0.20)
43
+ hiredis (0.6.1)
40
44
  httparty (0.16.0)
41
45
  multi_xml (>= 0.5.2)
42
46
  json (2.1.0)
@@ -66,6 +70,9 @@ GEM
66
70
  rb-fsevent (0.10.3)
67
71
  rb-inotify (0.9.10)
68
72
  ffi (>= 0.5.0, < 2)
73
+ redis (4.0.1)
74
+ redis-namespace (1.6.0)
75
+ redis (>= 3.0.4)
69
76
  rspec (3.7.0)
70
77
  rspec-core (~> 3.7.0)
71
78
  rspec-expectations (~> 3.7.0)
data/lib/mshard/mshard.rb CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  require 'httparty'
4
4
  require 'no_proxy_fix'
5
+ require 'redis'
6
+ require 'redis/connection/hiredis'
7
+ require 'redis-namespace'
5
8
  require 'slack-notifier'
6
9
 
7
10
  module MShard
@@ -47,5 +50,19 @@ module MShard
47
50
  return set(args) if detour?
48
51
  Slack::Notifier.new(args[:webhook_url], **args).ping(args[:text])
49
52
  end
53
+
54
+ def load(id, redis_uri: ENV['MSHARD_REDIS_URI'])
55
+ return get(id) if detour? || redis_uri.nil?
56
+ redis = Redis::Namespace.new(:shard, redis: Redis.new(url: redis_uri))
57
+ redis.get(id)
58
+ end
59
+
60
+ def save(redis_uri: ENV['MSHARD_REDIS_URI'], **args)
61
+ return set(**args) if detour? || redis_uri.nil?
62
+ redis = Redis::Namespace.new(:shard, redis: Redis.new(url: redis_uri))
63
+ response = redis.set(args[:id], args[:contents])
64
+ raise response unless response == 'OK'
65
+ args[:id]
66
+ end
50
67
  end
51
68
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MShard
4
- VERSION = '0.6.1'
4
+ VERSION = '0.7.0'
5
5
  end
data/mshard.gemspec CHANGED
@@ -21,8 +21,11 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
21
21
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
22
  spec.require_paths = ['lib']
23
23
 
24
+ spec.add_dependency 'hiredis'
24
25
  spec.add_dependency 'httparty'
25
26
  spec.add_dependency 'no_proxy_fix'
27
+ spec.add_dependency 'redis'
28
+ spec.add_dependency 'redis-namespace'
26
29
  spec.add_dependency 'slack-notifier'
27
30
  spec.add_dependency 'thor'
28
31
  spec.add_development_dependency 'bundler', '~> 1.7'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mshard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minwoo Lee
@@ -10,6 +10,20 @@ bindir: exe
10
10
  cert_chain: []
11
11
  date: 2018-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hiredis
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: httparty
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +52,34 @@ dependencies:
38
52
  - - ">="
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: redis
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: redis-namespace
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
41
83
  - !ruby/object:Gem::Dependency
42
84
  name: slack-notifier
43
85
  requirement: !ruby/object:Gem::Requirement