quartz 1.1.0 → 1.2.0

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: b2e2fe4395a4d05407cfc6b760117f1a157357cda18e21434bc5d099367738af
4
- data.tar.gz: 8f8aefe61999b809eae8a46a5e3f39a99249ccee623f322237fb38100e4f52b0
3
+ metadata.gz: 1a22ff297e6904e0f037039526312cfcb4d2e22018d08c50216ea834b75067de
4
+ data.tar.gz: 48bfc68a088720318828cc2389c1373753da2d27b9f144101d00c377a8824178
5
5
  SHA512:
6
- metadata.gz: 5c105ff943245abb21c857543340778215c43c70d4a14c5f4d23a27674da8a7e6cffa3fa225e4b1b2314b49433482c6aae9bbe4d9e93413079bf16c86ca1a2d2
7
- data.tar.gz: 02a7eb9ec1e09ccc37d76fc5593069a756606ef9a44f947d945ceb96662755b69abd1dd775ecd0ec36a66ed30db7ced67a371927558102cac8696e90fb014b3b
6
+ metadata.gz: f9f0845a06d885e1706a07040937577765e3c4dfc0eb66ebfce73e5a79df5b4234de1c42c5077f95d0b1642323bd506ebcb4b2cf4494ebc356ce8384f678a37b
7
+ data.tar.gz: e1f1371656edb1f49e478dc4c99155f42fba25e0bd4a8f523b5bafc29997d4c0a87ec6df670a14c3c87070a1921195bb0eb140fd51ba1b428d88f51a21aba7e5
data/README.md CHANGED
@@ -125,6 +125,19 @@ you can pass the `socket_dir` option.
125
125
  client = Quartz::Client.new(bin_path: 'my_adder_binary', socket_dir: '/apps/my_app/tmp')
126
126
  ```
127
127
 
128
+ If you want to manage the Go process manually, you can use the
129
+ following system to set the socket path manually. Now, you can use
130
+ Systemd/Kubernetes/etc. to manage the Go process.
131
+
132
+ ```shell
133
+ $ QUARTZ_SOCKET=/tmp/custom.sock ./go_process
134
+ ```
135
+
136
+ ```ruby
137
+ client = Quartz::Client.new(socket_path: '/tmp/custom.sock')
138
+
139
+ ```
140
+
128
141
  ## Copyright
129
142
 
130
143
  Copyright (c) 2018 David Huie. See LICENSE.txt for further details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
@@ -24,7 +24,7 @@ class Quartz::GoProcess
24
24
  def initialize(opts)
25
25
  @seed = SecureRandom.hex
26
26
  socket_dir = opts.fetch(:socket_dir) { '/tmp' }
27
- @socket_path = File.join(socket_dir, "quartz_#{seed}.sock")
27
+ @socket_path = opts[:socket_path] || File.join(socket_dir, "quartz_#{seed}.sock")
28
28
  ENV['QUARTZ_SOCKET'] = @socket_path
29
29
 
30
30
  if opts[:file_path]
@@ -32,6 +32,8 @@ class Quartz::GoProcess
32
32
  compile_and_run(opts[:file_path])
33
33
  elsif opts[:bin_path]
34
34
  @go_process = IO.popen(opts[:bin_path])
35
+ elsif opts[:socket_path]
36
+ @external_socket = true
35
37
  else
36
38
  raise Quartz::ConfigError, 'Missing go binary'
37
39
  end
@@ -127,6 +129,9 @@ class Quartz::GoProcess
127
129
  # process will.
128
130
  return if @forked
129
131
 
132
+ # If the Go process is managed externally, there's nothing to do.
133
+ return if @external_socket
134
+
130
135
  unless @killed_go_process
131
136
  Process.kill('SIGTERM', pid)
132
137
  Process.wait(pid)
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: quartz 1.1.0 ruby lib
5
+ # stub: quartz 1.2.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "quartz".freeze
9
- s.version = "1.1.0"
9
+ s.version = "1.2.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
@@ -7,11 +7,14 @@ describe Quartz::GoProcess do
7
7
  describe '#get_metadata' do
8
8
 
9
9
  context 'with a go file' do
10
-
11
10
  it 'pulls metadata' do
12
11
  expect(process.get_metadata).to eq("adder" => {"NameToMethodMetadata"=>{"Add"=>{"ArgumentToType"=>{"A"=>"int", "B"=>"int"}}, "AddError"=>{"ArgumentToType"=>{"A"=>"int", "B"=>"int"}}}})
13
12
  end
14
13
 
14
+ it 'pulls metadata from the recycled socket' do
15
+ new_process = Quartz::GoProcess.new(socket_path: process.socket_path)
16
+ expect(new_process.socket_path).to eq(process.socket_path)
17
+ end
15
18
  end
16
19
 
17
20
  end
@@ -53,6 +56,23 @@ describe Quartz::GoProcess do
53
56
 
54
57
  end
55
58
 
59
+ context 'with a custom socket path' do
60
+
61
+ let(:new_process) { Quartz::GoProcess.new(socket_path: process.socket_path) }
62
+
63
+ it 'the new process does not clean up the existing socket' do
64
+ expect(File.exists?(new_process.socket_path)).to be_truthy
65
+ new_process.cleanup
66
+ expect(File.exists?(new_process.socket_path)).to be_truthy
67
+ end
68
+
69
+ it 'creates the socket in the socket dir' do
70
+ result = new_process.call('adder', 'Add', { 'A' => 5, 'B' => 6 })
71
+ expect(result).to eq({"id"=>1, "result"=>{"X"=>11}, "error"=>nil})
72
+ end
73
+
74
+ end
75
+
56
76
  describe '.cleanup' do
57
77
 
58
78
  context 'files' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quartz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Huie