radar-app 0.9.0 → 0.10.0

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: 8903361bd6e9ce3c13909e031057e647377da02d
4
- data.tar.gz: dc56e484252d63d3de3a211587f379f9c1e1d6d0
2
+ SHA256:
3
+ metadata.gz: 9968d291e85ae6a4ab8301ee64bc479a539862bb1c38a6fb863824e11a1c1575
4
+ data.tar.gz: 77a8cca4490407185c660f3f38be20102d7e228e083c29a23721fd80021deaba
5
5
  SHA512:
6
- metadata.gz: e611e556f141036fa70873e0eb648f21c34351da61e435afdeff6b58433c44eddcbac267583005778dc074308616904f49dc0926bef77bfd18bc9d9a5fe66ccc
7
- data.tar.gz: 4f53ea0ca3b7c36c8f9336b175fdd92bd8353c9d519b2df6bc91b7506b257fe1ca86337b8c050568ce31584bf9146008e4c780cdeb4cd372f414758f8955b249
6
+ metadata.gz: e9f699c85c8b82f9a8728b3dc83a2fdb0fd8d2ba6ce4fee999f146886fc07981ac6743093ee43961e6ce2e9e4d47c0632c845efcf04c9c3abf03eb899ead2fc8
7
+ data.tar.gz: f6850b2b331a259fb95df90929db17bb6c79c84853a88ed1b9c88b4948d7a21104ef017df7b9c1b5d3b4fff3198e3a141fa7d114cc0fbd64d923155abb787a5f
data/Guardfile CHANGED
@@ -1,4 +1,4 @@
1
- guard :rspec do
1
+ guard :rspec, cmd: "bundle exec rspec" do
2
2
  watch(%r{^spec/.+_spec\.rb$})
3
3
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
4
  watch('spec/spec_helper.rb') { "spec" }
@@ -8,3 +8,12 @@ guard 'rake', :task => 'install' do
8
8
  watch(%r{^lib/(.+)\.rb$})
9
9
  watch(/^bin/)
10
10
  end
11
+
12
+ # Note: The cmd option is now required due to the increasing number of ways
13
+ # rspec may be run, below are examples of the most common uses.
14
+ # * bundler: 'bundle exec rspec'
15
+ # * bundler binstubs: 'bin/rspec'
16
+ # * spring: 'bin/rspec' (This will use spring if running and you have
17
+ # installed the spring binstubs per the docs)
18
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
19
+ # * 'just' rspec: 'rspec'
data/lib/radar/app.rb CHANGED
@@ -7,7 +7,9 @@ require 'radar/app/analyzer_controller'
7
7
  require 'radar/app/server'
8
8
  require 'radar/app/bootstrap'
9
9
  require 'radar/app/analyzer'
10
+ require 'radar/app/healthz'
10
11
  require 'radar/app/processor_factory'
12
+ require 'radar/app/multiplexed_processor'
11
13
 
12
14
  require 'radar-api'
13
15
  require 'connection_pool'
@@ -0,0 +1,9 @@
1
+ module Radar
2
+ module App
3
+ class Healthz
4
+ def status
5
+ Radar::API::HealthStatus::HEALTHY
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,20 @@
1
+ class Radar::App::MultiplexedProcessor < Thrift::MultiplexedProcessor
2
+ def process(iprot, oprot)
3
+ begin
4
+ name, type, seqid = iprot.read_message_begin
5
+ super(Thrift::StoredMessageProtocol.new(iprot, [name, type, seqid]), oprot)
6
+ rescue Thrift::Exception => e
7
+ write_error(Thrift::ApplicationException.new(Thrift::ApplicationException::INTERNAL_ERROR, e.message), oprot, name, seqid)
8
+ end
9
+ end
10
+
11
+ protected
12
+
13
+ def write_error(err, oprot, name, seqid)
14
+ oprot.write_message_begin(name, Thrift::MessageTypes::EXCEPTION, seqid)
15
+ err.write(oprot)
16
+ oprot.write_message_end
17
+ oprot.trans.flush
18
+ end
19
+
20
+ end
@@ -8,6 +8,7 @@ module Radar
8
8
  register(Radar::App::Tasks::New, :new, 'new APP', 'Create a new app')
9
9
  register(Radar::App::Tasks::Generate, :generate, 'generate TYPE NAME', 'Generate source files')
10
10
  register(Radar::App::Tasks::Server, :server, 'server', 'Start the app server')
11
+ register(Radar::App::Tasks::Status, :status, 'status', 'Check the server status')
11
12
  register(Radar::App::Tasks::Console, :console, 'console', 'Start the console for test')
12
13
  end
13
14
  end
@@ -7,7 +7,7 @@ module Radar
7
7
  include Radar::App::Logger
8
8
 
9
9
  def start
10
- multiplexer = Thrift::MultiplexedProcessor.new
10
+ multiplexer = MultiplexedProcessor.new
11
11
  analyzer_controller = Radar::App::AnalyzerController.new
12
12
  multiplexer.register_processor(
13
13
  'PortfolioAnalyzer',
@@ -28,6 +28,11 @@ module Radar
28
28
  new(Radar::App.transaction_file_importer)
29
29
  )
30
30
  end
31
+ multiplexer.register_processor(
32
+ 'Healthz',
33
+ ProcessorFactory.create_processor(Radar::API::Healthz::Processor).
34
+ new(Radar::App::Healthz.new)
35
+ )
31
36
  transport = Thrift::ServerSocket.new(port)
32
37
  server = Thrift::NonblockingServer.new(multiplexer, transport, Thrift::FramedTransportFactory.new)
33
38
  logger.info { "Starting app on port #{port}..." }
@@ -2,3 +2,4 @@ require 'radar/app/tasks/new'
2
2
  require 'radar/app/tasks/server'
3
3
  require 'radar/app/tasks/generate'
4
4
  require 'radar/app/tasks/console'
5
+ require 'radar/app/tasks/status'
@@ -1,3 +1,5 @@
1
+ require 'sigdump'
2
+
1
3
  module Radar
2
4
  module App
3
5
  module Tasks
@@ -6,6 +8,7 @@ module Radar
6
8
  namespace :server
7
9
 
8
10
  def start_server
11
+ Sigdump.setup('TTIN', '-')
9
12
  Radar::App::Bootstrap.startup
10
13
  Radar::App::Server.new(ENV['PORT'] || 5000).start
11
14
  end
@@ -0,0 +1,32 @@
1
+ require 'thrift'
2
+ require 'radar-api'
3
+
4
+ module Radar
5
+ module App
6
+ module Tasks
7
+ class Status < Thor::Group
8
+ include Thor::Actions
9
+ namespace :status
10
+
11
+ def status
12
+ transport = Thrift::FramedTransport.new(Thrift::Socket.new('127.0.0.1', ENV['PORT'] || 5000))
13
+ protocol = Thrift::MultiplexedProtocol.new(Thrift::BinaryProtocolAccelerated.new(transport), 'Healthz')
14
+ client = Radar::API::Healthz::Client.new(protocol)
15
+ begin
16
+ transport.open
17
+ client.status
18
+ rescue Thrift::TransportException => e
19
+ case e.type
20
+ when 1
21
+ puts "Server is down!"
22
+ else
23
+ puts "Server is not ready: #{e}"
24
+ end
25
+ exit 100 + e.type
26
+ end
27
+ puts "Server is up!"
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,5 +1,5 @@
1
1
  module Radar
2
2
  module App
3
- VERSION = "0.9.0"
3
+ VERSION = "0.10.0"
4
4
  end
5
5
  end
data/radar-app.gemspec CHANGED
@@ -24,9 +24,10 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "rspec"
25
25
 
26
26
  spec.add_dependency "thor", "~> 0.19"
27
- spec.add_dependency "radar-api", "~> 0.2"
27
+ spec.add_dependency "radar-api", ">= 0.10.0"
28
28
  spec.add_dependency "thin", "1.6.2"
29
29
  spec.add_dependency "connection_pool", "~> 2.0"
30
30
  spec.add_dependency "activesupport", "~> 4.1"
31
31
  spec.add_dependency "RaymondChou-thrift_client", "~> 0.9"
32
+ spec.add_dependency "sigdump", "~> 0.2.4"
32
33
  end
@@ -0,0 +1,26 @@
1
+ require 'radar/app/runner'
2
+ require 'radar/app'
3
+ require 'socket'
4
+
5
+ describe Radar::App::Tasks::Status do
6
+ describe '#status' do
7
+ let(:port) do
8
+ server = TCPServer.new('127.0.0.1', 0)
9
+ port = server.addr[1]
10
+ server.close
11
+ port
12
+ end
13
+ before :each do
14
+ allow(ENV).to receive(:[]).and_return nil
15
+ allow(ENV).to receive(:[]).with('PORT').and_return port
16
+ end
17
+ it 'exits with error code when cannot connect to server' do
18
+ expect { Radar::App::Runner.start(%w{status}) }.to raise_error SystemExit
19
+ end
20
+ it 'does not exit with error when PONG is received' do
21
+ Thread.new { @server = Radar::App::Server.new(port).start }
22
+ sleep 0.3
23
+ expect { Radar::App::Runner.start(%w{status}) }.not_to raise_error
24
+ end
25
+ end
26
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radar-app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonardo Mendonca
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-06-09 00:00:00.000000000 Z
12
+ date: 2019-08-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -85,16 +85,16 @@ dependencies:
85
85
  name: radar-api
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - "~>"
88
+ - - ">="
89
89
  - !ruby/object:Gem::Version
90
- version: '0.2'
90
+ version: 0.10.0
91
91
  type: :runtime
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - "~>"
95
+ - - ">="
96
96
  - !ruby/object:Gem::Version
97
- version: '0.2'
97
+ version: 0.10.0
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: thin
100
100
  requirement: !ruby/object:Gem::Requirement
@@ -151,6 +151,20 @@ dependencies:
151
151
  - - "~>"
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0.9'
154
+ - !ruby/object:Gem::Dependency
155
+ name: sigdump
156
+ requirement: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - "~>"
159
+ - !ruby/object:Gem::Version
160
+ version: 0.2.4
161
+ type: :runtime
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - "~>"
166
+ - !ruby/object:Gem::Version
167
+ version: 0.2.4
154
168
  description: generates and run a radar-app.
155
169
  email:
156
170
  - desenvolvimento@investtools.com.br
@@ -169,6 +183,7 @@ files:
169
183
  - bin/radar-app
170
184
  - lib/radar-app.rb
171
185
  - lib/radar/app.rb
186
+ - lib/radar/app/Healthz.rb
172
187
  - lib/radar/app/analyzer.rb
173
188
  - lib/radar/app/analyzer_controller.rb
174
189
  - lib/radar/app/bootstrap.rb
@@ -176,6 +191,7 @@ files:
176
191
  - lib/radar/app/core_ext.rb
177
192
  - lib/radar/app/core_ext/date.rb
178
193
  - lib/radar/app/logger.rb
194
+ - lib/radar/app/multiplexed_processor.rb
179
195
  - lib/radar/app/processor_factory.rb
180
196
  - lib/radar/app/runner.rb
181
197
  - lib/radar/app/server.rb
@@ -185,11 +201,13 @@ files:
185
201
  - lib/radar/app/tasks/generate.rb
186
202
  - lib/radar/app/tasks/new.rb
187
203
  - lib/radar/app/tasks/server.rb
204
+ - lib/radar/app/tasks/status.rb
188
205
  - lib/radar/app/version.rb
189
206
  - radar-app.gemspec
190
207
  - spec/lib/radar/app/analyzer_spec.rb
191
208
  - spec/lib/radar/app/processor_factory_spec.rb
192
209
  - spec/lib/radar/app/tasks/generate_spec.rb
210
+ - spec/lib/radar/app/tasks/status_spec.rb
193
211
  - templates/DOKKU_SCALE
194
212
  - templates/Gemfile
195
213
  - templates/Procfile
@@ -215,8 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
233
  - !ruby/object:Gem::Version
216
234
  version: '0'
217
235
  requirements: []
218
- rubyforge_project:
219
- rubygems_version: 2.5.1
236
+ rubygems_version: 3.0.4
220
237
  signing_key:
221
238
  specification_version: 4
222
239
  summary: radar-app generator
@@ -224,3 +241,4 @@ test_files:
224
241
  - spec/lib/radar/app/analyzer_spec.rb
225
242
  - spec/lib/radar/app/processor_factory_spec.rb
226
243
  - spec/lib/radar/app/tasks/generate_spec.rb
244
+ - spec/lib/radar/app/tasks/status_spec.rb