micro_service_client 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/MIT-LICENSE +20 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/micro_service_client/application.js +13 -0
- data/app/assets/stylesheets/micro_service_client/application.css +15 -0
- data/app/controllers/micro_service_client/application_controller.rb +5 -0
- data/app/controllers/micro_service_client/servers_controller.rb +15 -0
- data/app/helpers/micro_service_client/application_helper.rb +4 -0
- data/app/jobs/micro_service_client/microservice_server_install_job.rb +21 -0
- data/app/views/layouts/micro_service_client/application.html.erb +14 -0
- data/config/routes.rb +6 -0
- data/lib/micro_service_client/concerns/controllers/servers.rb +50 -0
- data/lib/micro_service_client/engine.rb +5 -0
- data/lib/micro_service_client/version.rb +3 -0
- data/lib/micro_service_client.rb +6 -0
- data/lib/tasks/micro_service_client_tasks.rake +4 -0
- metadata +185 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fbe7f457089d3b3024a1bae093f022099afbd350
|
4
|
+
data.tar.gz: 5b0f709b21fccd4a7e637c2604716fe00cd6c05c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8d2f4d24508ada7f3acb3b2cfebaef34666d152c607738c79045ff572c3cfc543335039cd65f6b07416f106a27129d21999839a5a993acea788068c08e392c84
|
7
|
+
data.tar.gz: 812dbddb5ae9ef2df4fa325bf12acb48feb95df628d851785e7a72f15eb3cc2db002addbbf3160a4364f867cd46ae8c95d395d4aec53ea7c1bd4680448c6a352
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2016 Butch Marshall
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'MicroServiceClient'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
|
+
|
19
|
+
load 'rails/tasks/engine.rake'
|
20
|
+
load 'rails/tasks/statistics.rake'
|
21
|
+
|
22
|
+
Bundler::GemHelper.install_tasks
|
23
|
+
|
24
|
+
|
25
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
26
|
+
|
27
|
+
require 'rspec/core'
|
28
|
+
require 'rspec/core/rake_task'
|
29
|
+
|
30
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
31
|
+
|
32
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
33
|
+
|
34
|
+
task :default => :spec
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_dependency "micro_service_client/application_controller"
|
2
|
+
|
3
|
+
module Concerns
|
4
|
+
module Controllers
|
5
|
+
module Servers
|
6
|
+
extend MicroServiceClient::Concerns::Controllers::Servers
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module MicroServiceClient
|
12
|
+
class ServersController < ApplicationController
|
13
|
+
include Concerns::Controllers::Servers
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module MicroServiceClient
|
2
|
+
class MicroserviceServerInstallJob < ActiveJob::Base
|
3
|
+
queue_as :default
|
4
|
+
|
5
|
+
def perform(*args)
|
6
|
+
params = args.extract_options!
|
7
|
+
|
8
|
+
begin
|
9
|
+
MicroService::Server.new(params).save
|
10
|
+
# Failed to notify the microservice we successfully installed ourselves
|
11
|
+
rescue MicroService::Server::InstallError => $e
|
12
|
+
# Increment attempt number
|
13
|
+
params["attempt"] ||= 1
|
14
|
+
params["attempt"] = params["attempt"] + 1
|
15
|
+
|
16
|
+
# Try again in one minute
|
17
|
+
MicroserviceServerInstallJob.set(wait: 1.minute).perform_later(params) unless params["attempt"].to_i > 3
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>MicroServiceClient</title>
|
5
|
+
<%= stylesheet_link_tag "micro_service_client/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "micro_service_client/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
module MicroServiceClient
|
2
|
+
module Concerns
|
3
|
+
module Controllers
|
4
|
+
module Servers
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
def create
|
8
|
+
MicroserviceServerInstallJob.perform_later(install_params)
|
9
|
+
|
10
|
+
render :nothing => true, :status => 204
|
11
|
+
end
|
12
|
+
|
13
|
+
def destroy
|
14
|
+
status = 403
|
15
|
+
|
16
|
+
@server = MicroService::Server.where(uninstall_params).first
|
17
|
+
if @server && @server.update_attributes(:uninstalled => true)
|
18
|
+
status = 204
|
19
|
+
end
|
20
|
+
|
21
|
+
render :nothing => true, :status => status
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def json_params
|
26
|
+
ActionController::Parameters.new(JSON.parse(request.body.read))
|
27
|
+
end
|
28
|
+
|
29
|
+
def uninstall_params
|
30
|
+
data = json_params
|
31
|
+
|
32
|
+
data.permit(
|
33
|
+
:id,
|
34
|
+
:secret,
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
def install_params
|
39
|
+
data = json_params
|
40
|
+
|
41
|
+
data.permit(
|
42
|
+
:client_id,
|
43
|
+
:url,
|
44
|
+
:secret,
|
45
|
+
)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,185 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: micro_service_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Butch Marshall
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: micro_service-server
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
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: rspec-activejob
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: factory_girl_rails
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: capybara
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: database_cleaner
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: webmock
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: Mountable Rails engine for integrating with microservice servers
|
140
|
+
email:
|
141
|
+
- butch.a.marshall@gmail.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- MIT-LICENSE
|
147
|
+
- Rakefile
|
148
|
+
- app/assets/javascripts/micro_service_client/application.js
|
149
|
+
- app/assets/stylesheets/micro_service_client/application.css
|
150
|
+
- app/controllers/micro_service_client/application_controller.rb
|
151
|
+
- app/controllers/micro_service_client/servers_controller.rb
|
152
|
+
- app/helpers/micro_service_client/application_helper.rb
|
153
|
+
- app/jobs/micro_service_client/microservice_server_install_job.rb
|
154
|
+
- app/views/layouts/micro_service_client/application.html.erb
|
155
|
+
- config/routes.rb
|
156
|
+
- lib/micro_service_client.rb
|
157
|
+
- lib/micro_service_client/concerns/controllers/servers.rb
|
158
|
+
- lib/micro_service_client/engine.rb
|
159
|
+
- lib/micro_service_client/version.rb
|
160
|
+
- lib/tasks/micro_service_client_tasks.rake
|
161
|
+
homepage: https://github.com/butchmarshall/rails-micro_service_client
|
162
|
+
licenses:
|
163
|
+
- MIT
|
164
|
+
metadata: {}
|
165
|
+
post_install_message:
|
166
|
+
rdoc_options: []
|
167
|
+
require_paths:
|
168
|
+
- lib
|
169
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - ">="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
requirements: []
|
180
|
+
rubyforge_project:
|
181
|
+
rubygems_version: 2.4.6
|
182
|
+
signing_key:
|
183
|
+
specification_version: 4
|
184
|
+
summary: Rails engine for integrating with microservices
|
185
|
+
test_files: []
|