rubypitaya 2.7.4 → 2.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 623c57d88899a89b5ff791d083b7f6025922f2b3a2c69d4d11ba2b7d328fb1c5
4
- data.tar.gz: fae9b7a11220d84d71f3775d6daeabf24628dd2db9eb48a2cf0b235643c864f3
3
+ metadata.gz: 78c0e17a12d24e8681424de7febeb3c496362c9efb6ddba566e2cb5a94a8e076
4
+ data.tar.gz: c01c5cdc3bd4adf77d1fae5479418d1f09f693e157b1bb28bc458260841198ee
5
5
  SHA512:
6
- metadata.gz: e3dd0f6775614ab1462fc2651582f9ad25850d52de90889b756879dd02bc0446f20564656b8d90bbb98d79a25a5da6bcb0c7dbcf220afd571a5643a6fa61d5b5
7
- data.tar.gz: 7316e7f5846839f4c59ebf2607da8f032b10560c03ba80e19b4a551f528ef96587516b9d516c340b128ef443791642ad23299d3c4e7886a8a28b2d943825a840
6
+ metadata.gz: 2e54976ad166dfef5c686cbd75cabb7c15e2dbb991aa7946b43a120213e26d1fa46b414212d9c1d18a970b17a6689ac89c38c8bedc075670d0ed4ea9a1050253
7
+ data.tar.gz: d510fcd44c66d24be9b7f07de8184f8fbff14d24308abd7955f9d156a2d056bc7417b47cf9c50da0ad9b17e307f7471949b50883b542118a029376c6f35f36f2
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'rubypitaya', '2.7.4'
3
+ gem 'rubypitaya', '2.7.5'
4
4
 
5
5
  group :development do
6
6
  gem 'pry', '0.12.2'
@@ -69,7 +69,7 @@ GEM
69
69
  rspec-support (~> 3.8.0)
70
70
  rspec-support (3.8.3)
71
71
  ruby2_keywords (0.0.2)
72
- rubypitaya (2.7.4)
72
+ rubypitaya (2.7.5)
73
73
  activerecord (= 6.0.2)
74
74
  etcdv3 (= 0.10.2)
75
75
  eventmachine (= 1.2.7)
@@ -106,7 +106,7 @@ DEPENDENCIES
106
106
  listen (= 3.2.1)
107
107
  pry (= 0.12.2)
108
108
  rspec (= 3.8.0)
109
- rubypitaya (= 2.7.4)
109
+ rubypitaya (= 2.7.5)
110
110
 
111
111
  BUNDLED WITH
112
112
  1.17.2
@@ -27,6 +27,13 @@ module MyApp
27
27
  # - methods:
28
28
  # - [](key)
29
29
  # - get config file by config path
30
+ # - log
31
+ # - class: Logger
32
+ # - link: https://ruby-doc.org/stdlib-2.6.4/libdoc/logger/rdoc/Logger.html
33
+ # - methods:
34
+ # - info
35
+ # - log information
36
+
30
37
 
31
38
  def run(initializer_content)
32
39
  bll = initializer_content.bll
@@ -56,6 +56,7 @@ services:
56
56
  working_dir: '/app/rubypitaya'
57
57
  volumes:
58
58
  - '.:/app/rubypitaya'
59
+ - '/var/run/docker.sock:/var/run/docker.sock'
59
60
  ports:
60
61
  - '80:4567'
61
62
  environment:
@@ -1,7 +1,7 @@
1
1
  FROM ruby:2.6.6
2
2
 
3
3
  RUN apt update
4
- RUN apt install -y git vim postgresql-client --no-install-recommends
4
+ RUN apt install -y git vim postgresql-client docker.io --no-install-recommends
5
5
 
6
6
  WORKDIR /app/rubypitaya/
7
7
 
@@ -2,7 +2,7 @@ kind: Role
2
2
  apiVersion: apps/v1
3
3
  metadata:
4
4
  namespace: default
5
- name: namespace
5
+ name: rubypitaya
6
6
  rules:
7
7
  - apiGroups:
8
8
  - ""
@@ -4,10 +4,11 @@ module RubyPitaya
4
4
 
5
5
  class_attribute :non_authenticated_routes, default: []
6
6
 
7
- attr_accessor :bll, :redis, :setup, :config, :params, :session, :postman
7
+ attr_accessor :bll, :log, :redis, :setup, :config, :params, :session, :postman
8
8
 
9
9
  def initialize
10
10
  @bll = nil
11
+ @log = nil
11
12
  @redis = nil
12
13
  @setup = nil
13
14
  @config = nil
@@ -53,7 +53,7 @@ module RubyPitaya
53
53
  end
54
54
 
55
55
  def call(handler_name, action_name, session, postman, redis, setup, config,
56
- bll, params)
56
+ bll, log, params)
57
57
  unless @handler_name_map.include?(handler_name)
58
58
  return {
59
59
  code: StatusCodes::CODE_HANDLER_NOT_FOUND,
@@ -71,6 +71,7 @@ module RubyPitaya
71
71
  handler = @handler_name_map[handler_name]
72
72
 
73
73
  handler.bll = bll
74
+ handler.log = log
74
75
  handler.redis = redis
75
76
  handler.setup = setup
76
77
  handler.config = config
@@ -2,10 +2,11 @@ module RubyPitaya
2
2
 
3
3
  class InitializerContent
4
4
 
5
- attr_reader :bll, :redis, :setup, :config
5
+ attr_reader :bll, :log, :redis, :setup, :config
6
6
 
7
- def initialize(bll, redis, setup, config)
7
+ def initialize(bll, log, redis, setup, config)
8
8
  @bll = bll
9
+ @log = log
9
10
  @redis = redis
10
11
  @setup = setup
11
12
  @config = config
@@ -1,4 +1,5 @@
1
1
  require 'socket'
2
+ require 'logger'
2
3
  require 'securerandom'
3
4
  require 'active_model'
4
5
 
@@ -32,6 +33,12 @@ module RubyPitaya
32
33
  @environment_name = ENV.fetch("RUBYPITAYA_ENV") { 'development' }
33
34
  @is_development_environment = @environment_name == 'development'
34
35
 
36
+ @log = Logger.new('/proc/self/fd/1')
37
+ @log.level = Logger::INFO
38
+ @log.formatter = proc do |severity, datetime, progname, msg|
39
+ "#{msg}\n"
40
+ end
41
+
35
42
  @application_files_importer = ApplicationFilesImporter.new
36
43
  @application_files_importer.import
37
44
  @application_files_importer.auto_reload if @is_development_environment
@@ -72,6 +79,7 @@ module RubyPitaya
72
79
  @bll = InstanceHolder.new
73
80
 
74
81
  @initializer_content = InitializerContent.new(@bll,
82
+ @log,
75
83
  @redis_connector.redis,
76
84
  @setup,
77
85
  @config)
@@ -88,6 +96,7 @@ module RubyPitaya
88
96
 
89
97
  def run_http
90
98
  HttpRoutes.set :bll, @bll
99
+ HttpRoutes.set :log, @log
91
100
  HttpRoutes.set :setup, @setup
92
101
  HttpRoutes.set :config, @config
93
102
  HttpRoutes.set :views, [Path::HTTP_VIEWS_PATH] + Path::Plugins::HTTP_VIEWS_PATHS
@@ -107,7 +116,7 @@ module RubyPitaya
107
116
  Signal.trap("SIGQUIT") { throw :sig_shutdown }
108
117
  Signal.trap("SIGTERM") { throw :sig_shutdown }
109
118
 
110
- puts "Server started!"
119
+ @log.info "Server started!"
111
120
  run_nats_connection
112
121
  end
113
122
 
@@ -122,7 +131,7 @@ module RubyPitaya
122
131
  return if @is_shutting_down
123
132
  @is_shutting_down = true
124
133
 
125
- puts "Server shutting down..."
134
+ @log.info "Server shutting down..."
126
135
 
127
136
  @etcd_connector.disconnect
128
137
  @database_connector.disconnect
@@ -153,22 +162,22 @@ module RubyPitaya
153
162
 
154
163
  handler_name, action_name = message_route.split('.')[1..-1]
155
164
 
156
- puts "request -> route: #{message_route}"
157
- puts " -> data: #{message_data}"
165
+ @log.info "request -> route: #{message_route}"
166
+ @log.info " -> data: #{message_data}"
158
167
 
159
168
  response = @handler_router.call(handler_name, action_name, @session,
160
169
  @postman, @redis_connector.redis,
161
- @setup, @config, @bll, params)
170
+ @setup, @config, @bll, @log, params)
162
171
 
163
172
  delta_time_seconds = Time.now.to_i - start_time_seconds
164
173
 
165
- puts "response [#{delta_time_seconds}s] -> #{response.to_json}"
174
+ @log.info "response [#{delta_time_seconds}s] -> #{response.to_json}"
166
175
 
167
176
  response
168
177
  end
169
178
  rescue Exception => error
170
- puts "ERROR: #{error}"
171
- puts error.backtrace
179
+ @log.info "ERROR: #{error}"
180
+ @log.info error.backtrace
172
181
  run_nats_connection
173
182
  end
174
183
  end
@@ -1,3 +1,3 @@
1
1
  module RubyPitaya
2
- VERSION = '2.7.4'
2
+ VERSION = '2.7.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubypitaya
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.4
4
+ version: 2.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luciano Prestes Cavalcanti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-30 00:00:00.000000000 Z
11
+ date: 2020-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg