hirefire-resource 0.10.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +171 -0
  3. data/LICENSE +21 -66
  4. data/README.md +34 -78
  5. data/hirefire-resource.gemspec +21 -15
  6. data/lib/hirefire/configuration.rb +31 -0
  7. data/lib/hirefire/errors/job_queue_latency_unsupported.rb +12 -0
  8. data/lib/hirefire/errors.rb +9 -0
  9. data/lib/hirefire/hirefire.rb +15 -0
  10. data/lib/hirefire/macro/bunny.rb +55 -55
  11. data/lib/hirefire/macro/delayed_job.rb +80 -60
  12. data/lib/hirefire/macro/deprecated/bunny.rb +85 -0
  13. data/lib/hirefire/macro/deprecated/delayed_job.rb +62 -0
  14. data/lib/hirefire/macro/deprecated/good_job.rb +32 -0
  15. data/lib/hirefire/macro/deprecated/que.rb +76 -0
  16. data/lib/hirefire/macro/deprecated/queue_classic.rb +28 -0
  17. data/lib/hirefire/macro/deprecated/resque.rb +47 -0
  18. data/lib/hirefire/macro/deprecated/sidekiq.rb +138 -0
  19. data/lib/hirefire/macro/good_job.rb +48 -13
  20. data/lib/hirefire/macro/que.rb +56 -36
  21. data/lib/hirefire/macro/queue_classic.rb +86 -0
  22. data/lib/hirefire/macro/resque.rb +111 -25
  23. data/lib/hirefire/macro/sidekiq.rb +324 -74
  24. data/lib/hirefire/macro/solid_queue.rb +166 -0
  25. data/lib/hirefire/middleware.rb +50 -103
  26. data/lib/hirefire/railtie.rb +1 -1
  27. data/lib/hirefire/resource.rb +1 -47
  28. data/lib/hirefire/utility.rb +22 -0
  29. data/lib/hirefire/version.rb +5 -0
  30. data/lib/hirefire/web.rb +151 -0
  31. data/lib/hirefire/worker.rb +39 -0
  32. data/lib/hirefire-resource.rb +4 -9
  33. metadata +50 -25
  34. data/.github/workflows/main.yml +0 -16
  35. data/.gitignore +0 -5
  36. data/Gemfile +0 -10
  37. data/Gemfile.lock +0 -52
  38. data/Rakefile +0 -4
  39. data/bin/rake +0 -29
  40. data/lib/hirefire/macro/qc.rb +0 -23
  41. data/lib/hirefire/macro/qu.rb +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a071158b508eb303b36e2e62e11ef4acfd104b4d3c2fb1431ce042587ce1c6e4
4
- data.tar.gz: 8393b0eaf605fd706980506413d0424b5cf003d337e4930f8280cbf386602c22
3
+ metadata.gz: 1e973c6cacc949a2272e34b4e7d198a0eacf2b6f64c45cd68992365606eacb08
4
+ data.tar.gz: fb11287cb45d6d310396dce3b847b9d188bf8cea4ebae0fb83deecc45ac4093a
5
5
  SHA512:
6
- metadata.gz: e24741c9418227b9264499f9216af379f01f6036a8926ad0093f2412b09c83bafa0b276929d9388c9c05f08584c67714d39676b6675e4ae65b0b251f353884c5
7
- data.tar.gz: 0fa7878f1f5c005928dbb26def63f11f0ad18b9bb425512eb6d37a922c407b05b5d81cfe651428c59be040c3f11b4c4b3f5df6057c4b1372b829f102a068114e
6
+ metadata.gz: a30817796fceb776b6439e9c5d56c4663ff2619fdb0c5efdf88a53b0427d6fed277488bf15f2af0defb089a482702cc3daffcc11351143b091c4fe46905b21a3
7
+ data.tar.gz: ee5a162079121d899877b8fdee63b8bb288b1ab7670d5e849e0652d513c463712ad3acfff5bd41249cf1198208bbecc6b22a44507a5138aa0e1c6a7504837142
data/CHANGELOG.md CHANGED
@@ -1,3 +1,174 @@
1
+ ## v1.0.0
2
+
3
+ * `HireFire`:
4
+ * Deprecate `HireFire::Resource`.
5
+ * Use `HireFire` as the primary entrypoint to configure the gem. `HireFire::Resource` is now an alias for backward compatibility.
6
+ * Add a configuration option to specify a custom logger, defaulting to `Logger.new($stdout)`.
7
+ * Introduce the `dyno(:web)` configuration option for integration with the upcoming autoscaling strategy `HireFire - Request Queue Time`.
8
+ * `HireFire::Macro::SolidQueue`:
9
+ * Add support for [SolidQueue](https://github.com/basecamp/solid_queue) with `.job_queue_latency` and `.job_queue_size` for latency and size measurement.
10
+ * `HireFire::Macro::Sidekiq.job_queue_latency`:
11
+ * Deprecate `.latency`.
12
+ * Introduce `.job_queue_latency` (replacing `.latency`).
13
+ * Consider jobs in the scheduled and retry sets.
14
+ * Accept the `:skip_scheduled` and `:skip_retries` options.
15
+ * Accept multiple queues.
16
+ * Infer all queues when none are specified.
17
+ * `HireFire::Macro::Sidekiq.job_queue_size`:
18
+ * Deprecate `.queue`.
19
+ * Add `.job_queue_size` (replacing `.queue`).
20
+ * Accept `:server` to perform the lookup on the Redis server using Lua.
21
+ * Optimize client-side counting of `ScheduledSet` and `RetrySet`.
22
+ * `HireFire::Macro::GoodJob.job_queue_latency`:
23
+ * Add `.job_queue_latency` to measure job queue latency for GoodJob.
24
+ * `HireFire::Macro::GoodJob.job_queue_size`:
25
+ * Deprecate `.queue`.
26
+ * Add `.job_queue_size` (replacing `.queue`).
27
+ * `HireFire::Macro::Delayed::Job.job_queue_latency`:
28
+ * Add `.job_queue_latency` to measure job queue latency for Delayed::Job.
29
+ * `HireFire::Macro::Delayed::Job.job_queue_size`:
30
+ * Deprecate `.queue`.
31
+ * Add `.job_queue_size` (replacing `.queue`).
32
+ * Remove the `:mapper` option. Mapper is now inferred from the adapter.
33
+ * Remove `:min_priority` and `:max_priority` options.
34
+ * `HireFire::Macro::Bunny.job_queue_size`:
35
+ * Deprecate `.queue`.
36
+ * Add `.job_queue_size` (replacing `.queue`).
37
+ * Remove the `:"x-max-priority"` option.
38
+ * Remove the `:connection` and `:durable` options.
39
+ * `:amqp_url` option now defaults, in order, to `AMQP_URL`, `RABBITMQ_URL`, `RABBITMQ_BIGWIG_URL`, `CLOUDAMQP_URL`, and `"amqp://guest:guest@localhost:5672"`.
40
+ * Measure job queue size in passive mode to avoid queue configuration conflicts.
41
+ * Raise an error when no queue is provided.
42
+ * `HireFire::Macro::Resque.job_queue_size`:
43
+ * Deprecate `.queue`.
44
+ * Add `.job_queue_size` (replacing `.queue`).
45
+ * Consider scheduled jobs (`resque-scheduled`).
46
+ * Consider failed jobs (`resque-retry`).
47
+ * `HireFire::Macro::Que.job_queue_latency`:
48
+ * Add `.job_queue_latency` to measure job queue latency for Que.
49
+ * `HireFire::Macro::Que.job_queue_size`:
50
+ * Deprecate `.queue`.
51
+ * Add `.job_queue_size` (replacing `.queue`).
52
+ * `HireFire::Macro::QC.job_queue_latency`:
53
+ * Add `.job_queue_latency` to measure job queue latency for QC (Queue Classic).
54
+ * `HireFire::Macro::QC.job_queue_size`:
55
+ * Deprecate `.queue`.
56
+ * Add `.job_queue_size` (replacing `.queue`).
57
+ * Accept multiple queues.
58
+ * Consider scheduled jobs.
59
+ * Support:
60
+ * Add support for the latest versions of Ruby and all integrations.
61
+ * Drop support for Ruby 2.6.
62
+ * Drop support for delayed_job 2.
63
+ * Drop support for delayed_job_mongoid 2.
64
+ * Drop support for que 0 and 1.
65
+ * Drop support for qu.
66
+ * Switch to MIT license.
67
+
68
+ ### Migration - Configuration
69
+
70
+ The configuration method for the `hirefire-resource` gem has been updated. Previously, it was set up as follows:
71
+
72
+ ```rb
73
+ HireFire::Resource.configure do |config|
74
+ # existing configuration
75
+ end
76
+ ```
77
+
78
+ The new configuration method is:
79
+
80
+ ```rb
81
+ HireFire.configure do |config|
82
+ # existing configuration
83
+ end
84
+ ```
85
+
86
+ This change is backward-compatible, meaning that your current configuration using `HireFire::Resource` will continue to work for now. However, `HireFire::Resource` may be removed in a future release, so we recommend updating to the new method at your earliest convenience.
87
+
88
+ ### Migration - Macro Functions
89
+
90
+ All `.queue` and `.latency` functions have been deprecated. Although they will continue to work, they are no longer supported and may be removed in a future release. We recommend migrating to the new `.job_queue_size` and `.job_queue_latency` functions. Note that we've streamlined these functions' arguments for consistency as much as possible, and options may have been added, removed, or changed.
91
+
92
+ Almost all functions now infer all existing queues when the `*queues` argument is left empty. For example:
93
+
94
+ ```rb
95
+ HireFire::Macro::Sidekiq.job_queue_size # Measures queue size across all queues
96
+ HireFire::Macro::Sidekiq.job_queue_latency # Measures maximum latency across all queues
97
+ ```
98
+
99
+ If your worker operates on all queues (assuming critical, default, low are all queues), for example:
100
+
101
+ ```sh
102
+ worker: sidekiq -q critical -q default -q low
103
+ ```
104
+
105
+ Then you can simply configure the macro as follows to measure latency across all queues:
106
+
107
+ ```rb
108
+ dyno(:worker) do
109
+ HireFire::Macro::Sidekiq.job_queue_latency
110
+ end
111
+ ```
112
+
113
+ Or to measure queue size across all queues:
114
+
115
+ ```rb
116
+ dyno(:worker) do
117
+ HireFire::Macro::Sidekiq.job_queue_size
118
+ end
119
+ ```
120
+
121
+ If your workers each operate on a subset of queues, for example:
122
+
123
+ ```sh
124
+ worker: sidekiq -q critical -q default -q low
125
+ mailer: sidekiq -q mailer
126
+ ```
127
+
128
+ The corresponding new function calls would be:
129
+
130
+ ```rb
131
+ dyno(:worker) do
132
+ HireFire::Macro::Sidekiq.job_queue_latency(:critical, :default, :low)
133
+ # or: HireFire::Macro::Sidekiq.job_queue_size(:critical, :default, :low)
134
+ end
135
+
136
+ dyno(:mailer) do
137
+ HireFire::Macro::Sidekiq.job_queue_latency(:mailer)
138
+ # or: HireFire::Macro::Sidekiq.job_queue_size(:mailer)
139
+ end
140
+ ```
141
+
142
+ Choose the appropriate module and function based on the worker library you are using and the autoscaling strategy you have implemented, whether it is Job Queue Size or Job Queue Latency. For more details on the available options per function, see the documentation.
143
+
144
+ ### Migration - Request Queue Time
145
+
146
+ We are introducing a new autoscaling strategy called `HireFire - Request Queue Time`. This strategy uses the same metric as the `Logplex - Request Queue Time` strategy. The primary difference is that while the Logplex strategy requires the HireFire middleware to write the request queue time data to stdout and have the Heroku Logplex forward that data to HireFire via a Logdrain, the new strategy directly dispatches this data from the web dyno to HireFire, bypassing the Heroku Logplex entirely.
147
+
148
+ This strategy offers several advantages:
149
+
150
+ - Simpler integration.
151
+ - Elimination of log forwarding, resulting in:
152
+ - Reduced log size.
153
+ - Decreased log noise.
154
+ - Fewer points of failure (i.e., Heroku Logplex availability).
155
+
156
+ To switch to this strategy:
157
+
158
+ 1. Remove `config.log_queue_metrics = true` from your HireFire configuration file.
159
+ 2. Insert the line `config.dyno(:web)` into your HireFire configuration file.
160
+ 3. Ensure that the `HIREFIRE_TOKEN` environment variable is set in your Heroku application.
161
+ 4. Deploy these changes to Heroku.
162
+ 5. Switch the autoscaling strategy of the Dyno Manager in your HireFire account from `Logplex - Request Queue Time` to `HireFire - Request Queue Time`.
163
+
164
+ You can find the `HIREFIRE_TOKEN` environment variable in your HireFire account under the Dyno Manager settings. To verify if it's already set in your Heroku application, run:
165
+
166
+ ```sh
167
+ heroku config -a <application> | grep HIREFIRE_TOKEN
168
+ ```
169
+
170
+ Note: The `Logplex - Request Queue Time` strategy will continue to be available as an option.
171
+
1
172
  ## v0.10.1
2
173
 
3
174
  * Add redis 5 (gem) support to HireFire::Macro::Resque
data/LICENSE CHANGED
@@ -1,66 +1,21 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
10
-
11
- "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
12
-
13
- "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
14
-
15
- "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
16
-
17
- "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
18
-
19
- "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
20
-
21
- "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
22
-
23
- "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
24
-
25
- "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
26
-
27
- "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
28
-
29
- 2. Grant of Copyright License.
30
-
31
- Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
32
-
33
- 3. Grant of Patent License.
34
-
35
- Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
36
-
37
- 4. Redistribution.
38
-
39
- You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
40
-
41
- You must give any other recipients of the Work or Derivative Works a copy of this License; and
42
- You must cause any modified files to carry prominent notices stating that You changed the files; and
43
- You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
44
- If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
45
- You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
46
-
47
- 5. Submission of Contributions.
48
-
49
- Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
50
-
51
- 6. Trademarks.
52
-
53
- This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
54
-
55
- 7. Disclaimer of Warranty.
56
-
57
- Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
58
-
59
- 8. Limitation of Liability.
60
-
61
- In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
62
-
63
- 9. Accepting Warranty or Additional Liability.
64
-
65
- While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
66
-
1
+ MIT License
2
+
3
+ Copyright (c) 2012 HireFire
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,95 +1,51 @@
1
- ## [HireFire] - Autoscaling for [Heroku]
1
+ ## HireFire Integration Library for Ruby Applications
2
2
 
3
- Response times, queue times, job queues, load and schedule-based autoscaling for web and worker dynos on [Heroku].
3
+ This library integrates Ruby applications with HireFire's Dyno Managers (Heroku Dyno Autoscalers). Instructions specific to supported web frameworks and worker libraries are provided during the setup process.
4
4
 
5
- ---
6
-
7
- It supports practically any worker library. We provide out-of-the-box support for:
8
-
9
- * Sidekiq
10
- * Delayed Job
11
- * Resque
12
- * GoodJob
13
- * Qu
14
- * Que
15
- * QueueClassic
16
- * Bunny
17
-
18
- *Note that you can write your own worker queue logic for almost any other worker library as well.
19
- HireFire can scale multiple individual worker libraries at the same time, as well as multiple individual queues for any worker library.*
20
-
21
- It supports practically any Rack-based application or framework, such as:
22
-
23
- * Ruby on Rails
24
- * Sinatra
25
- * Padrino
26
- * Bare Rack Apps
5
+ **Supported web frameworks:**
27
6
 
28
- We provide convenient macros for the above mentioned worker libraries to calculate the queue size for each of them.
29
- If you wish to conribute more macros for other existing worker libraries feel free to send us a pull request.
7
+ - Rails
8
+ - Sinatra
9
+ - Hanami
10
+ - Rack
30
11
 
31
- Here is an example with Rails 3+
12
+ **Supported worker libraries:**
32
13
 
33
- First, add the gem to your `Gemfile`:
14
+ - Solid Queue
15
+ - Good Job
16
+ - Delayed Job
17
+ - Sidekiq
18
+ - Resque
19
+ - Que
20
+ - QC
21
+ - Bunny
34
22
 
35
- ```ruby
36
- gem "hirefire-resource"
37
- ```
38
-
39
- Then, create an initializer in `config/initializers/hirefire.rb` and add the following:
40
-
41
- ```ruby
42
- HireFire::Resource.configure do |config|
43
- config.dyno(:resque_worker) do
44
- HireFire::Macro::Resque.queue
45
- end
46
-
47
- config.dyno(:dj_worker) do
48
- HireFire::Macro::Delayed::Job.queue(mapper: :active_record)
49
- end
50
- end
51
- ```
23
+ ---
52
24
 
53
- Finally, set your `HIREFIRE_TOKEN` environment variable on Heroku. To retrieve your token, visit the [HireFire dashboard](https://manager.hirefire.io/applications) and click your application name.
54
- ```
55
- heroku config:set HIREFIRE_TOKEN=token --app application_name
56
- ```
57
- To check that everything is working, you can visit:
58
- - In development: `localhost:3000/hirefire/development/info`
59
- - In production: `yourdomain.com/hirefire/your_token/info`
25
+ Since 2011, over 1,000 companies have trusted [HireFire] to autoscale more than 5,000 applications hosted on [Heroku], managing over 10,000 web and worker dynos.
60
26
 
61
- This will allow HireFire to read out the queues for both Resque and Delayed Job. By default these macros will count all the queues combined if you are using multiple
62
- different queues for each worker library. You can also pass in specific queues to count, like so:
27
+ HireFire is distinguished by its support for both web and worker dynos, extending autoscaling capabilities to Standard-tier dynos. It provides fine-grained control over scaling behavior and improves scaling accuracy by monitoring more reliable metrics at the application level. These metrics include request queue time (web), job queue latency (worker), and job queue size (worker), which contribute to making more effective scaling decisions.
63
28
 
64
- ```ruby
65
- HireFire::Resource.configure do |config|
66
- config.dyno(:resque_worker) do
67
- HireFire::Macro::Resque.queue(:mail, :backup)
68
- end
29
+ For more information, visit our [home page][HireFire].
69
30
 
70
- config.dyno(:dj_worker) do
71
- HireFire::Macro::Delayed::Job
72
- .queue(:encode, :compress, mapper: :active_record)
73
- end
74
- end
75
- ```
31
+ ---
76
32
 
77
- This will tell HireFire to count the total amount of jobs from the `mail` and `backup` queue for the `resque_worker` dyno, and the `encode` and `compress` queues for the `dj_worker` dyno.
78
- The `resque_worker` refers to the `resque_worker` in your `Procfile`, and the `dj_worker` refers to the `dj_worker` in the `Procfile`. In this case the `Procfile` would look something like this:
33
+ ## Development
79
34
 
80
- ```
81
- resque_worker: QUEUE=mail,backup bundle exec rake resque:work
82
- dj_worker: QUEUES=encode,compress bundle exec rake jobs:work
83
- ```
35
+ - Run `bin/setup` to prepare the environment.
36
+ - See `rake -T` for common tasks.
84
37
 
85
- Now that HireFire will scale both of the these dyno types based on their individual queue sizes. To customize how they scale, log in to the HireFire web interface.
38
+ ## Release
86
39
 
87
- Visit the [official website] for more information!
40
+ 1. Update the `HireFire::VERSION` constant.
41
+ 2. Ensure that `CHANGELOG.md` is up-to-date.
42
+ 3. Commit changes with `git commit`.
43
+ 4. Create a `git tag` matching the new version (e.g., `v1.0.0`).
44
+ 5. Push the new git tag. Continuous Integration will handle the distribution process.
88
45
 
89
- ### License
46
+ ## License
90
47
 
91
- hirefire-resource is released under the Apache 2.0 license. See LICENSE.
48
+ This library is licensed under the terms of the MIT license.
92
49
 
93
- [HireFire]: https://www.hirefire.io/
94
- [official website]: https://www.hirefire.io/
95
- [Heroku]: https://www.heroku.com/
50
+ [HireFire]: https://hirefire.io/
51
+ [Heroku]: https://heroku.com/
@@ -1,19 +1,25 @@
1
+ require_relative "lib/hirefire/version"
2
+
1
3
  Gem::Specification.new do |spec|
2
4
  spec.name = "hirefire-resource"
3
- spec.version = "0.10.1"
5
+ spec.version = HireFire::VERSION
4
6
  spec.platform = Gem::Platform::RUBY
5
- spec.authors = "Michael van Rooijen"
6
- spec.email = "michael@hirefire.io"
7
- spec.homepage = "https://www.hirefire.io"
8
- spec.summary = "Autoscaling for your Heroku dynos"
9
- spec.description = "Load- and schedule-based scaling for web- and worker dynos"
10
- spec.licenses = ["Apache License"]
11
- spec.metadata = {
12
- "homepage_uri" => "https://www.hirefire.io",
13
- "changelog_uri" => "https://github.com/hirefire/hirefire-resource/blob/master/CHANGELOG.md",
14
- "source_code_uri" => "https://github.com/hirefire/hirefire-resource/",
15
- "bug_tracker_uri" => "https://github.com/hirefire/hirefire-resource/issues"
16
- }
17
- spec.files = `git ls-files`.split("\n")
18
- spec.require_path = "lib"
7
+ spec.authors = ["Michael van Rooijen"]
8
+ spec.email = ["support@hirefire.io"]
9
+ spec.homepage = "https://hirefire.io"
10
+ spec.summary = "HireFire integration library for Ruby applications"
11
+ spec.license = "MIT"
12
+ spec.metadata["homepage_uri"] = "https://hirefire.io"
13
+ spec.metadata["documentation_uri"] = "https://www.rubydoc.info/gems/hirefire-resource"
14
+ spec.metadata["changelog_uri"] = "https://github.com/hirefire/hirefire-resource-ruby/blob/master/CHANGELOG.md"
15
+ spec.metadata["source_code_uri"] = "https://github.com/hirefire/hirefire-resource-ruby"
16
+ spec.metadata["bug_tracker_uri"] = "https://github.com/hirefire/hirefire-resource-ruby/issues"
17
+ spec.require_paths = ["lib"]
18
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
19
+ `git ls-files -z`.split("\x0").select do |f|
20
+ f.start_with?(*%w[lib/ README.md LICENSE CHANGELOG.md hirefire-resource.gemspec])
21
+ end
22
+ end
23
+ spec.required_ruby_version = ">= 2.7.0"
24
+ spec.add_development_dependency "appraisal", "~> 2"
19
25
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "logger"
4
+
5
+ module HireFire
6
+ class Configuration
7
+ class LogQueueMetricsUnsupportedError < StandardError; end
8
+
9
+ attr_reader :web, :workers
10
+ attr_writer :log_queue_metrics
11
+ attr_accessor :logger
12
+
13
+ def initialize
14
+ @web = nil
15
+ @workers = []
16
+ @logger = Logger.new($stdout)
17
+ end
18
+
19
+ def dyno(name, &block)
20
+ if name.to_s == "web"
21
+ @web = Web.new
22
+ else
23
+ @workers << Worker.new(name, &block)
24
+ end
25
+ end
26
+
27
+ def log_queue_metrics
28
+ @log_queue_metrics ||= false
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HireFire
4
+ module Errors
5
+ module JobQueueLatencyUnsupported
6
+ def job_queue_latency(*, **)
7
+ raise HireFire::Errors::JobQueueLatencyUnsupportedError,
8
+ "#{name} currently does not support job queue latency measurements."
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HireFire
4
+ module Errors
5
+ class MissingQueueError < StandardError; end
6
+
7
+ class JobQueueLatencyUnsupportedError < StandardError; end
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HireFire
4
+ extend self
5
+
6
+ attr_writer :configuration
7
+
8
+ def configure
9
+ yield configuration
10
+ end
11
+
12
+ def configuration
13
+ @configuration ||= Configuration.new
14
+ end
15
+ end