dynamodb-mutex 0.0.4 → 0.0.5

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
- SHA1:
3
- metadata.gz: 6021f2684e6d453eec6b6c571dc9579680720e09
4
- data.tar.gz: 73721ae381b3f05c1de835ceb819ee60ae5eeff3
2
+ SHA256:
3
+ metadata.gz: f3a77760615a522845fc8f07bddf52f6bec983d8d5fc7dae92c1d9fa4d69129d
4
+ data.tar.gz: 34e0bec90f3428ddd4dff85c402d9a06e2ac010fb1ef7e6e50623fecbdee49fc
5
5
  SHA512:
6
- metadata.gz: 6eec01b731fb9afa95fcd1352555f0be5bdd65bf141c94f6aadbe4509bc15ea04d1f67f18ea8b8aae1734753b6bfe6d6d7dd658eff979a3f932395a1f6da4122
7
- data.tar.gz: 0ccadf258c6e395214cf9e47e85beeef348351018a480acb9348d4cbdcdcfc8e8960fbd58bf75d7a46e04c4d1a6d886afe89fea05a1753ffbb78e14b412393c0
6
+ metadata.gz: 9462029628137e2a983a8d39a66ecab8ed5d665887a626bb0df51f2142b3ad01754e989c616066b7b8a5ad3ddc981b686620953e2aba8cbd44d5887d8d6bea92
7
+ data.tar.gz: 0d6af63b18901d4b862b34ffc5ffa93ed30a438dfca308fa8513ead80b9217b46c6d77cffb2a4617173c136b7029ecae529afea76b1dbca2bd2b72d35c2f8f28
data/README.rst CHANGED
@@ -1,9 +1,9 @@
1
1
  DynamoDB Mutex
2
2
  ==============
3
3
 
4
- .. image:: https://travis-ci.org/clearhaus/dynamodb-mutex.svg?branch=master
4
+ .. image:: https://circleci.com/gh/clearhaus/dynamodb-mutex.svg?style=shield
5
5
  :alt: Build Status
6
- :target: https://travis-ci.org/clearhaus/dynamodb-mutex
6
+ :target: https://circleci.com/gh/clearhaus/dynamodb-mutex
7
7
 
8
8
  .. image:: https://codeclimate.com/github/clearhaus/dynamodb-mutex/badges/gpa.svg
9
9
  :alt: Code Climate
@@ -1,4 +1,5 @@
1
- require 'aws-sdk'
1
+ require 'aws-sdk-dynamodb'
2
+
2
3
  require 'socket'
3
4
  require_relative 'logging'
4
5
 
@@ -1,4 +1,4 @@
1
1
 
2
2
  module DynamoDBMutex
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'.freeze
4
4
  end
@@ -53,6 +53,7 @@ describe DynamoDBMutex::Lock do
53
53
 
54
54
  ensure
55
55
  Process.kill('QUIT', child)
56
+ Process.waitpid(child)
56
57
  end
57
58
  end
58
59
 
@@ -69,6 +70,7 @@ describe DynamoDBMutex::Lock do
69
70
 
70
71
  ensure
71
72
  Process.kill('QUIT', child)
73
+ Process.waitpid(child)
72
74
  end
73
75
  end
74
76
 
@@ -1,46 +1,64 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
3
1
  require 'rspec'
4
- require 'fake_dynamo'
5
- require 'aws-sdk'
6
2
 
7
- Aws.config.update({
3
+ require 'aws-sdk-dynamodb'
4
+ require 'dynamodb-mutex'
5
+
6
+ Aws.config.update(
8
7
  credentials: Aws::Credentials.new(
9
8
  'your_access_key_id',
10
9
  'your_secret_access_key'
11
10
  ),
12
11
  endpoint: 'http://localhost:4567'
13
- })
12
+ )
14
13
 
15
- require 'dynamodb-mutex'
14
+ AMAZON_LOCAL_DYNAMODB_URL =
15
+ 'https://s3.eu-central-1.amazonaws.com/dynamodb-local-frankfurt/dynamodb_local_latest.tar.gz'.freeze
16
+ DYNAMODB_JAR_DIR = 'resources'.freeze
17
+ DYNAMODB_TMP_PATH = '/tmp/dynamodb_local_latest.tar.gz'.freeze
18
+
19
+ def fetch_amazon_dynamodb_local
20
+ Dir.mkdir(DYNAMODB_JAR_DIR) unless Dir.exist?(DYNAMODB_JAR_DIR)
21
+
22
+ return if File.exist?("./#{DYNAMODB_JAR_DIR}/DynamoDBLocal.jar")
23
+
24
+ system("wget #{AMAZON_LOCAL_DYNAMODB_URL} -O #{DYNAMODB_TMP_PATH} -q") ||
25
+ raise("Error downloading #{AMAZON_LOCAL_DYNAMODB_URL}")
26
+
27
+ system("tar -xf #{DYNAMODB_TMP_PATH} -C #{DYNAMODB_JAR_DIR}") ||
28
+ raise("Error unpacking #{DYNAMODB_TMP_PATH}")
29
+ end
30
+
31
+ def spawn_dynamodb
32
+ Dir.chdir(DYNAMODB_JAR_DIR)
33
+ $stdout.reopen('/dev/null', 'w')
34
+
35
+ exec('java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -inMemory -port 4567')
36
+ end
16
37
 
17
38
  RSpec.configure do |config|
18
- log_stream = ENV['DEBUG'] =~ (/^(true|t|yes|y|1)$/i) ? STDERR : StringIO.new
39
+ log_stream = ENV['DEBUG'] =~ /^(true|t|yes|y|1)$/i ? STDERR : StringIO.new
19
40
 
20
41
  DynamoDBMutex::Lock.logger = Logger.new(log_stream)
21
42
 
22
- dynamo_thread = nil
43
+ dynamo_pid = nil
23
44
 
24
45
  config.before(:suite) do
25
- FakeDynamo::Logger.setup(:debug)
26
- FakeDynamo::Storage.instance.init_db('test.fdb')
27
- FakeDynamo::Storage.instance.load_aof
28
-
29
- dynamo_thread = Thread.new do
30
- $stdout = log_stream # Throw FakeDynamo's stdout logging somewhere else.
31
- FakeDynamo::Server.run!(port: 4567, bind: 'localhost') do |server|
32
- if server.respond_to?('config') && server.config.respond_to?('[]=')
33
- server.config[:AccessLog] = []
34
- end
35
- end
46
+ # Download Amazons local DynamoDB and use that as an endpoint for specs.
47
+ fetch_amazon_dynamodb_local
48
+
49
+ dynamo_pid = Process.fork do
50
+ spawn_dynamodb
36
51
  end
37
- sleep(1)
52
+
53
+ [0.1, 0.5, 1, 3, 5, 7, 10].lazy.map do |sleep_interval|
54
+ Aws::DynamoDB::Client.new.list_tables rescue (sleep sleep_interval; false)
55
+ end.any? || raise('DynamoDB did not start in time')
38
56
  end
39
57
 
40
58
  config.after(:suite) do
41
- FakeDynamo::Storage.instance.shutdown
42
- dynamo_thread.exit if dynamo_thread
43
- FileUtils.rm('test.fdb', force: true)
59
+ if dynamo_pid
60
+ Process.kill('INT', dynamo_pid)
61
+ Process.waitpid(dynamo_pid)
62
+ end
44
63
  end
45
-
46
64
  end
metadata CHANGED
@@ -1,88 +1,74 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamodb-mutex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
- - Dinesh Yadav
7
+ - Clearhaus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-16 00:00:00.000000000 Z
11
+ date: 2018-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: aws-sdk
14
+ name: aws-sdk-dynamodb
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '1.6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '1.6'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rspec
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
32
- - !ruby/object:Gem::Version
33
- version: 2.0.0
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '>='
39
- - !ruby/object:Gem::Version
40
- version: 2.0.0
41
- - !ruby/object:Gem::Dependency
42
- name: rspec-mocks
28
+ name: rake
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - '>='
31
+ - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: '0'
33
+ version: '12.3'
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - '>='
38
+ - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: '0'
40
+ version: '12.3'
55
41
  - !ruby/object:Gem::Dependency
56
- name: rake
42
+ name: rspec
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - '>='
45
+ - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '0'
47
+ version: '2.0'
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
- - - '>='
52
+ - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '0'
54
+ version: '2.0'
69
55
  - !ruby/object:Gem::Dependency
70
- name: fake_dynamo
56
+ name: rspec-mocks
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - '='
59
+ - - "~>"
74
60
  - !ruby/object:Gem::Version
75
- version: 0.2.5
61
+ version: '3.7'
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - '='
66
+ - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: 0.2.5
68
+ version: '3.7'
83
69
  description: dynamodb-mutex implements a simple mutex that can be used to coordinate
84
70
  access to shared data from multiple concurrent hosts
85
- email: dy@clearhaus.com
71
+ email: hello@clearhaus.com
86
72
  executables: []
87
73
  extensions: []
88
74
  extra_rdoc_files: []
@@ -107,17 +93,17 @@ require_paths:
107
93
  - lib
108
94
  required_ruby_version: !ruby/object:Gem::Requirement
109
95
  requirements:
110
- - - '>='
96
+ - - ">="
111
97
  - !ruby/object:Gem::Version
112
98
  version: '0'
113
99
  required_rubygems_version: !ruby/object:Gem::Requirement
114
100
  requirements:
115
- - - '>='
101
+ - - ">="
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  requirements: []
119
105
  rubyforge_project:
120
- rubygems_version: 2.4.2
106
+ rubygems_version: 2.7.6
121
107
  signing_key:
122
108
  specification_version: 4
123
109
  summary: Distributed mutex based on AWS DynamoDB