rookout 0.1.42 → 0.1.43

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
  SHA256:
3
- metadata.gz: 1b7b251222795c20881099bbd6f64cb0e9c66c24f837403aecc29d5fc8737d22
4
- data.tar.gz: 488333717b7f9a0ef507d5a621caa4a37a99bd87a3f966e63808ba773aeb83ef
3
+ metadata.gz: 451da8de695dcbffddf0e548b213741155298be1877e390c7cbcb776a21744e6
4
+ data.tar.gz: 5d006c7a1e89e0ab1d6e407c4afa4e1410f50f2770e92c1cdc083498cee54af0
5
5
  SHA512:
6
- metadata.gz: fc9945c4fad24e0ebdee3bb83a1f71d353cef33bd14f9881007324ad2e82aba3292ba63cf54e54c14922547b1b68f6da58a1cdff99426dfd2a9bb85da78516cc
7
- data.tar.gz: 1848074ffaa23f2632457e42dec7c04f4527cb4cad80af234e9bc7dc3c7c72f63c786ee7dfcae3e1e3bff44eb8665fcfabf5be7dcde2ead58eb3234d72909796
6
+ metadata.gz: 743f3550703c0cfaa55527a185f014c31129761addff6584dbd01dc63d8bd0bc245188ce6cb51812de8ebb1c0d8ac1b6df9460c6a9f9c47b342ef5519cba1137
7
+ data.tar.gz: bb0dbcbb2ee6bbc8fa0b0d957e197021fb156e8a49fd2f8bd365072f665f23d7b7d6eb06bf490ccd880602f02dd43a226496d0e25dbb67e4c90932121a7d2f01
@@ -107,7 +107,9 @@ module Rookout
107
107
 
108
108
  unless config.nil? || config.empty?
109
109
  rate_limit_split = config.split "/"
110
- unless rate_limit_split.length == 2 && rate_limit_split[0].is_number? && rate_limit_split[1].is_number?
110
+ unless rate_limit_split.length == 2 && \
111
+ Utils.is_number?(rate_limit_split[0]) && \
112
+ Utils.is_number?(rate_limit_split[1])
111
113
  raise Exceptions::RookInvalidRateLimitConfiguration, config
112
114
  end
113
115
 
@@ -105,7 +105,6 @@ module Rookout
105
105
 
106
106
  private
107
107
 
108
- # rubocop:disable Style/StderrPuts
109
108
  def connection_thread
110
109
  backoff = Backoff.new
111
110
 
@@ -115,7 +114,8 @@ module Rookout
115
114
 
116
115
  if @print_on_initial_connection
117
116
  @print_on_initial_connection = false
118
- $stderr.puts "[Rookout] Successfully connected to controller"
117
+ Utils.quiet_puts "[Rookout] Successfully connected to controller"
118
+ Utils.quiet_puts "[Rookout] Rook's ID is #{@agent_id}"
119
119
  end
120
120
  Logger.instance.debug "WebSocket connected successfully"
121
121
  Logger.instance.info "Finished initialization"
@@ -139,13 +139,11 @@ module Rookout
139
139
  rescue Exception => e
140
140
  Logger.instance.error "Unexpected error in connection_thread", e
141
141
  end
142
- # rubocop:enable Style/StderrPuts
143
142
 
144
143
  def open_new_connection
145
144
  client = WebsocketClient.new @uri, @proxy, @token
146
145
  client.connect
147
146
 
148
- Logger.instance.info "Registering agent with id #{@agent_id}"
149
147
  msg = Com::Rookout::NewAgentMessage.new agent_info: @info.pack
150
148
  client.send_frame wrap_in_envelope(msg)
151
149
 
@@ -1,3 +1,3 @@
1
1
  module Rookout
2
- COMMIT = "17ed82e31d57aaaecc1244c11f0e10e673069d7e".freeze
2
+ COMMIT = "5444c2c813f2ee703b7bbcd51f5591ace3e1150f".freeze
3
3
  end
@@ -6,8 +6,10 @@ module Rookout
6
6
  # Magic to allow for module variables to be easily accessible
7
7
  class << self
8
8
  attr_accessor :debug
9
+ attr_accessor :quiet
9
10
 
10
11
  Rookout::Config.debug = false
12
+ Rookout::Config.quiet = false
11
13
 
12
14
  attr_accessor :logger_filename
13
15
  attr_accessor :logger_log_to_stderr
@@ -112,7 +114,7 @@ module Rookout
112
114
  quota = configuration["RUBY_GLOBAL_RATE_LIMIT_QUOTA_MS"]
113
115
  window_size = configuration["RUBY_GLOBAL_RATE_LIMIT_WINDOW_SIZE_MS"]
114
116
 
115
- if quota != "" && window_size != ""
117
+ if quota != "" && !quota.nil? && window_size != "" && !window_size.nil?
116
118
  global_rate_limit = "#{quota}/#{window_size}"
117
119
  end
118
120
  end
@@ -241,7 +241,7 @@ module Rookout
241
241
  def initialize config
242
242
  super "Invalid rate limit configuration: #{config}",
243
243
  {
244
- "rate_limit_config" => config
244
+ "config" => config
245
245
  }
246
246
  end
247
247
  end
@@ -4,6 +4,7 @@ module Rookout
4
4
  include Singleton
5
5
 
6
6
  require_relative "config"
7
+ require_relative "utils"
7
8
  require_relative "exceptions"
8
9
  include Exceptions
9
10
 
data/lib/rookout/utils.rb CHANGED
@@ -1,26 +1,34 @@
1
- module Utils
2
- require "securerandom"
1
+ module Rookout
2
+ module Utils
3
+ require "securerandom"
4
+ require_relative "config"
3
5
 
4
- module_function
6
+ module_function
5
7
 
6
- def uuid
7
- SecureRandom.uuid.gsub(/-/, "")
8
- end
8
+ def uuid
9
+ SecureRandom.uuid.gsub(/-/, "")
10
+ end
9
11
 
10
- def milliseconds_to_nanoseconds milliseconds
11
- nano = milliseconds * (10**6)
12
- nano.to_i
13
- end
12
+ def milliseconds_to_nanoseconds milliseconds
13
+ nano = milliseconds * (10**6)
14
+ nano.to_i
15
+ end
14
16
 
15
- def time_to_nanoseconds time_obj
16
- secs = time_obj.to_i
17
- nsecs = time_obj.nsec
18
- ((10**9) * secs) + nsecs
19
- end
20
- end
17
+ def time_to_nanoseconds time_obj
18
+ secs = time_obj.to_i
19
+ nsecs = time_obj.nsec
20
+ ((10**9) * secs) + nsecs
21
+ end
22
+
23
+ def quiet_puts msg
24
+ # rubocop:disable Style/StderrPuts
25
+ return if Config.quiet
26
+ $stderr.puts msg
27
+ # rubocop:enable Style/StderrPuts
28
+ end
21
29
 
22
- class String
23
- def is_number?
24
- to_f.to_s == self || to_i.to_s == self
30
+ def is_number? string
31
+ true if Float(string) rescue false
32
+ end
25
33
  end
26
34
  end
@@ -1,3 +1,3 @@
1
1
  module Rookout
2
- VERSION = "0.1.42".freeze
2
+ VERSION = "0.1.43".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rookout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.42
4
+ version: 0.1.43
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liran Haimovitch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-14 00:00:00.000000000 Z
11
+ date: 2022-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: binding_of_caller