sidekiq-belt 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +227 -0
- data/.rubocop_todo.yml +15 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/LICENSE +21 -0
- data/README.md +111 -0
- data/Rakefile +12 -0
- data/lib/sidekiq/belt/community/files.rb +17 -0
- data/lib/sidekiq/belt/ent/files.rb +23 -0
- data/lib/sidekiq/belt/ent/periodic_pause.rb +17 -0
- data/lib/sidekiq/belt/ent/periodic_run.rb +88 -0
- data/lib/sidekiq/belt/pro/files.rb +21 -0
- data/lib/sidekiq/belt/version.rb +7 -0
- data/lib/sidekiq/belt.rb +23 -0
- data/lib/sidekiq/web_action_helper.rb +30 -0
- data/lib/sidekiq/web_router_helper.rb +16 -0
- data/lib/sidekiq-belt.rb +3 -0
- data/sig/sidekiq/belt.rbs +6 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4f46a9f9e25f3ca4a020066547c25df3162a9644bd35d7a1a849d5766e0d1eac
|
4
|
+
data.tar.gz: 7e4153736d66d52c7f86f0721ef4239ee5a7ed51e4b4c51b41a7db2ff6e23c7d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a9ab0684f188afa56b7fe97c1efc88acaf381419c5d1f5f5f879eda5e22c7e7f36e7d48f5e2cf76caede6ae36381cdaf9b5429f89f0a0278269c8f31db71e24a
|
7
|
+
data.tar.gz: 2b07483a5a2cb6fa6d6a2af9e167857a0da4c5f7b55ee8ccce1e0e225029a71f93d39ebf94a98a39d8727614ea6e0f09445b34e7f62f89c1d27356a710efaa86
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,227 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
require:
|
4
|
+
- rubocop-rake
|
5
|
+
- rubocop-rspec
|
6
|
+
|
7
|
+
AllCops:
|
8
|
+
TargetRubyVersion: 2.6
|
9
|
+
NewCops: enable
|
10
|
+
|
11
|
+
Style/StringLiterals:
|
12
|
+
Enabled: true
|
13
|
+
EnforcedStyle: double_quotes
|
14
|
+
|
15
|
+
Style/StringLiteralsInInterpolation:
|
16
|
+
Enabled: true
|
17
|
+
EnforcedStyle: double_quotes
|
18
|
+
|
19
|
+
Layout/LineLength:
|
20
|
+
Max: 120
|
21
|
+
|
22
|
+
Gemspec/DeprecatedAttributeAssignment:
|
23
|
+
Enabled: true
|
24
|
+
Gemspec/DevelopmentDependencies:
|
25
|
+
Enabled: true
|
26
|
+
Gemspec/RequireMFA:
|
27
|
+
Enabled: true
|
28
|
+
Layout/LineContinuationLeadingSpace:
|
29
|
+
Enabled: true
|
30
|
+
Layout/LineContinuationSpacing:
|
31
|
+
Enabled: true
|
32
|
+
Layout/LineEndStringConcatenationIndentation:
|
33
|
+
Enabled: true
|
34
|
+
Layout/SpaceBeforeBrackets:
|
35
|
+
Enabled: true
|
36
|
+
Lint/AmbiguousAssignment:
|
37
|
+
Enabled: true
|
38
|
+
Lint/AmbiguousOperatorPrecedence:
|
39
|
+
Enabled: true
|
40
|
+
Lint/AmbiguousRange:
|
41
|
+
Enabled: true
|
42
|
+
Lint/ConstantOverwrittenInRescue:
|
43
|
+
Enabled: true
|
44
|
+
Lint/DeprecatedConstants:
|
45
|
+
Enabled: true
|
46
|
+
Lint/DuplicateBranch:
|
47
|
+
Enabled: true
|
48
|
+
Lint/DuplicateMagicComment:
|
49
|
+
Enabled: true
|
50
|
+
Lint/DuplicateMatchPattern:
|
51
|
+
Enabled: true
|
52
|
+
Lint/DuplicateRegexpCharacterClassElement:
|
53
|
+
Enabled: true
|
54
|
+
Lint/EmptyBlock:
|
55
|
+
Enabled: true
|
56
|
+
Lint/EmptyClass:
|
57
|
+
Enabled: true
|
58
|
+
Lint/EmptyInPattern:
|
59
|
+
Enabled: true
|
60
|
+
Lint/IncompatibleIoSelectWithFiberScheduler:
|
61
|
+
Enabled: true
|
62
|
+
Lint/LambdaWithoutLiteralBlock:
|
63
|
+
Enabled: true
|
64
|
+
Lint/MixedCaseRange:
|
65
|
+
Enabled: true
|
66
|
+
Lint/NoReturnInBeginEndBlocks:
|
67
|
+
Enabled: true
|
68
|
+
Lint/NonAtomicFileOperation:
|
69
|
+
Enabled: true
|
70
|
+
Lint/NumberedParameterAssignment:
|
71
|
+
Enabled: true
|
72
|
+
Lint/OrAssignmentToConstant:
|
73
|
+
Enabled: true
|
74
|
+
Lint/RedundantDirGlobSort:
|
75
|
+
Enabled: true
|
76
|
+
Lint/RedundantRegexpQuantifiers:
|
77
|
+
Enabled: true
|
78
|
+
Lint/RefinementImportMethods:
|
79
|
+
Enabled: true
|
80
|
+
Lint/RequireRangeParentheses:
|
81
|
+
Enabled: true
|
82
|
+
Lint/RequireRelativeSelfPath:
|
83
|
+
Enabled: true
|
84
|
+
Lint/SymbolConversion:
|
85
|
+
Enabled: true
|
86
|
+
Lint/ToEnumArguments:
|
87
|
+
Enabled: true
|
88
|
+
Lint/TripleQuotes:
|
89
|
+
Enabled: true
|
90
|
+
Lint/UnexpectedBlockArity:
|
91
|
+
Enabled: true
|
92
|
+
Lint/UnmodifiedReduceAccumulator:
|
93
|
+
Enabled: true
|
94
|
+
Lint/UselessRescue:
|
95
|
+
Enabled: true
|
96
|
+
Lint/UselessRuby2Keywords:
|
97
|
+
Enabled: true
|
98
|
+
Metrics/CollectionLiteralLength:
|
99
|
+
Enabled: true
|
100
|
+
Naming/BlockForwarding:
|
101
|
+
Enabled: true
|
102
|
+
Security/CompoundHash:
|
103
|
+
Enabled: true
|
104
|
+
Security/IoMethods:
|
105
|
+
Enabled: true
|
106
|
+
Style/ArgumentsForwarding:
|
107
|
+
Enabled: true
|
108
|
+
Style/ArrayIntersect:
|
109
|
+
Enabled: true
|
110
|
+
Style/CollectionCompact:
|
111
|
+
Enabled: true
|
112
|
+
Style/ComparableClamp:
|
113
|
+
Enabled: true
|
114
|
+
Style/ConcatArrayLiterals:
|
115
|
+
Enabled: true
|
116
|
+
Style/DataInheritance:
|
117
|
+
Enabled: true
|
118
|
+
Style/DirEmpty:
|
119
|
+
Enabled: true
|
120
|
+
Style/DocumentDynamicEvalDefinition:
|
121
|
+
Enabled: true
|
122
|
+
Style/EmptyHeredoc:
|
123
|
+
Enabled: true
|
124
|
+
Style/EndlessMethod:
|
125
|
+
Enabled: true
|
126
|
+
Style/EnvHome:
|
127
|
+
Enabled: true
|
128
|
+
Style/ExactRegexpMatch:
|
129
|
+
Enabled: true
|
130
|
+
Style/FetchEnvVar:
|
131
|
+
Enabled: true
|
132
|
+
Style/FileEmpty:
|
133
|
+
Enabled: true
|
134
|
+
Style/FileRead:
|
135
|
+
Enabled: true
|
136
|
+
Style/FileWrite:
|
137
|
+
Enabled: true
|
138
|
+
Style/HashConversion:
|
139
|
+
Enabled: true
|
140
|
+
Style/HashExcept:
|
141
|
+
Enabled: true
|
142
|
+
Style/IfWithBooleanLiteralBranches:
|
143
|
+
Enabled: true
|
144
|
+
Style/InPatternThen:
|
145
|
+
Enabled: true
|
146
|
+
Style/MagicCommentFormat:
|
147
|
+
Enabled: true
|
148
|
+
Style/MapCompactWithConditionalBlock:
|
149
|
+
Enabled: true
|
150
|
+
Style/MapToHash:
|
151
|
+
Enabled: true
|
152
|
+
Style/MapToSet:
|
153
|
+
Enabled: true
|
154
|
+
Style/MinMaxComparison:
|
155
|
+
Enabled: true
|
156
|
+
Style/MultilineInPatternThen:
|
157
|
+
Enabled: true
|
158
|
+
Style/NegatedIfElseCondition:
|
159
|
+
Enabled: true
|
160
|
+
Style/NestedFileDirname:
|
161
|
+
Enabled: true
|
162
|
+
Style/NilLambda:
|
163
|
+
Enabled: true
|
164
|
+
Style/NumberedParameters:
|
165
|
+
Enabled: true
|
166
|
+
Style/NumberedParametersLimit:
|
167
|
+
Enabled: true
|
168
|
+
Style/ObjectThen:
|
169
|
+
Enabled: true
|
170
|
+
Style/OpenStructUse:
|
171
|
+
Enabled: true
|
172
|
+
Style/OperatorMethodCall:
|
173
|
+
Enabled: true
|
174
|
+
Style/QuotedSymbols:
|
175
|
+
Enabled: true
|
176
|
+
Style/RedundantArgument:
|
177
|
+
Enabled: true
|
178
|
+
Style/RedundantArrayConstructor:
|
179
|
+
Enabled: true
|
180
|
+
Style/RedundantConstantBase:
|
181
|
+
Enabled: true
|
182
|
+
Style/RedundantCurrentDirectoryInPath:
|
183
|
+
Enabled: true
|
184
|
+
Style/RedundantDoubleSplatHashBraces:
|
185
|
+
Enabled: true
|
186
|
+
Style/RedundantEach:
|
187
|
+
Enabled: true
|
188
|
+
Style/RedundantFilterChain:
|
189
|
+
Enabled: true
|
190
|
+
Style/RedundantHeredocDelimiterQuotes:
|
191
|
+
Enabled: true
|
192
|
+
Style/RedundantInitialize:
|
193
|
+
Enabled: true
|
194
|
+
Style/RedundantLineContinuation:
|
195
|
+
Enabled: true
|
196
|
+
Style/RedundantRegexpArgument:
|
197
|
+
Enabled: true
|
198
|
+
Style/RedundantRegexpConstructor:
|
199
|
+
Enabled: true
|
200
|
+
Style/RedundantSelfAssignmentBranch:
|
201
|
+
Enabled: true
|
202
|
+
Style/RedundantStringEscape:
|
203
|
+
Enabled: true
|
204
|
+
Style/ReturnNilInPredicateMethodDefinition:
|
205
|
+
Enabled: true
|
206
|
+
Style/SelectByRegexp:
|
207
|
+
Enabled: true
|
208
|
+
Style/StringChars:
|
209
|
+
Enabled: true
|
210
|
+
Style/SwapValues:
|
211
|
+
Enabled: true
|
212
|
+
Style/YAMLFileRead:
|
213
|
+
Enabled: true
|
214
|
+
Style/Documentation:
|
215
|
+
Enabled: false
|
216
|
+
|
217
|
+
Metrics/MethodLength:
|
218
|
+
Max: 120
|
219
|
+
|
220
|
+
RSpec/MultipleExpectations:
|
221
|
+
Max: 20
|
222
|
+
|
223
|
+
RSpec/ExampleLength:
|
224
|
+
Enabled: false
|
225
|
+
|
226
|
+
RSpec/NestedGroups:
|
227
|
+
Enabled: false
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2023-10-11 15:02:29 UTC using RuboCop version 1.56.4.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
11
|
+
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
|
12
|
+
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
|
13
|
+
Naming/FileName:
|
14
|
+
Exclude:
|
15
|
+
- 'lib/sidekiq-belt.rb'
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at daniloj.dasilva@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 Danilo Jeremias da Silva
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
# Sidekiq::Belt
|
2
|
+
|
3
|
+
This Ruby gem enhances the capabilities of Sidekiq, Sidekiq Pro, and Sidekiq Enterprise by adding essential utilities.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install the gem and add to the application's Gemfile by executing:
|
8
|
+
|
9
|
+
$ bundle add sidekiq-belt
|
10
|
+
|
11
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
12
|
+
|
13
|
+
$ gem install sidekiq-belt
|
14
|
+
|
15
|
+
## Features
|
16
|
+
|
17
|
+
GitHub Copilot: Sure, here's a rewritten version of the content that is easier to read for a developer:
|
18
|
+
|
19
|
+
## Features
|
20
|
+
|
21
|
+
To enable all features, add the following code to the end of the Sidekiq initializer file:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
Sidekiq::Belt.use!
|
25
|
+
```
|
26
|
+
|
27
|
+
or
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
Sidekiq::Belt.use!([:all])
|
31
|
+
```
|
32
|
+
|
33
|
+
To enable only specific features, add the following code to the Sidekiq initializer file while passing the necessary options:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
Sidekiq::Belt.use!([:periodic_run, :periodic_pause])
|
37
|
+
```
|
38
|
+
|
39
|
+
### Run Periodic Jobs Manually (sidekiq-enterprise)
|
40
|
+
|
41
|
+
This functionality adds a button on the Sidekiq Enterprise web page that allows manual execution of a job.
|
42
|
+
To enable this feature, pass the `periodic_run` option:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
Sidekiq::Belt.use!([:periodic_run])
|
46
|
+
```
|
47
|
+
|
48
|
+
![periodic_run_index](https://github.com/dannnylo/sidekiq-belt/assets/20794/1c6ceed7-c2be-447e-b61c-b1e15f002bc2)
|
49
|
+
![periodic_run_show](https://github.com/dannnylo/sidekiq-belt/assets/20794/be8cab4b-bfb1-4e15-b01b-56c69231169b)
|
50
|
+
|
51
|
+
### Pause Periodic Jobs (sidekiq-enterprise)
|
52
|
+
|
53
|
+
This feature is not yet implemented.
|
54
|
+
|
55
|
+
### Delete an Unfinished Batch (sidekiq-pro)
|
56
|
+
|
57
|
+
This feature is not yet implemented.
|
58
|
+
```
|
59
|
+
Sidekiq::Belt.use!
|
60
|
+
```
|
61
|
+
|
62
|
+
or
|
63
|
+
|
64
|
+
```
|
65
|
+
Sidekiq::Belt.use!([:all])
|
66
|
+
```
|
67
|
+
|
68
|
+
To enable only the features you want, add the code to the Sidekiq initializer file while passing the necessary options.
|
69
|
+
|
70
|
+
```
|
71
|
+
Sidekiq::Belt.use!([:periodic_run, :periodic_pause])
|
72
|
+
```
|
73
|
+
|
74
|
+
### Run manualy Periodic Jobs (sidekiq-enterprise)
|
75
|
+
|
76
|
+
This functionality adds a button on the Sidekiq Enterprise web page that allows manual execution of a job.
|
77
|
+
|
78
|
+
To enable this feature, pass the periodic_run option:
|
79
|
+
|
80
|
+
```
|
81
|
+
Sidekiq::Belt.use!([:periodic_run])
|
82
|
+
```
|
83
|
+
|
84
|
+
![periodic_run_index](https://github.com/dannnylo/sidekiq-belt/assets/20794/1c6ceed7-c2be-447e-b61c-b1e15f002bc2)
|
85
|
+
![periodic_run_show](https://github.com/dannnylo/sidekiq-belt/assets/20794/be8cab4b-bfb1-4e15-b01b-56c69231169b)
|
86
|
+
|
87
|
+
### Pause Periodic Jobs (sidekiq-enterprise)
|
88
|
+
|
89
|
+
It will be implemented in upcoming versions.
|
90
|
+
|
91
|
+
### Delete a not finished Batch (sidekiq-pro)
|
92
|
+
|
93
|
+
It will be implemented in upcoming versions.
|
94
|
+
|
95
|
+
## Development
|
96
|
+
|
97
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
98
|
+
|
99
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
100
|
+
|
101
|
+
## Contributing
|
102
|
+
|
103
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/dannnylo/sidekiq-belt. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/dannnylo/sidekiq-belt/blob/main/CODE_OF_CONDUCT.md).
|
104
|
+
|
105
|
+
## License
|
106
|
+
|
107
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
108
|
+
|
109
|
+
## Code of Conduct
|
110
|
+
|
111
|
+
Everyone interacting in the Sidekiq::Belt project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/dannnylo/sidekiq-belt/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "sidekiq"
|
4
|
+
# require_relative "feature"
|
5
|
+
|
6
|
+
module Sidekiq
|
7
|
+
module Belt
|
8
|
+
module Community
|
9
|
+
module Files
|
10
|
+
def self.use!(_options = [:all])
|
11
|
+
# all = options.include?(:all)
|
12
|
+
# Sidekiq::Belt::Pro::Feature.load! if all || options.include?(:feature)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "sidekiq"
|
4
|
+
|
5
|
+
require_relative "periodic_pause"
|
6
|
+
require_relative "periodic_run"
|
7
|
+
|
8
|
+
module Sidekiq
|
9
|
+
module Belt
|
10
|
+
module Ent
|
11
|
+
module Files
|
12
|
+
def self.use!(options = [:all])
|
13
|
+
return unless Sidekiq.ent?
|
14
|
+
|
15
|
+
all = options.include?(:all)
|
16
|
+
|
17
|
+
Sidekiq::Belt::Ent::PeriodicPause.use! if all || options.include?(:periodic_pause)
|
18
|
+
Sidekiq::Belt::Ent::PeriodicRun.use! if all || options.include?(:periodic_run)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sidekiq
|
4
|
+
module Belt
|
5
|
+
module Ent
|
6
|
+
module PeriodicPause
|
7
|
+
def self.use!
|
8
|
+
# require("sidekiq-ent/periodic")
|
9
|
+
# require("sidekiq-ent/periodic/static_loop")
|
10
|
+
|
11
|
+
# Sidekiq::Periodic::Loop.prepend(Sidekiq::Belt::Ent::PeriodicPause)
|
12
|
+
# Sidekiq::Periodic::StaticLoop.prepend(Sidekiq::Belt::Ent::PeriodicPause)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "sidekiq/web/helpers"
|
4
|
+
|
5
|
+
module Sidekiq
|
6
|
+
module Belt
|
7
|
+
module Ent
|
8
|
+
module PeriodicRun
|
9
|
+
def run
|
10
|
+
args = begin
|
11
|
+
JSON.parse(options)["args"]
|
12
|
+
rescue StandardError
|
13
|
+
{}
|
14
|
+
end
|
15
|
+
|
16
|
+
Module.const_get(klass).perform_async(*args)
|
17
|
+
end
|
18
|
+
|
19
|
+
module SidekiqLoopsPeriodicRun
|
20
|
+
FORCE_RUN_BUTTON = <<~ERB
|
21
|
+
<form action="<%= root_path %>loops/<%= loup.lid %>/run" method="post">
|
22
|
+
<%= csrf_tag %>
|
23
|
+
<input class="btn btn-danger" type="submit" name="run" value="<%= t('Run now') %>"
|
24
|
+
data-confirm="Run the job <%= loup.klass %>? <%= t('AreYouSure') %>" />
|
25
|
+
</form>
|
26
|
+
ERB
|
27
|
+
|
28
|
+
FORCE_RUN_SINGLE_PAGE = <<~ERB
|
29
|
+
<tr>
|
30
|
+
<th><%= t('Force Run') %></th>
|
31
|
+
<td>
|
32
|
+
<form action="<%= root_path %>loops/<%= @loop.lid %>/run" method="post">
|
33
|
+
<%= csrf_tag %>
|
34
|
+
<input class="btn btn-danger" type="submit" name="run" value="<%= t('Run now') %>"
|
35
|
+
data-confirm="Run the job <%= @loop.klass %>? <%= t('AreYouSure') %>" />
|
36
|
+
</form>
|
37
|
+
</td>
|
38
|
+
</tr>
|
39
|
+
</tbody>
|
40
|
+
ERB
|
41
|
+
|
42
|
+
def self.registered(app)
|
43
|
+
app.replace_content("/loops") do |content|
|
44
|
+
# Add the top of the table
|
45
|
+
content.gsub!("</th>\n </tr>", "</th><th><%= t('Force Run') %></th></th>\n </tr>")
|
46
|
+
|
47
|
+
# Add the run button
|
48
|
+
content.gsub!(
|
49
|
+
"</td>\n </tr>\n <% end %>",
|
50
|
+
"</td>\n<td>#{FORCE_RUN_BUTTON}</td>\n </tr>\n <% end %>"
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
app.replace_content("/loops/:lid") do |content|
|
55
|
+
i = 0
|
56
|
+
|
57
|
+
content.gsub!("</tbody>") do |match|
|
58
|
+
if i.zero?
|
59
|
+
i += 1
|
60
|
+
|
61
|
+
FORCE_RUN_SINGLE_PAGE
|
62
|
+
else
|
63
|
+
match
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
app.post("/loops/:lid/run") do
|
69
|
+
Sidekiq::Periodic::Loop.new(params[:lid]).run
|
70
|
+
|
71
|
+
return redirect "#{root_path}loops"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.use!
|
77
|
+
require("sidekiq-ent/web")
|
78
|
+
require("sidekiq-ent/periodic")
|
79
|
+
require("sidekiq-ent/periodic/static_loop")
|
80
|
+
|
81
|
+
Sidekiq::Web.register(Sidekiq::Belt::Ent::PeriodicRun::SidekiqLoopsPeriodicRun)
|
82
|
+
Sidekiq::Periodic::Loop.prepend(Sidekiq::Belt::Ent::PeriodicRun)
|
83
|
+
Sidekiq::Periodic::StaticLoop.prepend(Sidekiq::Belt::Ent::PeriodicRun)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "sidekiq"
|
4
|
+
|
5
|
+
# require_relative "feature"
|
6
|
+
|
7
|
+
module Sidekiq
|
8
|
+
module Belt
|
9
|
+
module Pro
|
10
|
+
module Files
|
11
|
+
def self.use!(_options = [:all])
|
12
|
+
return unless Sidekiq.pro?
|
13
|
+
|
14
|
+
true
|
15
|
+
# all = options.include?(:all)
|
16
|
+
# Sidekiq::Belt::Pro::Feature.load! if all || options.include?(:feature)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/sidekiq/belt.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "sidekiq"
|
4
|
+
|
5
|
+
require_relative "belt/version"
|
6
|
+
require_relative "web_action_helper"
|
7
|
+
require_relative "web_router_helper"
|
8
|
+
|
9
|
+
require_relative("belt/community/files")
|
10
|
+
require_relative("belt/ent/files")
|
11
|
+
require_relative("belt/pro/files")
|
12
|
+
|
13
|
+
module Sidekiq
|
14
|
+
module Belt
|
15
|
+
class Error < StandardError; end
|
16
|
+
|
17
|
+
def self.use!(options = [:all])
|
18
|
+
Sidekiq::Belt::Community::Files.use!(options)
|
19
|
+
Sidekiq::Belt::Pro::Files.use!(options)
|
20
|
+
Sidekiq::Belt::Ent::Files.use!(options)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "sidekiq/web/helpers"
|
4
|
+
require "sidekiq/web/action"
|
5
|
+
|
6
|
+
module Sidekiq
|
7
|
+
module WebActionHelper
|
8
|
+
def self.blocks
|
9
|
+
@blocks ||= {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def render(engine, content, options = {})
|
13
|
+
begin
|
14
|
+
path_info = /"([^"]*)"/.match(block.source.to_s)[1]
|
15
|
+
rescue StandardError
|
16
|
+
path_info = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
path_info ||= ::Rack::Utils.unescape(env["PATH_INFO"])
|
20
|
+
|
21
|
+
Sidekiq::WebActionHelper.blocks.fetch(path_info.to_s, []).each do |content_block|
|
22
|
+
content_block.call(content)
|
23
|
+
end
|
24
|
+
|
25
|
+
super(engine, content, options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
Sidekiq::WebAction.prepend(Sidekiq::WebActionHelper)
|
30
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "sidekiq/web/helpers"
|
4
|
+
require "sidekiq/web/router"
|
5
|
+
require_relative "web_action_helper"
|
6
|
+
|
7
|
+
module Sidekiq
|
8
|
+
module WebRouterHelper
|
9
|
+
def replace_content(path, &block)
|
10
|
+
Sidekiq::WebActionHelper.blocks[path.to_s] ||= []
|
11
|
+
Sidekiq::WebActionHelper.blocks[path.to_s] << block
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
Sidekiq::WebRouter.prepend(Sidekiq::WebRouterHelper)
|
16
|
+
end
|
data/lib/sidekiq-belt.rb
ADDED
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sidekiq-belt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Danilo Jeremias da Silva
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-10-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sidekiq
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '7.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '7.0'
|
27
|
+
description: This Ruby gem enhances the capabilities of Sidekiq, Sidekiq Pro, and
|
28
|
+
Sidekiq Enterprise by adding essential utilities.
|
29
|
+
email:
|
30
|
+
- daniloj.dasilva@gmail.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- ".rspec"
|
36
|
+
- ".rubocop.yml"
|
37
|
+
- ".rubocop_todo.yml"
|
38
|
+
- CHANGELOG.md
|
39
|
+
- CODE_OF_CONDUCT.md
|
40
|
+
- LICENSE
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- lib/sidekiq-belt.rb
|
44
|
+
- lib/sidekiq/belt.rb
|
45
|
+
- lib/sidekiq/belt/community/files.rb
|
46
|
+
- lib/sidekiq/belt/ent/files.rb
|
47
|
+
- lib/sidekiq/belt/ent/periodic_pause.rb
|
48
|
+
- lib/sidekiq/belt/ent/periodic_run.rb
|
49
|
+
- lib/sidekiq/belt/pro/files.rb
|
50
|
+
- lib/sidekiq/belt/version.rb
|
51
|
+
- lib/sidekiq/web_action_helper.rb
|
52
|
+
- lib/sidekiq/web_router_helper.rb
|
53
|
+
- sig/sidekiq/belt.rbs
|
54
|
+
homepage: https://github.com/dannnylo/sidekiq-belt
|
55
|
+
licenses:
|
56
|
+
- MIT
|
57
|
+
metadata:
|
58
|
+
homepage_uri: https://github.com/dannnylo/sidekiq-belt
|
59
|
+
source_code_uri: https://github.com/dannnylo/sidekiq-belt
|
60
|
+
rubygems_mfa_required: 'true'
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 2.6.0
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubygems_version: 3.4.10
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: This Ruby gem enhances the capabilities of Sidekiq, Sidekiq Pro, and Sidekiq
|
80
|
+
Enterprise by adding essential utilities.
|
81
|
+
test_files: []
|