rookout 0.1.15 → 0.1.20

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: a79d1186aec6390fdce4b56f19a1a2586e91837e51e1e40d70b3290284f8ca0a
4
- data.tar.gz: bc0400c6406c42355a9aec84ad0655c37ae7546464e5b80bbc9d3d8a7ae1c330
3
+ metadata.gz: 481ca24b7cd172e3416b29fee18905c6282d589db6cb316b2aa4d5adab26da1a
4
+ data.tar.gz: 5e391b43a1e7177ef5c020bc64d133fb9e62810bc4596301b2ed7298d18182d6
5
5
  SHA512:
6
- metadata.gz: 181118c9440177b284e30570420d4b12bb5d9e5885605c2081695b07e128828460653fc74bfa8123cc0c87f1d5ec9d210eda05a553b64fd7cf19610cceb2ecb5
7
- data.tar.gz: 52f5f5a5c62b617f8936c5ee5e9ff6b3a5c2bad83dce5ea912275dcc0a762e636dae84b37cfa78803208247cc5d560ae24002d67b74452e91430f3e9e8280568
6
+ metadata.gz: 30d63371644e94dba222b0e63650158d92f1de63e96d4731dd4eaa300c6a8e2d8220cd6f93fdcc0fdee5aaf390d3170bb52ebbcb7e82d2611228a7341c15faed
7
+ data.tar.gz: 5d0c24c4f132464d38b547d68f221983500fb76d7a6a4b438378abdb5d6f3bfb7f924e8784ac64b9da9642f7f84b2bf5c9facaa835a2f3d75d103d4e72df615c
@@ -17,9 +17,14 @@ module Rookout
17
17
  if Time.now - @last_ping > @interval
18
18
  Logger.instance.debug "Sending Ping"
19
19
  @last_ping = Time.now
20
- @connection.ping Time.now.to_s do
21
- Logger.instance.debug "Got Ping reply"
22
- @last_pong = Time.now
20
+ begin
21
+ @connection.ping Time.now.to_s do
22
+ Logger.instance.debug "Got Ping reply"
23
+ @last_pong = Time.now
24
+ end
25
+ rescue RuntimeError, Errno::EPIPE
26
+ Logger.instance.debug "Failed to send ping"
27
+ break
23
28
  end
24
29
  end
25
30
 
@@ -2,6 +2,7 @@ module Rookout
2
2
  module ComWs
3
3
  require "openssl"
4
4
  require "websocket/driver"
5
+ require "uri"
5
6
 
6
7
  require_relative "../config"
7
8
  require_relative "../logger"
@@ -11,14 +12,12 @@ module Rookout
11
12
  def initialize url, proxy, token
12
13
  @token = token
13
14
  @connection = WebsocketConnection.new url, proxy
15
+ @proxy = proxy
14
16
  @driver = nil
15
- @error = nil
16
- @last_ping = nil
17
17
  end
18
18
 
19
19
  def connect
20
- # TODO: add proxy support
21
- @connection.connect
20
+ connection_error = nil
22
21
  @driver = WebSocket::Driver.client @connection
23
22
 
24
23
  headers.each do |key, value|
@@ -26,18 +25,20 @@ module Rookout
26
25
  end
27
26
 
28
27
  @driver.on :error do |error|
29
- @error = error
28
+ connection_error = error
30
29
  end
31
30
 
32
31
  # Connect to the remote server
33
- @driver.start
34
32
  # TODO: ADD CONNECT TIMEOUT
33
+ @connection.connect @driver
34
+ @driver.start
35
+
35
36
  while @driver.state == :connecting
36
37
  recv_data = @connection.read_char
37
38
  @driver.parse recv_data
38
39
  end
39
40
 
40
- raise Exceptions::RookWebsocketException, @error if @driver.state != :open
41
+ raise Exceptions::RookWebsocketException, connection_error if @driver.state != :open
41
42
  end
42
43
 
43
44
  def connection_pump message_handler
@@ -62,7 +63,12 @@ module Rookout
62
63
  def close
63
64
  return if @driver.nil?
64
65
 
65
- @driver.close
66
+ begin
67
+ @driver.close
68
+ rescue RuntimeError, Errno::EPIPE
69
+ # Protocol close may fail if the connection is already closed
70
+ nil
71
+ end
66
72
  @connection.close
67
73
  end
68
74
 
@@ -88,14 +94,36 @@ module Rookout
88
94
  @secure = %w[https wss].include? @uri.scheme
89
95
 
90
96
  @socket = nil
97
+
98
+ @proxy_connected = false
91
99
  end
92
100
 
93
- def connect
94
- if @secure
95
- @socket = ssl_connect
96
- else
97
- @socket = tcp_connect
101
+ def connect driver
102
+ @socket = tcp_connect
103
+
104
+ proxy_connect driver if @proxy
105
+
106
+ @socket = ssl_connect @socket if @secure
107
+ end
108
+
109
+ def proxy_connect driver
110
+ connection_error = nil
111
+ @proxy_connected = false
112
+ proxy = driver.proxy @proxy
113
+
114
+ proxy.on :connect do
115
+ @proxy_connected = true
98
116
  end
117
+
118
+ proxy.on :error do |error|
119
+ connection_error = error
120
+ end
121
+
122
+ proxy.start
123
+
124
+ proxy.parse read_char until @proxy_connected == true || !connection_error.nil?
125
+
126
+ raise Exceptions::RookProxyException, connection_error unless connection_error.nil?
99
127
  end
100
128
 
101
129
  attr_reader :url
@@ -118,13 +146,16 @@ module Rookout
118
146
  private
119
147
 
120
148
  def tcp_connect
121
- TCPSocket.new @uri.host,
122
- @uri.port || (@secure ? 443 : 80)
149
+ if @proxy
150
+ uri = URI(@proxy)
151
+ TCPSocket.new uri.host, uri.port
152
+ else
153
+ TCPSocket.new @uri.host,
154
+ @uri.port || (@secure ? 443 : 80)
155
+ end
123
156
  end
124
157
 
125
- def ssl_connect
126
- tcp_socket = tcp_connect
127
-
158
+ def ssl_connect tcp_socket
128
159
  ctx = ::OpenSSL::SSL::SSLContext.new
129
160
  ctx.min_version = ::OpenSSL::SSL::TLS1_2_VERSION
130
161
  cert_store = ::OpenSSL::X509::Store.new
@@ -1,3 +1,3 @@
1
1
  module Rookout
2
- COMMIT = "c6e9d699d0dd8a6d17e8c466c18ccc082a29e5aa".freeze
2
+ COMMIT = "f63d232fa7d56db9e3a82bdbbe8a1eafaea49ab3".freeze
3
3
  end
@@ -144,6 +144,12 @@ module Rookout
144
144
  end
145
145
  end
146
146
 
147
+ class RookInvalidLabel < ToolException
148
+ def initialize label_name
149
+ super "Invalid label: must not start with the '$' character (#{label_name})"
150
+ end
151
+ end
152
+
147
153
  class RookCrcMismatchException < ToolException
148
154
  def initialize filepath, expected, calculated
149
155
  super "Line CRC32s do not match! path: #{filepath}, expected: #{expected}, calculated:#{calculated}",
@@ -178,10 +184,22 @@ module Rookout
178
184
  end
179
185
  end
180
186
 
187
+ class RookProxyException < ToolException
188
+ def initialize error
189
+ super "Error from proxy #{error}", { "error" => error }
190
+ end
191
+ end
192
+
181
193
  class RookBadProtobuf < ToolException
182
194
  def initialize
183
195
  super 'Bad protobuf version. Please execute "bundle config force_ruby_platform true" before "bundler install".'
184
196
  end
185
197
  end
198
+
199
+ class RookBadProtobufPlatform < ToolException
200
+ def initialize platform
201
+ super "Bad protobuf platform: #{platform}"
202
+ end
203
+ end
186
204
  end
187
205
  end
@@ -12,11 +12,18 @@ module Rookout
12
12
  @start_options = nil
13
13
  end
14
14
 
15
+ def print_debug_messages
16
+ puts "[Rookout] Running in debug mode"
17
+ puts "[Rookout] Rookout SDK for ruby: " + Config.rookout_version
18
+ end
19
+
15
20
  def start options = {}
16
21
  return unless @rook.nil?
17
22
  throw_errors = options[:throw_errors] == true
18
23
  Config.debug = evaluate_flag options[:debug], "ROOKOUT_DEBUG"
19
24
 
25
+ print_debug_messages if Config.debug
26
+
20
27
  begin
21
28
  verify_env
22
29
 
@@ -75,7 +82,11 @@ module Rookout
75
82
  return unless File.exist? "/etc/alpine-release"
76
83
 
77
84
  protobuf = Gem::Specification.find_by_path "google/protobuf"
78
- raise RookBadProtobuf if protobuf.nil? || protobuf.platform != "ruby"
85
+ STDERR.puts RookBadProtobuf.new.message if protobuf.nil?
86
+ return unless protobuf.platform != "ruby"
87
+
88
+ error = RookBadProtobufPlatform.new protobuf.platform
89
+ STDERR.puts error.message
79
90
  end
80
91
 
81
92
  def configure_globals options
@@ -103,7 +114,7 @@ module Rookout
103
114
  proxy = evaluate_config options[:proxy], "ROOKOUT_PROXY"
104
115
  token = evaluate_config options[:token], "ROOKOUT_TOKEN"
105
116
 
106
- raise RookMissingToken if token.nil? && host == "wss://control.rookout.com"
117
+ raise RookMissingToken if token.nil? && !(host_specified options)
107
118
  verify_token token if token
108
119
 
109
120
  labels = stringify_labels(options[:labels]) || parse_labels(ENV["ROOKOUT_LABELS"])
@@ -115,6 +126,10 @@ module Rookout
115
126
  { host: host, port: port, proxy: proxy, token: token, labels: labels, async_start: async_start, fork: fork }
116
127
  end
117
128
 
129
+ def host_specified options
130
+ !options[:host].nil? || !ENV["ROOKOUT_CONTROLLER_HOST"].nil? || !ENV["ROOKOUT_AGENT_HOST"].nil?
131
+ end
132
+
118
133
  def evaluate_flag argument, env_var_name
119
134
  return true? argument unless argument.nil?
120
135
  true? ENV[env_var_name]
@@ -12,7 +12,8 @@ module Rookout
12
12
 
13
13
  def initialize
14
14
  # Detect unit tests
15
- if ($PROGRAM_NAME.end_with?("minitest_runner.rb") ||
15
+ if (Config.debug ||
16
+ $PROGRAM_NAME.end_with?("minitest_runner.rb") ||
16
17
  $PROGRAM_NAME.end_with?("tunit_or_minitest_in_folder_runner.rb")) &&
17
18
  Dir.pwd.end_with?("ruby-sdk")
18
19
  Config.logger_log_level = :DEBUG
@@ -1,3 +1,3 @@
1
1
  module Rookout
2
- VERSION = "0.1.15".freeze
2
+ VERSION = "0.1.20".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.15
4
+ version: 0.1.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liran Haimovitch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-04 00:00:00.000000000 Z
11
+ date: 2021-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: binding_of_caller
@@ -84,14 +84,14 @@ dependencies:
84
84
  name: google-style
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - '='
88
88
  - !ruby/object:Gem::Version
89
89
  version: 1.24.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - '='
95
95
  - !ruby/object:Gem::Version
96
96
  version: 1.24.0
97
97
  - !ruby/object:Gem::Dependency
@@ -268,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
268
  - !ruby/object:Gem::Version
269
269
  version: '0'
270
270
  requirements: []
271
- rubygems_version: 3.1.2
271
+ rubygems_version: 3.1.4
272
272
  signing_key:
273
273
  specification_version: 4
274
274
  summary: rookout is the Ruby SDK for the Rookout Debugging Platform