hutch-schedule 0.4.2 → 0.4.4

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: 93a7154c024537201d32af0ad6d88c5b2a44e7cb
4
- data.tar.gz: 61a4bf23ad9d4cdb31e6c3cd9ecf18a174a47196
3
+ metadata.gz: e7d6b5d5d9762d162619d53eccc098a2a3653ba1
4
+ data.tar.gz: 1b0429efd64d15707587387e786d5f0b59c11b77
5
5
  SHA512:
6
- metadata.gz: c7ae43fbac466b5a439e8d09c297913cfb6f170147bbab7dc9e767e6f3a0b43c1a32c730d24326938aaa9630a0ca18b5e09a094b396855646c78879dd8082515
7
- data.tar.gz: ef62aa365fa12551114e2949d547b03b44d22640cde958a902b058de42371d4b2a4ddc2c96da4bf491fc0f4489c731bbfe7cfb3ca463fddf83ac324413f6627f
6
+ metadata.gz: f6216f7715530d9bfb291cb752c4804cccd72857611d41c32d00dbb25a1655b4681a92c0b1cd6545e0bbfcc69bf0f07436b437b936bf2046b0740ec10a9134c8
7
+ data.tar.gz: d76aa10fd7819f7cbd7765343f036c01dbbca0a05709e6581af049a4876c1ac3096d033cd70679c9f1d8d2538d0d73ccde36e7f045afbf8fd71c11987c9cc1b9
data/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ ## [0.4.2] - 2017-05-23
5
+ ### Fixed
6
+ - Reuse consumer when register ActiveJob queue to consumer
7
+
8
+
9
+ ## [0.4.1] - 2017-05-22
10
+ ### Fixed
11
+ - When register ActiveJob queue consumer, use job instance #queue_name not job class queue_name
12
+
13
+ ## [0.4.0] - 2017-05-21
14
+ ### Fixed
15
+ - Fix Hutch::ErrorsHandler::MaxRetry use Set#intersect? instead of Array#include? to
16
+ calculate routing_key diff and aggregate message faild times.
17
+
@@ -43,6 +43,7 @@ module ActiveJob
43
43
 
44
44
  # Register all ActiveJob Class to Hutch. (per queue per consumer)
45
45
  def self.register_actice_job_classes
46
+ # TODO: 需要考虑如何将 AJ 的 Proc queue_name 动态注册到 Hutch
46
47
  queue_consumers = {}
47
48
 
48
49
  Dir.glob(Rails.root.join('app/jobs/**/*.rb')).each { |x| require_dependency x }
@@ -52,7 +53,7 @@ module ActiveJob
52
53
  # Multi queue only have one consumer
53
54
  next if queue_consumers.key?(job.queue_name)
54
55
  queue_consumers[job.queue_name] = HutchAdapter.dynamic_consumer(job)
55
- Hutch.consumers << queue_consumers[job.queue_name]
56
+ Hutch.register_consumer(queue_consumers[job.queue_name])
56
57
  end
57
58
  end
58
59
 
@@ -66,13 +67,17 @@ module ActiveJob
66
67
  queue_name job_instance.queue_name
67
68
  consume HutchAdapter.routing_key(job_instance)
68
69
 
69
- define_method :process do |job_data|
70
+ def process(job_data)
70
71
  ActiveJob::Base.execute(job_data)
71
72
  end
72
73
 
74
+ define_singleton_method :name do
75
+ "#{job_instance.queue_name}_dynamic_consumer".camelize
76
+ end
77
+
73
78
  # inspect name
74
- define_method :inspect do
75
- "#{job_instance.queue_name}-anonymous-consumer"
79
+ define_singleton_method :inspect do
80
+ "#{job_instance.queue_name}_dynamic_consumer".camelize
76
81
  end
77
82
  end
78
83
  end
@@ -16,10 +16,10 @@ module Hutch
16
16
  # and then just use like Hutch to publish message `Hutch::Schedule.publish`
17
17
  module Schedule
18
18
 
19
- def self.connect(broker = Hutch.broker)
20
- raise "Please invoke Hutch.connect before Hutch::Schedule.connect, Hutch::Schedule need Hutch.broker" unless Hutch.connected?
19
+ def self.connect
21
20
  return if core.present?
22
- @core = Hutch::Schedule::Core.new(broker)
21
+ Hutch.connect unless Hutch.connected?
22
+ @core = Hutch::Schedule::Core.new(Hutch.broker)
23
23
  @core.connect!
24
24
  ActiveJob::QueueAdapters::HutchAdapter.register_actice_job_classes if defined?(ActiveJob::QueueAdapters::HutchAdapter)
25
25
  end
@@ -39,7 +39,6 @@ module Hutch
39
39
 
40
40
  def declare_exchange(ch = channel)
41
41
  exchange_name = "#{config[:mq_exchange]}.schedule"
42
- # TODO: Check mq_exchange_options info, ensure they won`t override x-dead-letter-exchange params
43
42
  exchange_options = { durable: true }.merge(config[:mq_exchange_options])
44
43
  logger.info "using topic exchange(schedule) '#{exchange_name}'"
45
44
 
@@ -54,7 +53,6 @@ module Hutch
54
53
  props = { 'x-message-ttl': 30.days.in_milliseconds, 'x-dead-letter-exchange': config[:mq_exchange] }
55
54
  queue = broker.queue("#{config[:mq_exchange]}_schedule_queue", props)
56
55
 
57
- # TODO: consider extract this routing_key params to config params
58
56
  # routing all to this queue
59
57
  queue.unbind(exchange, routing_key: '#')
60
58
  queue.bind(exchange, routing_key: '#')
@@ -1,5 +1,5 @@
1
1
  module Hutch
2
2
  module Schedule
3
- VERSION = "0.4.2"
3
+ VERSION = "0.4.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hutch-schedule
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wyatt pan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-23 00:00:00.000000000 Z
11
+ date: 2017-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hutch
@@ -119,6 +119,7 @@ files:
119
119
  - ".rspec"
120
120
  - ".rubocop.yml"
121
121
  - ".travis.yml"
122
+ - CHANGELOG.md
122
123
  - CODE_OF_CONDUCT.md
123
124
  - Gemfile
124
125
  - LICENSE.txt