Class: DynamoLocalRuby::DynamoDBLocal
- Inherits:
-
Object
- Object
- DynamoLocalRuby::DynamoDBLocal
- Defined in:
- lib/dynamo-local-ruby/dynamo_db_local.rb
Overview
Wrapper around Dynamo DB local process
Constant Summary collapse
- PORT =
9389
Class Method Summary collapse
Instance Method Summary collapse
-
#down ⇒ Object
rubocop:disable HandleExceptions.
-
#initialize(pid) ⇒ DynamoDBLocal
constructor
A new instance of DynamoDBLocal.
Constructor Details
#initialize(pid) ⇒ DynamoDBLocal
Returns a new instance of DynamoDBLocal.
8 9 10 |
# File 'lib/dynamo-local-ruby/dynamo_db_local.rb', line 8 def initialize(pid) @pid = pid end |
Class Method Details
.down ⇒ Object
29 30 31 |
# File 'lib/dynamo-local-ruby/dynamo_db_local.rb', line 29 def down @instance.down if defined? @instance end |
.endpoint(port = PORT) ⇒ Object
13 14 15 |
# File 'lib/dynamo-local-ruby/dynamo_db_local.rb', line 13 def endpoint(port = PORT) "http://localhost:#{port}" end |
.up(port = PORT) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dynamo-local-ruby/dynamo_db_local.rb', line 17 def up(port = PORT) local_path = File.('../../../lib/jars/dynamodb_local', __FILE__) lib_path = File.join(local_path, 'DynamoDBLocal_lib') jar_path = File.join(local_path, 'DynamoDBLocal.jar') pid = spawn("java -Djava.library.path=#{lib_path} -jar #{jar_path} "\ "-sharedDb -inMemory -port #{port}") @instance = DynamoDBLocal.new(pid) @instance end |
Instance Method Details
#down ⇒ Object
rubocop:disable HandleExceptions
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/dynamo-local-ruby/dynamo_db_local.rb', line 35 def down return unless @pid begin Process.kill('SIGINT', @pid) Process.waitpid2(@pid) rescue Errno::ECHILD, Errno::ESRCH # child process is dead end @pid = nil end |