nonnative 1.37.0 → 1.38.0

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: 7bcf9cffec3971770b2593b373938a6c084ab34381228bb2d9e43f794fb87d4a
4
- data.tar.gz: f1ef1bbb290b1a28d6036d06af5bf1230e32c22f4ea8e075c240480e807b212d
3
+ metadata.gz: 66174bae17db6e0fae12b8d0be37b1373c887687901a072e32914cb00bea1f08
4
+ data.tar.gz: a7430fe7c5d8bfd4a5a43fcf733fe80ef8fb1c8a25e78a2e22c5847518c547e7
5
5
  SHA512:
6
- metadata.gz: 8efcbbbbccf80e445d95c94207e521c8525a835abf544dd0f47ac37dad2e9af02ba2bd1af86a0475bc0c9c3db2f8d7d1b40be7487cf33ec7dbcdd4661125af34
7
- data.tar.gz: 1e69e4fd86e440c75b2ba4abf7eb1e929f3129e4d01b1a852ea9d0966e35e081ce6a4b40bb69ae3a984c1c36a743ae2b7c85f9af04a0fba5639afd451e636388
6
+ metadata.gz: 3b57cbc993f69dd8b051dcd51ccf2953dff7bede798fae49c75439e9d47b8dac8474f391d3050ec71af706bf75febfb681c65ddb247cbf7c87bc7d3d3f3e153f
7
+ data.tar.gz: 30f89fcd78a1a5eedb130f4707bb60246db7ad98df733cf13e6f39146a25c955d2664fb407e65ed318de28ab61b7f222a9e380abd50349c446ab1a7c39952953
data/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [1.38.0](https://github.com/alexfalkowski/nonnative/compare/v1.37.0...v1.38.0) (2021-04-22)
6
+
7
+
8
+ ### Features
9
+
10
+ * terminate connections on change ([#74](https://github.com/alexfalkowski/nonnative/issues/74)) ([6c1cc8e](https://github.com/alexfalkowski/nonnative/commit/6c1cc8e1c3f15d11848889852897b523f5848794))
11
+
12
+ ## [1.37.0](https://github.com/alexfalkowski/nonnative/compare/v1.36.0...v1.37.0) (2021-04-22)
13
+
14
+
15
+ ### Features
16
+
17
+ * simplify go exeutable ([#73](https://github.com/alexfalkowski/nonnative/issues/73)) ([95e4cf4](https://github.com/alexfalkowski/nonnative/commit/95e4cf44180ee84d32cc42ee058d6742732b57b9))
18
+
5
19
  ## [1.36.0](https://github.com/alexfalkowski/nonnative/compare/v1.35.2...v1.36.0) (2021-04-21)
6
20
 
7
21
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nonnative (1.37.0)
4
+ nonnative (1.38.0)
5
5
  concurrent-ruby (~> 1.0, >= 1.0.5)
6
6
  cucumber (>= 5, < 6)
7
7
  grpc (>= 1, < 2)
@@ -3,6 +3,7 @@
3
3
  module Nonnative
4
4
  class CloseAllSocketPair < SocketPair
5
5
  def connect(local_socket)
6
+ ensure
6
7
  local_socket.close
7
8
  end
8
9
  end
@@ -48,14 +48,7 @@ module Nonnative
48
48
  def perform_start
49
49
  loop do
50
50
  thread = Thread.start(tcp_server.accept) do |local_socket|
51
- id = Thread.current.object_id
52
-
53
- logger.info "started connection for #{id} with socket #{local_socket.inspect}"
54
-
55
- connect local_socket
56
- connections.delete(id)
57
-
58
- logger.info "finished connection for #{id} with socket #{local_socket.inspect}"
51
+ accept_connection local_socket
59
52
  end
60
53
 
61
54
  thread.report_on_exception = false
@@ -63,12 +56,32 @@ module Nonnative
63
56
  end
64
57
  end
65
58
 
59
+ def accept_connection(local_socket)
60
+ id = Thread.current.object_id
61
+ socket_info = local_socket.inspect
62
+
63
+ connect local_socket
64
+ connections.delete(id)
65
+ ensure
66
+ logger.info "handled connection for #{id} with socket #{socket_info}"
67
+ end
68
+
66
69
  def connect(local_socket)
67
- SocketPairFactory.create(read_state, service.proxy, logger).connect(local_socket)
70
+ pair = SocketPairFactory.create(read_state, service.proxy)
71
+
72
+ pair.connect(local_socket)
73
+ end
74
+
75
+ def close_connections
76
+ connections.each_value(&:terminate)
77
+ connections.clear
68
78
  end
69
79
 
70
80
  def apply_state(state)
71
- mutex.synchronize { @state = state }
81
+ mutex.synchronize do
82
+ @state = state
83
+ close_connections
84
+ end
72
85
  end
73
86
 
74
87
  def read_state
@@ -2,9 +2,8 @@
2
2
 
3
3
  module Nonnative
4
4
  class SocketPair
5
- def initialize(proxy, logger)
5
+ def initialize(proxy)
6
6
  @proxy = proxy
7
- @logger = logger
8
7
  end
9
8
 
10
9
  def connect(local_socket)
@@ -16,8 +15,6 @@ module Nonnative
16
15
  break if pipe(ready, local_socket, remote_socket)
17
16
  break if pipe(ready, remote_socket, local_socket)
18
17
  end
19
- rescue StandardError => e
20
- logger.error e
21
18
  ensure
22
19
  local_socket.close
23
20
  remote_socket&.close
@@ -25,7 +22,7 @@ module Nonnative
25
22
 
26
23
  protected
27
24
 
28
- attr_reader :proxy, :logger
25
+ attr_reader :proxy
29
26
 
30
27
  def create_remote_socket
31
28
  ::TCPSocket.new('0.0.0.0', proxy.port)
@@ -3,7 +3,7 @@
3
3
  module Nonnative
4
4
  class SocketPairFactory
5
5
  class << self
6
- def create(type, proxy, logger)
6
+ def create(type, proxy)
7
7
  pair = case type
8
8
  when :close_all
9
9
  CloseAllSocketPair
@@ -15,7 +15,7 @@ module Nonnative
15
15
  SocketPair
16
16
  end
17
17
 
18
- pair.new(proxy, logger)
18
+ pair.new(proxy)
19
19
  end
20
20
  end
21
21
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nonnative
4
- VERSION = '1.37.0'
4
+ VERSION = '1.38.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nonnative
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.37.0
4
+ version: 1.38.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Falkowski