micro_service-node 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +47 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/generators/micro_service/node/active_record_generator.rb +24 -0
- data/lib/generators/micro_service/node/next_migration_version.rb +16 -0
- data/lib/generators/micro_service/node/node_generator.rb +11 -0
- data/lib/generators/micro_service/node/templates/migration_0.0.1.rb +14 -0
- data/lib/micro_service/node.rb +23 -0
- data/lib/micro_service/node/compatibility.rb +25 -0
- data/lib/micro_service/node/version.rb +7 -0
- data/micro_service-node.gemspec +41 -0
- metadata +219 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 089053bcd85c3cf48a5cacb7b483e18c95acb559
|
4
|
+
data.tar.gz: acc9f8e275cfa71a5fab49595b2b6dfab98d215f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d5dd8d51f2f90440e71b548ac6e4f446fcb828af8459144ea56dd235a703deaf67ab77138db518b9c71686536f6d271bbe071ec7f6533c0e808f323c4ea4e38a
|
7
|
+
data.tar.gz: 7e78396b966a73e71365f4a3d58a56ec1a2b14ed6f9fd14e46acdea79595125319b525335f3a0f7c855f4429fd4962aa0eb33b758a18e1e4d0ae892114681a67
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/micro_service-node.svg)](http://badge.fury.io/rb/micro_service-node)
|
2
|
+
[![Build Status](https://travis-ci.org/butchmarshall/ruby-micro_service-node.svg?branch=master)](https://travis-ci.org/butchmarshall/ruby-micro_service-node)
|
3
|
+
|
4
|
+
# MicroService::Node
|
5
|
+
|
6
|
+
ActiveRecord MicroService implementation for nodes used in a clustered configuration.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'micro_service-node'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install micro_service-node
|
23
|
+
|
24
|
+
then run
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
rails generate micro_service:node:active_record
|
28
|
+
bundle exec rake db:migrate
|
29
|
+
```
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
To the ActiveRecord model:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
MicroService::Node.new(...)
|
37
|
+
```
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/butchmarshall/ruby-micro_service-node.
|
42
|
+
|
43
|
+
|
44
|
+
## License
|
45
|
+
|
46
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
47
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "micro_service/node"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "generators/micro_service/node/node_generator"
|
2
|
+
require "generators/micro_service/node/next_migration_version"
|
3
|
+
require "rails/generators/migration"
|
4
|
+
require "rails/generators/active_record"
|
5
|
+
|
6
|
+
# Extend the HasDynamicColumnsGenerator so that it creates an AR migration
|
7
|
+
module MicroService
|
8
|
+
class Node < ::ActiveRecord::Base
|
9
|
+
class ActiveRecordGenerator < ::MicroService::Node::Generator
|
10
|
+
include Rails::Generators::Migration
|
11
|
+
extend NextMigrationVersion
|
12
|
+
|
13
|
+
source_paths << File.join(File.dirname(__FILE__), "templates")
|
14
|
+
|
15
|
+
def create_migration_file
|
16
|
+
migration_template "migration_0.0.1.rb", "db/migrate/add_micro_service_node_0_0_1_migration.rb"
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.next_migration_number(dirname)
|
20
|
+
::ActiveRecord::Generators::Base.next_migration_number dirname
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module MicroService
|
2
|
+
class Node < ::ActiveRecord::Base
|
3
|
+
module NextMigrationVersion
|
4
|
+
# while methods have moved around this has been the implementation
|
5
|
+
# since ActiveRecord 3.0
|
6
|
+
def next_migration_number(dirname)
|
7
|
+
next_migration_number = current_migration_number(dirname) + 1
|
8
|
+
if ::ActiveRecord::Base.timestamped_migrations
|
9
|
+
[Time.now.utc.strftime("%Y%m%d%H%M%S"), format("%.14d", next_migration_number)].max
|
10
|
+
else
|
11
|
+
format("%.3d", next_migration_number)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
require 'micro_service/node/compatibility'
|
3
|
+
|
4
|
+
module MicroService
|
5
|
+
class Node < ::ActiveRecord::Base
|
6
|
+
class Generator < Rails::Generators::Base
|
7
|
+
source_paths << File.join(File.dirname(__FILE__), 'templates')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class AddMicroServiceNode001Migration < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :micro_service_nodes do |t|
|
4
|
+
t.string :host
|
5
|
+
t.string :secret
|
6
|
+
|
7
|
+
t.timestamps null: false
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.down
|
12
|
+
drop_table :micro_service_nodes
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "active_support"
|
2
|
+
require "active_support/dependencies"
|
3
|
+
require "active_record"
|
4
|
+
|
5
|
+
require "micro_service/node/version"
|
6
|
+
require "micro_service/node/compatibility"
|
7
|
+
|
8
|
+
module MicroService
|
9
|
+
class Node < ::ActiveRecord::Base
|
10
|
+
self.table_name = "micro_service_nodes"
|
11
|
+
|
12
|
+
validates :secret, uniqueness: true
|
13
|
+
validates :host, uniqueness: true
|
14
|
+
after_initialize :initialize_secret
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def initialize_secret
|
19
|
+
require 'securerandom'
|
20
|
+
self.secret ||= "#{SecureRandom.base64(24)}.s"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'micro_service/node/version'
|
2
|
+
|
3
|
+
module MicroService
|
4
|
+
class Node < ::ActiveRecord::Base
|
5
|
+
module Compatibility
|
6
|
+
if ActiveSupport::VERSION::MAJOR >= 4
|
7
|
+
require 'active_support/proxy_object'
|
8
|
+
def self.executable_prefix
|
9
|
+
'bin'
|
10
|
+
end
|
11
|
+
def self.proxy_object_class
|
12
|
+
ActiveSupport::ProxyObject
|
13
|
+
end
|
14
|
+
else
|
15
|
+
require 'active_support/basic_object'
|
16
|
+
def self.executable_prefix
|
17
|
+
'script'
|
18
|
+
end
|
19
|
+
def self.proxy_object_class
|
20
|
+
ActiveSupport::BasicObject
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'micro_service/node/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "micro_service-node"
|
8
|
+
spec.version = MicroService::Node::VERSION
|
9
|
+
spec.authors = ["Butch Marshall"]
|
10
|
+
spec.email = ["butch.a.marshall@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "ActiveRecord implementation to store MicroService::Nodes"
|
13
|
+
spec.description = "MicroService::Nodes so service instances can communicate"
|
14
|
+
spec.homepage = "https://github.com/butchmarshall/micro_service-node"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "activerecord", [">= 3.0", "<= 5.0"]
|
22
|
+
spec.add_dependency "validate_url"
|
23
|
+
|
24
|
+
spec.add_dependency "micro_service-client"
|
25
|
+
|
26
|
+
if RUBY_PLATFORM == 'java'
|
27
|
+
spec.add_development_dependency "jdbc-sqlite3", "> 0"
|
28
|
+
spec.add_development_dependency "activerecord-jdbcsqlite3-adapter", "> 0"
|
29
|
+
else
|
30
|
+
spec.add_development_dependency "sqlite3", "> 0"
|
31
|
+
end
|
32
|
+
|
33
|
+
spec.add_development_dependency "bigdecimal", "~> 1.1"
|
34
|
+
spec.add_development_dependency "database_cleaner"
|
35
|
+
spec.add_development_dependency "factory_girl", "> 4.0"
|
36
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
37
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
38
|
+
|
39
|
+
spec.add_development_dependency "rspec"
|
40
|
+
spec.add_development_dependency "webmock"
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,219 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: micro_service-node
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Butch Marshall
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
- - "<="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.0'
|
30
|
+
- - "<="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: validate_url
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: micro_service-client
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: sqlite3
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: bigdecimal
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '1.1'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '1.1'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: database_cleaner
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: factory_girl
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '4.0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '4.0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: bundler
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '1.7'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '1.7'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: rake
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '10.0'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - "~>"
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '10.0'
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: rspec
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
type: :development
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: webmock
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
description: MicroService::Nodes so service instances can communicate
|
174
|
+
email:
|
175
|
+
- butch.a.marshall@gmail.com
|
176
|
+
executables: []
|
177
|
+
extensions: []
|
178
|
+
extra_rdoc_files: []
|
179
|
+
files:
|
180
|
+
- ".gitignore"
|
181
|
+
- ".rspec"
|
182
|
+
- ".travis.yml"
|
183
|
+
- Gemfile
|
184
|
+
- README.md
|
185
|
+
- Rakefile
|
186
|
+
- bin/console
|
187
|
+
- bin/setup
|
188
|
+
- lib/generators/micro_service/node/active_record_generator.rb
|
189
|
+
- lib/generators/micro_service/node/next_migration_version.rb
|
190
|
+
- lib/generators/micro_service/node/node_generator.rb
|
191
|
+
- lib/generators/micro_service/node/templates/migration_0.0.1.rb
|
192
|
+
- lib/micro_service/node.rb
|
193
|
+
- lib/micro_service/node/compatibility.rb
|
194
|
+
- lib/micro_service/node/version.rb
|
195
|
+
- micro_service-node.gemspec
|
196
|
+
homepage: https://github.com/butchmarshall/micro_service-node
|
197
|
+
licenses: []
|
198
|
+
metadata: {}
|
199
|
+
post_install_message:
|
200
|
+
rdoc_options: []
|
201
|
+
require_paths:
|
202
|
+
- lib
|
203
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - ">="
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '0'
|
208
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
209
|
+
requirements:
|
210
|
+
- - ">="
|
211
|
+
- !ruby/object:Gem::Version
|
212
|
+
version: '0'
|
213
|
+
requirements: []
|
214
|
+
rubyforge_project:
|
215
|
+
rubygems_version: 2.4.6
|
216
|
+
signing_key:
|
217
|
+
specification_version: 4
|
218
|
+
summary: ActiveRecord implementation to store MicroService::Nodes
|
219
|
+
test_files: []
|