symphony 0.12.3 → 0.14.0

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
  SHA256:
3
- metadata.gz: 7222c714bd9a2268e47fa14996f96a92e6bc4e443c9212b61aa9a00b64a5dff9
4
- data.tar.gz: a63326ee75b5dd8673f17757cb62e2608598623279a2616cd110db7fd97e3ee7
3
+ metadata.gz: 4a3df7405c545cb568ef001dd1287e51bc2e2de8184d8b5ef43204b5fca7599b
4
+ data.tar.gz: 2abfd45b2447a5660feae02c67f9bbd5d856a68ba69cd391c9b7101e9a1a4582
5
5
  SHA512:
6
- metadata.gz: afc8ddd33eb3b437ca831426075a9f97927882baa372b356ad5da7e0f97f3c5a80422eae0f86224a87bde87ea2f14d24ce8a3dae5ee8e44b5896ce6889c9a5d6
7
- data.tar.gz: 826de2c46e1b1511631dd036e897033b9633a9a2500ac59d95dbe3c884afaade0a10b45b56640f18de2b344d4e688ab259563cb433a2f9d1efe221911e34f5e9
6
+ metadata.gz: a2bf4f256cb6605cbadfb03e6432a61cd036bf372ce8c97db932e3eafef0d22d9a8bf3e6907c772a271258fee096a5b87fd9a8f285b03302e94d922d65ccbff4
7
+ data.tar.gz: e384f2e9edbb3dc43e773e8cfa69be3bd316c8cbfa233d7ee93ab3865c67e90110f223671775d7318282cbee3ccbfed7d3a3ab17581f51f17edcee212f519bfb
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,42 @@
1
+ = Release History for symphony
2
+
3
+ ---
4
+
5
+ == v0.14.0 [2020-07-23] Michael Granger <ged@faeriemud.org>
6
+
7
+ Improvements:
8
+
9
+ - Allow `x-queue-type` to be specified for a `Task`. Thanks to
10
+ Alyssa Verkade <averkade@costar.com> for the patch.
11
+
12
+
13
+ == v0.13.0 [2020-03-09] Michael Granger <ged@faeriemud.org>
14
+
15
+ Improvements:
16
+
17
+ - Remove Yajl dependency in favor of stdlib json.
18
+ - Update for Ruby 2.7
19
+
20
+ Changes:
21
+
22
+ - Requires Ruby 2.6+
23
+
24
+
25
+ == v0.12.5 [2019-07-16] Michael Granger <ged@FaerieMUD.org>
26
+
27
+ Improvements:
28
+
29
+ - Rescue timeouts when adjusting workers
30
+
31
+
32
+ == v0.12.4 [2019-07-11] Michael Granger <ged@FaerieMUD.org>
33
+
34
+ Bugfixes:
35
+
36
+ - Be more paranoid about shared channels, and be defensive when using
37
+ the counting queue.
38
+
39
+
1
40
  == v0.12.3 [2019-07-11] Michael Granger <ged@FaerieMUD.org>
2
41
 
3
42
  Bugfixes:
@@ -1,8 +1,7 @@
1
1
  .simplecov
2
- ChangeLog
3
2
  History.rdoc
4
3
  Manifest.txt
5
- README.rdoc
4
+ README.md
6
5
  Rakefile
7
6
  UPGRADING.md
8
7
  USAGE.rdoc
@@ -1,10 +1,19 @@
1
- = symphony
1
+ # symphony
2
2
 
3
- wiki:: http://bitbucket.org/ged/symphony
4
- docs:: http://deveiate.org/code/symphony
3
+ home
4
+ : https://hg.sr.ht/~ged/Symphony
5
5
 
6
+ code
7
+ : https://hg.sr.ht/~ged/Symphony/browse
6
8
 
7
- == Description
9
+ docs
10
+ : https://deveiate.org/code/symphony
11
+
12
+ github
13
+ : https://github.com/ged/symphony
14
+
15
+
16
+ ## Description
8
17
 
9
18
  Symphony is a subscription-based asynchronous job system. It
10
19
  allows you to define jobs that watch for lightweight events from a
@@ -21,7 +30,7 @@ symphony-task::
21
30
  require the process management that the symphony daemon provides.
22
31
 
23
32
 
24
- == Synopsis
33
+ ## Synopsis
25
34
 
26
35
  class WorkerTask < Symphony::Task
27
36
  # Process all events
@@ -37,28 +46,33 @@ symphony-task::
37
46
  For a more detailed description of usage, please refer to the USAGE document.
38
47
 
39
48
 
40
- == Installation
49
+ ## Installation
41
50
 
42
51
  gem install symphony
43
52
 
44
53
 
45
- == Contributing
54
+ ## Contributing
46
55
 
47
56
  You can check out the current development source with Mercurial via its
48
- {project page}[http://bitbucket.org/ged/symphony]. Or if you prefer Git, via
49
- {its Github mirror}[https://github.com/ged/symphony].
57
+ [project page](https://hg.sr.ht/~ged/symphony). Or if you prefer Git, via
58
+ [its Github mirror](https://github.com/ged/symphony).
50
59
 
51
60
  After checking out the source, run:
52
61
 
53
- $ rake newb
62
+ $ rake setup
63
+
64
+ This task will install dependencies, and do any other necessary developer setup.
65
+
66
+
67
+ ## Authors
54
68
 
55
- This task will install any missing dependencies, run the tests/specs,
56
- and generate the API documentation.
69
+ - Michael Granger <ged@faeriemud.org>
70
+ - Mahlon E. Smith <mahlon@martini.nu>
57
71
 
58
72
 
59
- == License
73
+ ## License
60
74
 
61
- Copyright (c) 2011-2015, Michael Granger and Mahlon E. Smith
75
+ Copyright (c) 2011-2020, Michael Granger and Mahlon E. Smith
62
76
  All rights reserved.
63
77
 
64
78
  Redistribution and use in source and binary forms, with or without
data/Rakefile CHANGED
@@ -1,79 +1,10 @@
1
- #!/usr/bin/env rake
1
+ #!/usr/bin/env ruby -S rake
2
2
 
3
- begin
4
- require 'hoe'
5
- rescue LoadError
6
- abort "This Rakefile requires hoe (gem install hoe)"
7
- end
8
-
9
- GEMSPEC = 'symphony.gemspec'
10
-
11
-
12
- Hoe.plugin :mercurial
13
- Hoe.plugin :signing
14
- Hoe.plugin :deveiate
15
-
16
- Hoe.plugins.delete :rubyforge
17
-
18
- hoespec = Hoe.spec 'symphony' do |spec|
19
- spec.readme_file = 'README.rdoc'
20
- spec.history_file = 'History.rdoc'
21
- spec.extra_rdoc_files = FileList[ '*.rdoc' ]
22
- spec.spec_extras[:rdoc_options] = ['-f', 'fivefish', '-t', 'Symphony']
23
- spec.spec_extras[:required_rubygems_version] = '>= 2.0.3'
24
- spec.license 'BSD'
25
-
26
- spec.developer 'Michael Granger', 'ged@FaerieMUD.org'
27
- spec.developer 'Mahlon E. Smith', 'mahlon@martini.nu'
28
-
29
- spec.dependency 'configurability', '~> 3.1'
30
- spec.dependency 'loggability', '~> 0.11'
31
- spec.dependency 'pluggability', '~> 0.4'
32
- spec.dependency 'bunny', '~> 2.0'
33
- spec.dependency 'sysexits', '~> 1.1'
34
- spec.dependency 'yajl-ruby', '~> 1.3'
35
- spec.dependency 'msgpack', '~> 1.0'
36
- spec.dependency 'metriks', '~> 0.9'
37
- spec.dependency 'rusage', '~> 0.2'
38
-
39
- spec.dependency 'rspec', '~> 3.0', :developer
40
- spec.dependency 'simplecov', '~> 0.8', :developer
41
- spec.dependency 'timecop', '~> 0.8', :developer
42
-
43
- spec.require_ruby_version( '>=2.0.0' )
44
- spec.hg_sign_tags = true if spec.respond_to?( :hg_sign_tags= )
3
+ require 'rake/deveiate'
45
4
 
46
- self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
5
+ Rake::DevEiate.setup( 'symphony' ) do |project|
6
+ project.publish_to = 'deveiate:/usr/local/www/public/code'
7
+ project.required_ruby_version = '~> 2.6'
47
8
  end
48
9
 
49
- # Fix some Hoe retardedness
50
- hoespec.spec.files.delete( '.gemtest' )
51
- ENV['VERSION'] ||= hoespec.spec.version.to_s
52
-
53
- # Run the tests before checking in
54
- task 'hg:precheckin' => [ :check_history, :check_manifest, :gemspec, :spec ]
55
-
56
- # Rebuild the ChangeLog immediately before release
57
- task :prerelease => 'ChangeLog'
58
- CLOBBER.include( 'ChangeLog' )
59
-
60
- desc "Build a coverage report"
61
- task :coverage do
62
- ENV["COVERAGE"] = 'yes'
63
- Rake::Task[:spec].invoke
64
- end
65
-
66
-
67
- task :gemspec => GEMSPEC
68
- file GEMSPEC => hoespec.spec.files do |task|
69
- spec = $hoespec.spec
70
- spec.version = "#{spec.version.bump}.0.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
71
- File.open( task.name, 'w' ) do |fh|
72
- fh.write( spec.to_ruby )
73
- end
74
- end
75
-
76
- task :default => :gemspec
77
-
78
- CLOBBER.include( GEMSPEC.to_s )
79
10
 
data/USAGE.rdoc CHANGED
@@ -79,14 +79,14 @@ calling #run on the class itself.
79
79
  == The Simplest Task
80
80
 
81
81
  #!/usr/bin/env ruby
82
-
82
+
83
83
  require 'symphony'
84
-
84
+
85
85
  class Test < Symphony::Task
86
-
86
+
87
87
  # Process all events
88
88
  subscribe_to '#'
89
-
89
+
90
90
  def work( payload, metadata )
91
91
  puts "I received an event: %p with a payload of %p" % [
92
92
  metadata[ :delivery_info ][ :routing_key ],
@@ -95,7 +95,7 @@ calling #run on the class itself.
95
95
  return true
96
96
  end
97
97
  end
98
-
98
+
99
99
  Symphony.load_config( 'etc/config.yml' )
100
100
  Test.run
101
101
 
@@ -239,13 +239,13 @@ By default, Symphony will try and create a queue based on the Class
239
239
  name of the task. You can override this per-task.
240
240
 
241
241
  class Test < Symphony::Task
242
-
242
+
243
243
  # Process all events
244
244
  subscribe_to '#'
245
-
245
+
246
246
  # I don't want to connect to a 'test' queue, lets make it interesting:
247
247
  queue_name 'shazzzaaaam'
248
-
248
+
249
249
  def work( payload, metadata )
250
250
  ...
251
251
 
@@ -261,14 +261,28 @@ can tell a task to create a persistent queue instead of an auto-delete queue:
261
261
 
262
262
  == Queue Re-binding
263
263
 
264
- If you want Symphony to re-bind a worker's queue when it starts up, you call tell it to with +always_rebind+:
264
+ If you want Symphony to re-bind a worker's queue when it starts up, you call
265
+ tell it to with +always_rebind+:
265
266
 
266
267
  always_rebind true
267
268
 
268
- Note that re-binding doesn't *unbind* from the existing pattern/s, so you'll
269
+ Note that re-binding doesn't *unbind* from the existing pattern/s, so you'll
269
270
  need to account for this in the Task's +work+ method.
270
271
 
271
272
 
273
+ == Queue Type
274
+
275
+ If you're running a version of RabbitMQ that supports the `x-queue-type`
276
+ argument (e.g., for quorum queues), you can specify a value for it using the
277
+ `queue_type` declaration:
278
+
279
+ queue_type 'quorum'
280
+
281
+ Note that several other queue settings might not work with some kinds of
282
+ queues; the validity of the combination of the task's settings are left to
283
+ the implementor.
284
+
285
+
272
286
  = Plugins
273
287
 
274
288
  Plugins change or enhance the behavior of a Symphony::Task.
@@ -287,7 +301,7 @@ the process name to display a total count and jobs per second rate.
287
301
  prepend Symphony::Metrics
288
302
  # ...
289
303
  end
290
-
304
+
291
305
 
292
306
  == Routing
293
307
 
@@ -300,13 +314,13 @@ receive multiple message topics much easier to maintain and test.
300
314
 
301
315
  class Test < Symphony::Task
302
316
  include Symphony::Routing
303
-
317
+
304
318
  on 'users.create', 'workstation.create' do |payload, metadata|
305
319
  puts "A user or workstation wants to be created!"
306
320
  # ...
307
321
  return true
308
322
  end
309
-
323
+
310
324
  on 'users.delete' do |payload, metadata|
311
325
  puts "A user wants to be deleted!"
312
326
  return true
@@ -12,7 +12,7 @@ module Symphony
12
12
  Configurability
13
13
 
14
14
  # Library version constant
15
- VERSION = '0.12.3'
15
+ VERSION = '0.14.0'
16
16
 
17
17
  # Version-control revision constant
18
18
  REVISION = %q$Revision$
@@ -1,5 +1,5 @@
1
1
  # -*- ruby -*-
2
- #encoding: utf-8
2
+ # frozen_string_literal: true
3
3
 
4
4
  require 'configurability'
5
5
  require 'loggability'
@@ -248,7 +248,7 @@ class Symphony::Daemon
248
248
  self.log.info "Restarting task group for %p" % [ task_class ]
249
249
  group.max_workers = max
250
250
  group.restart_workers
251
- end
251
+ end
252
252
 
253
253
 
254
254
  ### Shut down the workers for the specified task group.
@@ -1,5 +1,5 @@
1
1
  # -*- ruby -*-
2
- #encoding: utf-8
2
+ # frozen_string_literal: true
3
3
 
4
4
  require 'rusage'
5
5
  require 'metriks'
@@ -1,5 +1,5 @@
1
1
  # -*- ruby -*-
2
- #encoding: utf-8
2
+ # frozen_string_literal: true
3
3
 
4
4
 
5
5
  module Symphony
@@ -69,6 +69,7 @@ class Symphony::Queue
69
69
 
70
70
  ### Fetch a Hash of AMQP options.
71
71
  def self::amqp_session_options
72
+ self.session_opts ||= self.defaults
72
73
  opts = self.session_opts.merge({
73
74
  logger: Loggability[ Bunny ],
74
75
  })
@@ -149,13 +150,14 @@ class Symphony::Queue
149
150
 
150
151
  ### Create a new Queue for the specified +task_class+.
151
152
  def initialize( task_class )
152
- @name = task_class.queue_name
153
- @acknowledge = task_class.acknowledge
154
- @consumer_tag = task_class.consumer_tag
155
- @routing_keys = task_class.routing_keys
156
- @prefetch = task_class.prefetch
157
- @persistent = task_class.persistent
158
- @always_rebind = task_class.always_rebind
153
+ @name = task_class.queue_name
154
+ @acknowledge = task_class.acknowledge
155
+ @consumer_tag = task_class.consumer_tag
156
+ @routing_keys = task_class.routing_keys
157
+ @prefetch = task_class.prefetch
158
+ @persistent = task_class.persistent
159
+ @always_rebind = task_class.always_rebind
160
+ @amqp_queue_type = task_class.queue_type
159
161
 
160
162
  @amqp_queue = nil
161
163
  @shutting_down = false
@@ -194,6 +196,10 @@ class Symphony::Queue
194
196
  # Whether or not to re-bind the queue to the exchange during setup
195
197
  attr_predicate :always_rebind
196
198
 
199
+ ##
200
+ # The -x-queue-type of the queue, if any
201
+ attr_reader :amqp_queue_type
202
+
197
203
  ##
198
204
  # The underlying Bunny::Queue this object manages
199
205
  attr_reader :amqp_queue
@@ -255,19 +261,20 @@ class Symphony::Queue
255
261
  exchange = self.class.amqp_exchange
256
262
  channel = self.class.amqp_channel
257
263
  created_queue = false
258
- queue = nil
259
264
 
260
- begin
261
- queue = channel.queue( self.name, passive: true )
265
+ queue = begin
266
+ existing_queue = channel.queue( self.name, passive: true )
262
267
  channel.prefetch( prefetch_count )
263
268
  self.log.info "Using pre-existing queue: %s" % [ self.name ]
269
+ existing_queue
264
270
  rescue Bunny::NotFound => err
265
271
  self.log.info "%s; creating a new queue instead." % [ err.message ]
266
272
  created_queue = true
267
273
  channel = self.class.reset_amqp_channel
268
274
  channel.prefetch( prefetch_count )
269
275
 
270
- queue = channel.queue( self.name, auto_delete: !self.persistent )
276
+ arguments = { 'x-queue-type' => self.amqp_queue_type }.compact
277
+ channel.queue( self.name, auto_delete: !self.persistent, arguments: arguments )
271
278
  end
272
279
 
273
280
  if self.always_rebind? || created_queue
@@ -1,5 +1,5 @@
1
1
  # -*- ruby -*-
2
- #encoding: utf-8
2
+ # frozen_string_literal: true
3
3
 
4
4
  require 'loggability'
5
5
 
@@ -1,5 +1,5 @@
1
1
  # -*- ruby -*-
2
- #encoding: utf-8
2
+ # frozen_string_literal: true
3
3
 
4
4
  require 'symphony'
5
5