postburner 1.0.0.pre.2 → 1.0.0.pre.3

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.
@@ -10,9 +10,9 @@ module Postburner
10
10
  # @example Basic usage
11
11
  # class ProcessPayment < Postburner::Job
12
12
  # queue 'critical'
13
- # queue_priority 0
14
- # queue_ttr 300
15
- # queue_max_job_retries 3
13
+ # priority 0
14
+ # ttr 300
15
+ # max_retries 3
16
16
  #
17
17
  # def perform(args)
18
18
  # # ...
@@ -32,6 +32,9 @@ module Postburner
32
32
 
33
33
  class_methods do
34
34
  # Sets or returns the queue name.
35
+ #
36
+ # The queue name expands 'postburner.<environment>.<queue_name>' for the
37
+ # tube name in Beanstalkd.
35
38
  #
36
39
  # @param name [String, Symbol, nil] Queue name to set, or nil to get current value
37
40
  #
@@ -52,21 +55,21 @@ module Postburner
52
55
  end
53
56
  end
54
57
 
55
- # Sets or returns the queue priority.
58
+ # Sets or returns the priority.
56
59
  #
57
- # Lower numbers = higher priority in Beanstalkd.
60
+ # Lower numbers = higher priority in Beanstalkd (0 is highest).
58
61
  #
59
62
  # @param pri [Integer, nil] Priority to set (0-4294967295), or nil to get current value
60
63
  #
61
64
  # @return [Integer, nil] Current priority when getting, nil when setting
62
65
  #
63
66
  # @example Set priority
64
- # queue_priority 0 # Highest priority
67
+ # priority 0 # Highest priority
65
68
  #
66
69
  # @example Get priority
67
- # ProcessPayment.queue_priority # => 0
70
+ # ProcessPayment.priority # => 0
68
71
  #
69
- def queue_priority(pri = nil)
72
+ def priority(pri = nil)
70
73
  if pri
71
74
  self.postburner_priority = pri
72
75
  nil
@@ -75,24 +78,24 @@ module Postburner
75
78
  end
76
79
  end
77
80
 
78
- # Sets or returns the queue TTR (time-to-run).
81
+ # Sets or returns the TTR (time-to-run).
79
82
  #
80
83
  # Number of seconds Beanstalkd will wait for job completion before
81
84
  # making it available again.
82
85
  #
83
- # @param ttr [Integer, nil] Timeout in seconds, or nil to get current value
86
+ # @param seconds [Integer, nil] Timeout in seconds, or nil to get current value
84
87
  #
85
88
  # @return [Integer, nil] Current TTR when getting, nil when setting
86
89
  #
87
90
  # @example Set TTR
88
- # queue_ttr 300 # 5 minutes
91
+ # ttr 300 # 5 minutes
89
92
  #
90
93
  # @example Get TTR
91
- # ProcessPayment.queue_ttr # => 300
94
+ # ProcessPayment.ttr # => 300
92
95
  #
93
- def queue_ttr(ttr = nil)
94
- if ttr
95
- self.postburner_ttr = ttr
96
+ def ttr(seconds = nil)
97
+ if seconds
98
+ self.postburner_ttr = seconds
96
99
  nil
97
100
  else
98
101
  postburner_ttr
@@ -106,12 +109,12 @@ module Postburner
106
109
  # @return [Integer, nil] Current max retries when getting, nil when setting
107
110
  #
108
111
  # @example Set max retries
109
- # queue_max_job_retries 3
112
+ # max_retries 3
110
113
  #
111
114
  # @example Get max retries
112
- # ProcessPayment.queue_max_job_retries # => 3
115
+ # ProcessPayment.max_retries # => 3
113
116
  #
114
- def queue_max_job_retries(retries = nil)
117
+ def max_retries(retries = nil)
115
118
  if retries
116
119
  self.postburner_max_retries = retries
117
120
  nil
@@ -130,15 +133,15 @@ module Postburner
130
133
  # @return [Integer, Proc, nil] Current delay when getting, nil when setting
131
134
  #
132
135
  # @example Set fixed retry delay
133
- # queue_retry_delay 10
136
+ # retry_delay 10
134
137
  #
135
138
  # @example Set exponential backoff with proc
136
- # queue_retry_delay ->(retries) { 2 ** retries }
139
+ # retry_delay ->(retries) { 2 ** retries }
137
140
  #
138
141
  # @example Get retry delay
139
- # ProcessPayment.queue_retry_delay # => 10 or #<Proc>
142
+ # ProcessPayment.retry_delay # => 10 or #<Proc>
140
143
  #
141
- def queue_retry_delay(delay = nil)
144
+ def retry_delay(delay = nil)
142
145
  if delay
143
146
  self.postburner_retry_delay = delay
144
147
  nil
@@ -80,9 +80,9 @@ module Postburner
80
80
  data = { class: job.class.name, args: [job.id] }
81
81
 
82
82
  # Get priority, TTR from job instance (respects instance overrides) or options
83
- pri = options[:pri] || job.queue_priority || Postburner.configuration.default_priority
83
+ pri = options[:pri] || job.priority || Postburner.configuration.default_priority
84
84
  delay = options[:delay] || 0
85
- ttr = options[:ttr] || job.queue_ttr || Postburner.configuration.default_ttr
85
+ ttr = options[:ttr] || job.ttr || Postburner.configuration.default_ttr
86
86
 
87
87
  response = conn.tubes[tube_name].put(
88
88
  JSON.generate(data),
@@ -1,3 +1,3 @@
1
1
  module Postburner
2
- VERSION = '1.0.0.pre.2'
2
+ VERSION = '1.0.0.pre.3'
3
3
  end
@@ -43,63 +43,62 @@ module Postburner
43
43
  #
44
44
  # **Development:**
45
45
  # ```yaml
46
- # default_forks: 0
47
- # default_threads: 1
46
+ # forks: 0
47
+ # threads: 1
48
48
  # ```
49
49
  # Single-threaded, single-process (simplest debugging)
50
50
  #
51
51
  # **Staging:**
52
52
  # ```yaml
53
- # default_forks: 0
54
- # default_threads: 10
53
+ # forks: 0
54
+ # threads: 10
55
55
  # ```
56
56
  # Multi-threaded, single-process (moderate concurrency)
57
57
  #
58
58
  # **Production:**
59
59
  # ```yaml
60
- # default_forks: 4
61
- # default_threads: 10
60
+ # forks: 4
61
+ # threads: 10
62
62
  # ```
63
63
  # 4 processes × 10 threads = 40 concurrent jobs per queue
64
64
  #
65
65
  # ## Configuration
66
66
  #
67
67
  # @example Development (single-threaded)
68
- # development:
68
+ # development: # <- environment config, i.e. defaults
69
69
  # default_forks: 0
70
70
  # default_threads: 1
71
- # queues:
72
- # default: {}
73
- # mailers: {}
71
+ # workers: # <- worker config, i.e. overrides
72
+ # default:
73
+ # queues:
74
+ # - default
75
+ # - mailers
74
76
  #
75
77
  # @example Staging (multi-threaded, single process)
76
- # staging:
78
+ # staging: # <- environment config, i.e. defaults
77
79
  # default_forks: 0
78
80
  # default_threads: 10
79
81
  # default_gc_limit: 5000
80
- # queues:
81
- # critical:
82
- # threads: 1 # Single-threaded for critical jobs
82
+ # workers: # <- worker config, i.e. overrides
83
83
  # default:
84
- # threads: 10 # 10 concurrent threads
85
- # mailers:
86
- # threads: 5 # 5 concurrent emails
84
+ # queues:
85
+ # - critical
86
+ # - default
87
+ # - mailers
87
88
  #
88
- # @example Production (Puma-style: forks × threads)
89
- # production:
89
+ # @example Production (Puma-style: forks × threads with worker overrides)
90
+ # production: # <- environment config, i.e. defaults
90
91
  # default_forks: 2
91
92
  # default_threads: 10
92
93
  # default_gc_limit: 5000
93
- # queues:
94
- # critical:
95
- # forks: 1 # Single fork
96
- # threads: 1 # Single thread = 1 concurrent job
94
+ # workers: # <- worker config, i.e. overrides
97
95
  # default:
98
- # forks: 4 # 4 forks (Puma-style)
99
- # threads: 10 # 10 threads per fork = 40 total concurrent jobs
100
- # mailers:
101
- # forks: 2
102
- # threads: 5 # 2×5 = 10 total email senders
96
+ # forks: 4 # Overrides default_forks
97
+ # threads: 10 # Overrides default_threads
98
+ # queues:
99
+ # - critical
100
+ # - default
101
+ # - mailers
103
102
  #
104
103
  class Worker < Base
105
104
  # Starts the worker.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postburner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.2
4
+ version: 1.0.0.pre.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Smith