pg-ephemeral 0.0.2-aarch64-linux → 0.0.3-aarch64-linux

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/pg-ephemeral +0 -0
  3. data/lib/pg_ephemeral.rb +24 -16
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99b910dc0813197f3ef7ac4cf811b0183375e8f44387bb2c1ff7ad759f04c15f
4
- data.tar.gz: ea1a15d473eacbadedff15104d36f3877779f7a674697c79fd797b7bb9227aba
3
+ metadata.gz: 45169bb80e9ec4a27cfd940185049da5b88b526803573a0cc6ffa2feaba74033
4
+ data.tar.gz: e80eb2e4a2493d08cb9f50c95d063aca4f9e8d8b58d39bf4cfd1671df195cadb
5
5
  SHA512:
6
- metadata.gz: f2b2fda631a07a27e64e3039ac5d48d424126891753bda25b480bd73f505513f7ed555c0310587cb73afab4121f0861f8df9abb12c8d6f035cc5768bf1ee929b
7
- data.tar.gz: 714a5cde214940c4821e1458d7b6bc55963bdc84bc752075766cb0f985adb0584369b04038600c44c7b49d6b77ddbede05ad4561cad330f635ed81e5589d2343
6
+ metadata.gz: 609a6f2c3dde0d73b9e26a5c0c045b4c0130edd425800229d950d0dca07f8b8273fb7a7c1a8421b0b7eadcafa9867e16a0846c7414afcd1b2172eaeba86fb6e1
7
+ data.tar.gz: 3e5ce1dfccf9bd797b532fbde1d010cff9b90f4c9f5fae6cc12f9ad53b8a2fa654e5efd053ffc16a36a023b1cd0c4545eddb4bd871e20b584588fc2a36e8d18e
data/bin/pg-ephemeral CHANGED
Binary file
data/lib/pg_ephemeral.rb CHANGED
@@ -50,6 +50,9 @@ module PgEphemeral
50
50
  end
51
51
 
52
52
  def self.run_server(instance_name, config, &block)
53
+ result_read, result_write = IO.pipe
54
+ control_read, control_write = IO.pipe
55
+
53
56
  command = [binary_path]
54
57
 
55
58
  if config
@@ -59,22 +62,27 @@ module PgEphemeral
59
62
  command.concat([
60
63
  'integration-server',
61
64
  '--instance', instance_name,
62
- '--protocol', 'v0'
65
+ '--result-fd', result_write.fileno.to_s,
66
+ '--control-fd', control_read.fileno.to_s
63
67
  ])
64
68
 
65
- Open3.popen2(*command) do |stdin, stdout, wait_thread|
66
- config_json = stdout.gets
69
+ pid = Process.spawn(*command, result_write.fileno => result_write, control_read.fileno => control_read)
67
70
 
68
- raise 'Failed to read server configuration' unless config_json
71
+ result_write.close
72
+ control_read.close
69
73
 
70
- url = JSON.parse(config_json).fetch('url')
71
- server = Server.new(url, stdin, wait_thread)
74
+ config_json = result_read.gets
75
+ result_read.close
72
76
 
73
- begin
74
- block.call(server)
75
- ensure
76
- server.shutdown
77
- end
77
+ raise 'Failed to read server configuration' unless config_json
78
+
79
+ url = JSON.parse(config_json).fetch('url')
80
+ server = Server.new(url, control_write, pid)
81
+
82
+ begin
83
+ block.call(server)
84
+ ensure
85
+ server.shutdown
78
86
  end
79
87
  end
80
88
  private_class_method :run_server
@@ -82,15 +90,15 @@ module PgEphemeral
82
90
  class Server
83
91
  attr_reader :url
84
92
 
85
- def initialize(url, stdin, wait_thread)
93
+ def initialize(url, control_write, pid)
86
94
  @url = url
87
- @stdin = stdin
88
- @wait_thread = wait_thread
95
+ @control_write = control_write
96
+ @pid = pid
89
97
  end
90
98
 
91
99
  def shutdown
92
- @stdin.close unless @stdin.closed?
93
- @wait_thread.value
100
+ @control_write.close unless @control_write.closed?
101
+ Process.wait(@pid)
94
102
  end
95
103
  end
96
104
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg-ephemeral
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Markus Schirp