orchestration 0.2.6 → 0.2.7

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
  SHA1:
3
- metadata.gz: 3d452624b11c2d2502ad8f063deb3cdf860d471a
4
- data.tar.gz: 2d5fc17927a310c894a9f0ea894164d300bc512b
3
+ metadata.gz: 7371c8d7691770e73a17feb1c67095e5ff6d4f68
4
+ data.tar.gz: 6438dc68182cf8673c25137ac3b9676f69284fe7
5
5
  SHA512:
6
- metadata.gz: 5c6ad0de94e5d530ff11d82e5e5c6ddfc24e023bc29abce9daf99c1eaf55160dfea9b6d6e39290dd760b6f28884cfee5df31f09d411cbf12b4548e06cffc9530
7
- data.tar.gz: ea8d5d8ea15eb9754e69a2e74b69de1e124b34143342ba3edf3b33f39c37b5ab0fda1d66b8be2659e04c198df965c77dec46d8c28596fe662525b176df61f9ab
6
+ metadata.gz: '0888c846560554ea5b5d767b764af902c60902344501b18786283d033050d96f76a6a4ecc5906da48c00e959c22a3f8d1c318a1c3ee25651538fad932285d841'
7
+ data.tar.gz: 313e67474a01c8a3f9014fa914af1be67df44c94ec947b5dfd5c62bf62a109cd06964117764c6193cce940d079bf06e2a579b98926d7e2dd6fc5e97ac24533a1
data/README.md CHANGED
@@ -18,7 +18,7 @@ Containers are automatically created for the following dependencies:
18
18
  Add this line to your application's Gemfile:
19
19
 
20
20
  ```ruby
21
- gem 'orchestration', '~> 0.2.6'
21
+ gem 'orchestration', '~> 0.2.7'
22
22
  ```
23
23
 
24
24
  And then build your bundle:
@@ -1,6 +1,5 @@
1
1
  en:
2
2
  orchestration:
3
- unknown_scheme: "Unrecognised database adapter for URL scheme: %{scheme}"
4
3
  attempt_limit: "Unable to reconnect after %{limit} attempts. Aborting."
5
4
 
6
5
  application:
@@ -3,6 +3,8 @@
3
3
  module Orchestration
4
4
  module DockerCompose
5
5
  class MongoService
6
+ PORT = 27_020
7
+
6
8
  def initialize(config)
7
9
  @config = config
8
10
  end
@@ -28,7 +28,7 @@ module Orchestration
28
28
  end
29
29
 
30
30
  def host
31
- 'localhost'
31
+ '127.0.0.1'
32
32
  end
33
33
 
34
34
  def local_port
@@ -34,7 +34,7 @@ module Orchestration
34
34
  @adapter = adapter_object(base['adapter'])
35
35
  @settings = base.merge(@adapter.credentials)
36
36
  .merge(
37
- 'scheme' => scheme_name(base['adapter']),
37
+ 'scheme' => base['adapter'],
38
38
  'port' => DockerCompose::DatabaseService::PORT
39
39
  )
40
40
  end
@@ -90,37 +90,16 @@ module Orchestration
90
90
 
91
91
  {
92
92
  'host' => uri.hostname,
93
- 'adapter' => adapter_name(uri.scheme),
93
+ 'adapter' => uri.scheme,
94
94
  'port' => uri.port
95
95
  }.merge(query_params(uri))
96
96
  end
97
97
 
98
- def scheme_name(adapter_name)
99
- adapter_mapping.invert.fetch(adapter_name)
100
- end
101
-
102
- def adapter_name(scheme)
103
- name = adapter_mapping.fetch(scheme, nil)
104
-
105
- return name unless name.nil?
106
-
107
- raise ArgumentError,
108
- I18n.t('orchestration.unknown_scheme', scheme: scheme)
109
- end
110
-
111
98
  def query_params(uri)
112
99
  return {} if uri.query.nil?
113
100
 
114
101
  Hash[URI.decode_www_form(uri.query)]
115
102
  end
116
-
117
- def adapter_mapping
118
- {
119
- 'mysql' => 'mysql2',
120
- 'postgres' => 'postgresql',
121
- 'sqlite3' => 'sqlite3'
122
- }
123
- end
124
103
  end
125
104
  end
126
105
  end
@@ -50,6 +50,10 @@ module Orchestration
50
50
  # class we happen to be included in.
51
51
  self.class.parent.const_get(:Configuration)
52
52
  end
53
+
54
+ def devnull
55
+ File.open(File::NULL, 'w')
56
+ end
53
57
  end
54
58
  end
55
59
  end
@@ -14,17 +14,45 @@ module Orchestration
14
14
  return unless defined?(Mongoid)
15
15
  return unless File.exist?(@env.mongoid_configuration_path)
16
16
 
17
- @settings = config.fetch(@env.environment)
17
+ @settings = { clients_key => hosts_config }
18
18
  end
19
19
 
20
20
  def friendly_config
21
- "[mongoid] #{host}:#{local_port}"
21
+ "[mongoid] #{host}:#{local_port}/#{database}"
22
22
  end
23
23
 
24
24
  private
25
25
 
26
+ def hosts_config
27
+ {
28
+ 'default' => {
29
+ 'hosts' => ["#{host}:#{port}"],
30
+ 'database' => database
31
+ }
32
+ }
33
+ end
34
+
35
+ def database
36
+ config
37
+ .fetch(@env.environment)
38
+ .fetch(clients_key)
39
+ .fetch('default')
40
+ .fetch('database')
41
+ end
42
+
43
+ def port
44
+ DockerCompose::MongoService::PORT
45
+ end
46
+
47
+ def clients_key
48
+ return 'clients' if config.fetch(@env.environment).key?('clients')
49
+
50
+ # Support older Mongoid versions
51
+ 'sessions'
52
+ end
53
+
26
54
  def config
27
- YAML.safe_load(
55
+ @config ||= YAML.safe_load(
28
56
  File.read(@env.mongoid_configuration_path), [], [], true
29
57
  )
30
58
  end
@@ -9,14 +9,35 @@ module Orchestration
9
9
  dependencies 'mongoid'
10
10
 
11
11
  def connection_errors
12
+ return [Moped::Errors::ConnectionFailure] if defined?(Moped)
13
+
12
14
  [::Mongo::Error::NoServerAvailable]
13
15
  end
14
16
 
15
17
  def connect
18
+ silence_warnings
19
+
16
20
  # REVIEW: For some reason this is extremely slow. Worth trying
17
21
  # to see if there's a faster way to fail.
18
22
  Mongoid.load_configuration(@configuration.settings)
19
- !Mongoid.default_client.database_names.empty?
23
+ !default_client.database_names.empty?
24
+ end
25
+
26
+ private
27
+
28
+ def default_client
29
+ return Mongoid.default_client if Mongoid.respond_to?(:default_client)
30
+
31
+ # Support older versions of Mongoid
32
+ Mongoid.default_session
33
+ end
34
+
35
+ def silence_warnings
36
+ if defined?(Moped)
37
+ Moped.logger = Logger.new(devnull)
38
+ else
39
+ Mongoid.logger = Logger.new(devnull)
40
+ end
20
41
  end
21
42
  end
22
43
  end
@@ -22,12 +22,6 @@ module Orchestration
22
22
  connection.start
23
23
  connection.stop
24
24
  end
25
-
26
- private
27
-
28
- def devnull
29
- File.open(File::NULL, 'w')
30
- end
31
25
  end
32
26
  end
33
27
  end
@@ -57,10 +57,10 @@ wait-rabbitmq:
57
57
 
58
58
  docker: build push
59
59
 
60
- GIT_BRANCH:=BRANCH:=$(if $(BRANCH),$(BRANCH),$(shell git rev-parse --abbrev-ref HEAD))
60
+ GIT_BRANCH:=$(if $(BRANCH),$(BRANCH),$(shell git rev-parse --abbrev-ref HEAD))
61
61
 
62
62
  build:
63
- @echo "Preparing build."
63
+ @echo "Preparing build from ${GIT_BRANCH}"
64
64
  @mkdir -p ./docker/.build
65
65
  @git show ${GIT_BRANCH}:./Gemfile > ./docker/Gemfile
66
66
  @git show ${GIT_BRANCH}:./Gemfile.lock > ./docker/Gemfile.lock
@@ -1,6 +1,7 @@
1
1
  #!/bin/sh
2
2
  set -u
3
- useradd -u ${HOST_UID} -m -o owner
3
+ id owner >/dev/null 2>&1 || useradd -u ${HOST_UID} -m -o owner
4
4
  mkdir -p /application/tmp/pids
5
5
  chown -R owner:owner /application/tmp /application/log /application/db
6
+ rm -f /application/tmp/pids/unicorn.pid
6
7
  exec gosu owner "$@"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Orchestration
4
- VERSION = '0.2.6'
4
+ VERSION = '0.2.7'
5
5
  end
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require 'orchestration/version'
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- url = 'https://bitbucket.org/orchestration_developers/orchestration/src'
8
+ url = 'https://github.com/bobf/orchestration'
9
9
  spec.name = 'orchestration'
10
10
  spec.version = Orchestration::VERSION
11
11
  spec.authors = ['Bob Farrell']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orchestration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Farrell
@@ -336,7 +336,7 @@ files:
336
336
  - lib/orchestration/version.rb
337
337
  - lib/tasks/orchestration.rake
338
338
  - orchestration.gemspec
339
- homepage: https://bitbucket.org/orchestration_developers/orchestration/src
339
+ homepage: https://github.com/bobf/orchestration
340
340
  licenses: []
341
341
  metadata: {}
342
342
  post_install_message: