sqewer 2.0.1 → 2.0.2

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
  SHA1:
3
- metadata.gz: 7a28c968f3a51ed4f10f5f1e301d7580c39ce0a3
4
- data.tar.gz: eed7b54c31ba440d02e9c936dfe748308ce2adf4
3
+ metadata.gz: b0587cd9025e697b5a59b65e9a332d847896cc4d
4
+ data.tar.gz: b8387600d676de06a137ffa7adb83a63eb0cae71
5
5
  SHA512:
6
- metadata.gz: f0386ee7b9544566759997509e3182a2fb50971c7f71f217c6efb5d6d9006e332867b346ee1858953d589e9d3802527b1a21170ca038d1721fb9e31fa5a5a3a1
7
- data.tar.gz: fd59adf4ff3f6c920f0428b2dd915843e6f922906c36db7af5c4f3d203095a2961f3b82cd681d3fda8d153d9965770f18e0e035455a17db9b687b01125575ceb
6
+ metadata.gz: 3d40e03010b39caaac013142b3ebe29ec4f9de15371c4a43f8943635d2e8953ee69ab1c0d3da415c4556a24d7ec7b3a07bd41d46b26584a6d032eb4a6b870cce
7
+ data.tar.gz: 710bfe3a794e01bfbf0b07acd41edebb8ecbaf8ba9cf7efa6700feda9e280ccb2a2039b2a717c10687b30173186ffb8b775880ce17d721cd2bb995b70ac02346
data/DETAILS.md CHANGED
@@ -128,7 +128,9 @@ The very minimal executable for running jobs would be this:
128
128
  require 'my_applicaion'
129
129
  Sqewer::CLI.run
130
130
 
131
- This will connect to the queue at the URL set in the `SQS_QUEUE_URL` environment variable.
131
+ This will connect to the queue at the URL set in the `SQS_QUEUE_URL` environment variable, and
132
+ use all the default parameters. The `CLI` module will also set up a signal handler to terminate
133
+ the current jobs cleanly if the commandline app receives a USR1 and TERM.
132
134
 
133
135
  You can also run a worker without signal handling, for example in test
134
136
  environments. Note that the worker is asynchronous, it has worker threads
@@ -152,8 +154,20 @@ S3 bucket notifications coming into the same queue):
152
154
 
153
155
  worker = Sqewer::Worker.new(serializer: CustomSerializer.new)
154
156
 
155
- The `Sqewer::CLI` module that you run from the commandline handler application accepts the
156
- same options as the `Worker` constructor, so everything stays configurable.
157
+ You can also elect to inherit from the `Worker` class and override some default constructor
158
+ arguments:
159
+
160
+ class CustomWorker < Sqewer::Worker
161
+ def initialize(**kwargs)
162
+ super(serializer: CustomSerializer.mnew, ..., **kwargs)
163
+ end
164
+ end
165
+
166
+ The `Sqewer::CLI` module that you run from the commandline handler application can be
167
+ started with your custom Worker of choice:
168
+
169
+ custom_worker = Sqewer::Worker.new(logger: special_logger)
170
+ Sqewer::CLI.start(custom_worker)
157
171
 
158
172
  ## Threads versus processes
159
173
 
@@ -41,7 +41,8 @@ class Sqewer::Connection
41
41
  # @return [Array<Message>] an array of Message objects
42
42
  def receive_messages
43
43
  client = ::Aws::SQS::Client.new
44
- response = client.receive_message(queue_url: @queue_url, wait_time_seconds: DEFAULT_TIMEOUT_SECONDS, max_number_of_messages: 10)
44
+ response = client.receive_message(queue_url: @queue_url,
45
+ wait_time_seconds: DEFAULT_TIMEOUT_SECONDS, max_number_of_messages: 10)
45
46
  response.messages.map do | message |
46
47
  Message.new(message.receipt_handle, message.body)
47
48
  end
@@ -1,3 +1,3 @@
1
1
  module Sqewer
2
- VERSION = '2.0.1'
2
+ VERSION = '2.0.2'
3
3
  end
@@ -124,18 +124,7 @@ class Sqewer::Worker
124
124
  end
125
125
  end
126
126
 
127
- # It makes sense to have one GC caller per process, since a GC cuts across threads.
128
- # We will perform a full GC cycle after the same number of jobs as our consumer thread
129
- # count - so not on every job, but still as often as we can to keep the memory use in check.
130
- gc = Thread.new do
131
- loop do
132
- break if stopping?
133
- GC.start if (@execution_counter.to_i % @num_threads).zero?
134
- sleep 0.5
135
- end
136
- end
137
-
138
- @threads = [provider, gc] + consumers
127
+ @threads = consumers + [provider]
139
128
 
140
129
  # If any of our threads are already dead, it means there is some misconfiguration and startup failed
141
130
  if @threads.any?{|t| !t.alive? }
@@ -153,6 +142,16 @@ class Sqewer::Worker
153
142
  def stop
154
143
  @state.transition! :stopping
155
144
  @logger.info { '[worker] Stopping (clean shutdown), will wait for threads to terminate'}
145
+ loop do
146
+ n_live = @threads.select(&:alive?).length
147
+ break if n_live.zero?
148
+
149
+ n_dead = @threads.length - n_live
150
+ @logger.info {"Waiting on threads to terminate, %d still alive, %d quit" % [n_live, n_dead] }
151
+
152
+ sleep 2
153
+ end
154
+
156
155
  @threads.map(&:join)
157
156
  @logger.info { '[worker] Stopped'}
158
157
  @state.transition! :stopped
@@ -2,16 +2,16 @@
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: sqewer 2.0.1 ruby lib
5
+ # stub: sqewer 2.0.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "sqewer"
9
- s.version = "2.0.1"
9
+ s.version = "2.0.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Julik Tarkhanov"]
14
- s.date = "2016-01-21"
14
+ s.date = "2016-01-23"
15
15
  s.description = "Process jobs from SQS"
16
16
  s.email = "me@julik.nl"
17
17
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqewer
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julik Tarkhanov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-21 00:00:00.000000000 Z
11
+ date: 2016-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk