sensu-spawn 1.8.0 → 2.0.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
  SHA1:
3
- metadata.gz: 058ad7882b5371243ab74e37631b0a02a039c1fc
4
- data.tar.gz: 8d9a0574272c6062385cb476182e2a39a0061ccb
3
+ metadata.gz: 80a5ddfaf5cb5f4c364d433a3ba8916b571060d8
4
+ data.tar.gz: e9a0cfb1692724f8e67969160812dc6218f986fd
5
5
  SHA512:
6
- metadata.gz: 7cda93618978d84014179fe083e9404902c896e6acbefe73fbd30155fe2593ccbfbe2a1d845457e340aecf67cf1fc1e9e61fca5081a9d765c7d84dcff7349a75
7
- data.tar.gz: b1f4533e0718a8ffb0e30a6097e30e07efd159b8cb106db5e42398a7d99a410466dc5a9adf5a28a7bc45f6ea77c82270d16bf9da9abfcd1d204df120b17ecfff
6
+ metadata.gz: 9b71c329d9cb7a936a326775ff298269bf725c112e49db42900846475516e3d4bdc437da87501130636aedbf9d527040d60a457b023e697eacedb322ef7c7ad0
7
+ data.tar.gz: e49eace6222275956d35456253b7f1ed4e9c06545a1ce2cb8ea48541c9b71ebfbe421b3cd81632edc1037c72057d4e39c932ed7672b0386bee2634b7ac99b12f
data/lib/sensu/spawn.rb CHANGED
@@ -23,8 +23,20 @@ module Sensu
23
23
  @@mutex = Mutex.new
24
24
 
25
25
  class << self
26
- # Spawn a child process. A maximum of 12 processes will be
27
- # spawned at a time. The EventMachine reactor (loop) must be
26
+ # Setup a spawn process worker, to limit the number of
27
+ # concurrent child processes allowed at one time. This method
28
+ # creates the spawn process worker instance variable:
29
+ # `@process_worker`.
30
+ #
31
+ # @param [Hash] options to create a process worker with.
32
+ # @option options [Integer] :limit max number of child processes
33
+ # at a time.
34
+ def setup(options={})
35
+ limit = options[:limit] || 12
36
+ @process_worker ||= EM::Worker.new(:concurrency => limit)
37
+ end
38
+
39
+ # Spawn a child process. The EventMachine reactor (loop) must be
28
40
  # running for this method to work.
29
41
  #
30
42
  # @param [String] command to run.
@@ -37,7 +49,7 @@ module Sensu
37
49
  create = Proc.new do
38
50
  child_process(command, options)
39
51
  end
40
- @process_worker ||= EM::Worker.new(:concurrency => 12)
52
+ setup(options) unless @process_worker
41
53
  @process_worker.enqueue(create, callback)
42
54
  end
43
55
 
data/sensu-spawn.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "sensu-spawn"
5
- spec.version = "1.8.0"
5
+ spec.version = "2.0.0"
6
6
  spec.authors = ["Sean Porter"]
7
7
  spec.email = ["portertech@gmail.com"]
8
8
  spec.summary = "The Sensu spawn process library"
data/spec/spawn_spec.rb CHANGED
@@ -4,6 +4,10 @@ require "sensu/spawn"
4
4
  describe "Sensu::Spawn" do
5
5
  include Helpers
6
6
 
7
+ it "can setup a process worker" do
8
+ Sensu::Spawn.setup(:limit => 20)
9
+ end
10
+
7
11
  it "can spawn a process" do
8
12
  async_wrapper do
9
13
  Sensu::Spawn.process("echo foo") do |output, status|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-spawn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Porter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-10 00:00:00.000000000 Z
11
+ date: 2016-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  version: '0'
148
148
  requirements: []
149
149
  rubyforge_project:
150
- rubygems_version: 2.4.5.1
150
+ rubygems_version: 2.6.3
151
151
  signing_key:
152
152
  specification_version: 4
153
153
  summary: The Sensu spawn process library