autoscale-agent 0.2.0 → 0.2.1

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: 8eee5bfe7779587148bf96e20f474069cdc159921964a15c793032aacc1c5a8b
4
- data.tar.gz: 31973d0ed5d7e483447d4eb8361ccb83491873832f0ed7a62d2eeaf34cd3cca8
3
+ metadata.gz: 5e5fac211926fd32008d9b5a34821744f5641c8b8cb87d8eac252216120e4ff0
4
+ data.tar.gz: 4c18afc1684e781380dad1eefa25f1415b315659919138839d3e2b016042e5a9
5
5
  SHA512:
6
- metadata.gz: 7ec5e6defbb72526b04401ec95c9e548e5b7102e3d3df923ea25eac1b8d268bbb02d17ed03196e93c480401aed71ca1df7dcdb54b8f909ddb40301eb0fb93804
7
- data.tar.gz: 2e18fe0276aa512f1446533990c4e083fa68874b5826d4ab0adec9245d0020cb7ba77a437692a3e088707278e02c53b0f2fccf397daf3aec3c62a0757413a393
6
+ metadata.gz: c907c30ca3ad52721dcc9d702c2f2afcea7c14ca3851c60f3983ad7256bca5068d98c24b92416263bbc83ed915a3d9be1377597c4f8d7070c09099c5ee9c9012
7
+ data.tar.gz: 28c7a7328a84a2e8c30a8b98fb21a873ae5702fd23733c87023a53b4d3ab0b149fa19e56ae89642ac0e194081ff0b52bfed4fce4883c6c065552ce04ba362b9a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.1] - 2023-04-24
4
+
5
+ - Don't run WorkerDispatchers#run in a separate thread
6
+
7
+
3
8
  ## [0.2.0] - 2023-04-24
4
9
 
5
10
  - Change when and where dispatchers are run
data/README.md CHANGED
@@ -38,6 +38,14 @@ See Rake for relevant tasks:
38
38
 
39
39
  bin/rake -T
40
40
 
41
+ ## Release
42
+
43
+ 1. Finalize CHANGELOG.md
44
+ 2. Update version.rb
45
+ 3. Run `bundle install`
46
+ 4. Commit
47
+ 5. Create and push a new tag (`v1.2.3`)
48
+
41
49
  ## Contributing
42
50
 
43
51
  Bug reports and pull requests are welcome on GitHub at https://github.com/autoscale-app/ruby-agent
@@ -0,0 +1,16 @@
1
+ module Autoscale
2
+ module Agent
3
+ module Util
4
+ module_function
5
+
6
+ def loop_with_interval(interval, &block)
7
+ loop do
8
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
9
+ block.call
10
+ duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
11
+ sleep [0, interval - duration].max
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,5 +1,5 @@
1
1
  module Autoscale
2
2
  module Agent
3
- VERSION = "0.2.0".freeze
3
+ VERSION = "0.2.1".freeze
4
4
  end
5
5
  end
@@ -7,8 +7,6 @@ module Autoscale
7
7
 
8
8
  def initialize
9
9
  @dispatchers = []
10
- @running = false
11
- @running_lock = Mutex.new
12
10
  end
13
11
 
14
12
  def each(&block)
@@ -28,17 +26,7 @@ module Autoscale
28
26
  end
29
27
 
30
28
  def run
31
- @running_lock.synchronize do
32
- return if @running
33
- @running = true
34
- end
35
-
36
- Thread.new do
37
- loop do
38
- dispatch
39
- sleep DISPATCH_INTERVAL
40
- end
41
- end
29
+ Util.loop_with_interval(DISPATCH_INTERVAL) { dispatch }
42
30
  end
43
31
  end
44
32
  end
@@ -4,7 +4,9 @@ require "multi_json"
4
4
 
5
5
  require_relative "agent/configuration"
6
6
  require_relative "agent/middleware"
7
+ require_relative "agent/railtie" if defined?(Rails::Railtie)
7
8
  require_relative "agent/request"
9
+ require_relative "agent/util"
8
10
  require_relative "agent/version"
9
11
  require_relative "agent/web_dispatcher"
10
12
  require_relative "agent/worker_dispatcher"
@@ -25,5 +27,3 @@ module Autoscale
25
27
  end
26
28
  end
27
29
  end
28
-
29
- require_relative "agent/railtie" if defined?(Rails::Railtie)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoscale-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael R. van Rooijen
@@ -40,6 +40,7 @@ files:
40
40
  - lib/autoscale/agent/middleware.rb
41
41
  - lib/autoscale/agent/railtie.rb
42
42
  - lib/autoscale/agent/request.rb
43
+ - lib/autoscale/agent/util.rb
43
44
  - lib/autoscale/agent/version.rb
44
45
  - lib/autoscale/agent/web_dispatcher.rb
45
46
  - lib/autoscale/agent/worker_dispatcher.rb