request_repeater 0.1.0.1 → 0.1.0.2
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 +4 -4
- data/.travis.yml +3 -1
- data/Gemfile +2 -0
- data/README.md +265 -3
- data/Rakefile +6 -0
- data/lib/request_repeater.rb +1 -0
- data/lib/request_repeater/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8ea5315f4de43f2af15ac16f4fd2969b72a45c6
|
4
|
+
data.tar.gz: 5ba44c94b23a93438208fa1a8bfcda2f3187699c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6edfdd4ba6e00243ae3f63009c70f1e380a30b83b64e2b8d2d171f2c7a53822eba0c52815ad065179a388d682492730447534dcb1dbe4bf5385be0e3c5b4e657
|
7
|
+
data.tar.gz: c56ff347a10cddfeb88d8932550227577997d3b5502d69f85965a3d2a94f65e347e055139946b8aac1226938328efa3ee5fb8f2dcd8ba793e114fce569489c2d
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,27 @@
|
|
1
1
|
# Request Repeater
|
2
2
|
|
3
|
-
Simple [Ruby Gem](
|
3
|
+
Simple [Ruby Gem](https://rubygems.org/gems/request_repeater)
|
4
|
+
or [Docker image](https://hub.docker.com/r/pobble/request_repeater/) to
|
4
5
|
execute GET request on an endpoint (Request Repeater).
|
5
6
|
|
6
|
-
This is
|
7
|
+
This is useful if you cannot do cron jobs in your application setup.
|
7
8
|
|
8
9
|
Just expose a certain route in your web application to execute the job
|
9
|
-
(or to schedule
|
10
|
+
(or to schedule background job) and tell `request_repeeter` to trigger GET requests on it.
|
11
|
+
|
12
|
+
**Application can be executed as**:
|
13
|
+
|
14
|
+
* :heavy_dollar_sign: [Standalone Ruby gem application](https://github.com/Pobble/request_repeater#standalone-ruby-gem)
|
15
|
+
* :whale: [Docker image application](https://github.com/Pobble/request_repeater#docker-image-application)
|
10
16
|
|
11
17
|
## Standalone Ruby gem
|
12
18
|
|
19
|
+
[](https://travis-ci.org/Pobble/request_repeater)
|
20
|
+
[](https://codeclimate.com/github/Pobble/request_repeater)
|
21
|
+
[](https://codeclimate.com/github/Pobble/request_repeater/coverage)
|
22
|
+
|
23
|
+
#### Instalation
|
24
|
+
|
13
25
|
Add this line to your application's Gemfile:
|
14
26
|
|
15
27
|
```ruby
|
@@ -28,6 +40,256 @@ Or install it yourself as:
|
|
28
40
|
|
29
41
|
$ gem install request_repeater
|
30
42
|
|
43
|
+
#### Usage
|
44
|
+
|
45
|
+
**Single endpoint**
|
46
|
+
|
47
|
+
Pass enviroment variable `URL` with location
|
48
|
+
|
49
|
+
```
|
50
|
+
# every second send request to http://localhost:3000/execute-something.html
|
51
|
+
$ URL=http://localhost:3000/execute-something.html bundle exec request_repeater
|
52
|
+
|
53
|
+
# ...or if you didn't use Bundler
|
54
|
+
$ URL=http://localhost:3000/execute-something.html request_repeater
|
55
|
+
```
|
56
|
+
|
57
|
+
Default timeout is 1000ms (1 second), if you need different timeout pass
|
58
|
+
`SLEEPFOR` env variable:
|
59
|
+
|
60
|
+
```
|
61
|
+
# every two seconds send request to https://localhost:3000/maintenance?token=12345
|
62
|
+
$ URL=https://localhost:3000/maintenance?token=12345 SLEEPFOR=2000 bundle exec request_repeater
|
63
|
+
```
|
64
|
+
|
65
|
+
For authentication we recommend just to pass token as a query param,
|
66
|
+
like: `/maintenance?token=12345`
|
67
|
+
|
68
|
+
**Multiple endpoints**
|
69
|
+
|
70
|
+
You need to pass `URLS` env variable with json in format:
|
71
|
+
|
72
|
+
```json
|
73
|
+
{
|
74
|
+
"urls": [
|
75
|
+
{"url":"http://myserver/some-endpoint", "sleep":4000},
|
76
|
+
{"url":"http://myserver/another-endpoint", "sleep":1200},
|
77
|
+
{"url":"http://myserver/third-endpoint", "sleep":72000}
|
78
|
+
]
|
79
|
+
}
|
80
|
+
```
|
81
|
+
|
82
|
+
example:
|
83
|
+
|
84
|
+
```
|
85
|
+
$ URLS='{"urls": [{"url":"http://localhost/some-endpoint", "sleep":1200}, {"url":"http://localhost/another-endpoint","sleep":3000}]}' bundle exec request_repeater
|
86
|
+
```
|
87
|
+
|
88
|
+
> `URL` and `SLEEPFOR` env variables are ignored when you provide `URLS` env variable
|
89
|
+
|
90
|
+
## Docker Image Application
|
91
|
+
|
92
|
+

|
93
|
+
[](https://imagelayers.io/?images=pobble/request_repeater:latest 'Get your own badge on imagelayers.io')
|
94
|
+
|
95
|
+
#### Usage
|
96
|
+
|
97
|
+
```bash
|
98
|
+
$ docker pull pobble/request_repeater
|
99
|
+
```
|
100
|
+
|
101
|
+
**Single Endpoint**
|
102
|
+
|
103
|
+
Specify `URL` env variable
|
104
|
+
|
105
|
+
|
106
|
+
```bash
|
107
|
+
$ docker run -e "URL=http://www.my-app.dot/execute-something.html" pobble/request_repeater
|
108
|
+
```
|
109
|
+
|
110
|
+
Default timeout is 1000ms (1 second), if you need different timeout pass
|
111
|
+
`SLEEPFOR` env variable:
|
112
|
+
|
113
|
+
```bash
|
114
|
+
# 2 second timeout
|
115
|
+
$ docker run -e "SLEEPFOR=2000" -e "URL=http://www.my-app.dot/execute-something.html" pobble/request_repeater
|
116
|
+
```
|
117
|
+
|
118
|
+
To execute on localhost of image host:
|
119
|
+
|
120
|
+
```bash
|
121
|
+
$ docker run -e "SLEEPFOR=2000" -e "URL=http://localhost:3000/execute-something.html" --net="host" pobble/request_repeater
|
122
|
+
```
|
123
|
+
|
124
|
+
You want authentication ? How about passing token param:
|
125
|
+
|
126
|
+
```bash
|
127
|
+
$ docker run -e "URL=https://www.my-app.dot/execute-something.html?token=1234556" pobble/request_repeater
|
128
|
+
```
|
129
|
+
|
130
|
+
**docker-compose.yml example**
|
131
|
+
|
132
|
+
```yml
|
133
|
+
---
|
134
|
+
version: '2'
|
135
|
+
services:
|
136
|
+
nginx:
|
137
|
+
image: quay.io/myorg/my-nginx-image
|
138
|
+
ports:
|
139
|
+
- "80:80"
|
140
|
+
request_repeater:
|
141
|
+
image: 'pobble/request_repeater'
|
142
|
+
links:
|
143
|
+
- nginx:nginx
|
144
|
+
environment:
|
145
|
+
URL: 'http://nginx/some-endpoint'
|
146
|
+
SLEEPFOR: 7200
|
147
|
+
```
|
148
|
+
|
149
|
+
|
150
|
+
**AWS Elastic Beanstalk Dockerrun.aws.json example**
|
151
|
+
|
152
|
+
```json
|
153
|
+
{
|
154
|
+
"containerDefinitions": [
|
155
|
+
{
|
156
|
+
"name": "nginx",
|
157
|
+
"image": "........",
|
158
|
+
"portMappings": [
|
159
|
+
{
|
160
|
+
"hostPort": 80,
|
161
|
+
"containerPort": 80
|
162
|
+
}
|
163
|
+
],
|
164
|
+
},
|
165
|
+
{
|
166
|
+
"name": "request_repeater",
|
167
|
+
"image": "pobble/request_repeater",
|
168
|
+
"essential": true,
|
169
|
+
"memory": 150,
|
170
|
+
"links": [ "nginx" ],
|
171
|
+
"environment": [
|
172
|
+
{
|
173
|
+
"name": "URL",
|
174
|
+
"value": "http://nginx/some-endpoint"
|
175
|
+
}
|
176
|
+
]
|
177
|
+
}
|
178
|
+
]
|
179
|
+
}
|
180
|
+
```
|
181
|
+
|
182
|
+
**Multiple endpoints**
|
183
|
+
|
184
|
+
You need to pass `URLS` env variable with JSON in format:
|
185
|
+
|
186
|
+
```json
|
187
|
+
{
|
188
|
+
"urls": [
|
189
|
+
{"url":"http://myserver/some-endpoint", "sleep":4000},
|
190
|
+
{"url":"http://myserver/another-endpoint", "sleep":1200},
|
191
|
+
{"url":"http://myserver/third-endpoint", "sleep":72000}
|
192
|
+
]
|
193
|
+
}
|
194
|
+
```
|
195
|
+
|
196
|
+
```bash
|
197
|
+
$ docker run -e 'URLS={"urls": [{"url":"http://localhost/some-endpoint", "sleep":1200}, {"url":"http://localhost/another-endpoint","sleep":3000}]}' --net="host" pobble/request_repeater
|
198
|
+
```
|
199
|
+
|
200
|
+
> `URL` and `SLEEPFOR` env variables are ignored when you provide `URLS` env variable
|
201
|
+
|
202
|
+
#### Docker Composer example
|
203
|
+
|
204
|
+
*docker-compose.yml*:
|
205
|
+
|
206
|
+
```yml
|
207
|
+
---
|
208
|
+
version: '2'
|
209
|
+
services:
|
210
|
+
nginx:
|
211
|
+
image: quay.io/myorg/my-nginx-image
|
212
|
+
ports:
|
213
|
+
- "80:80"
|
214
|
+
request_repeater:
|
215
|
+
image: 'pobble/request_repeater'
|
216
|
+
links:
|
217
|
+
- nginx:nginx
|
218
|
+
environment:
|
219
|
+
URLS: '{"urls": [{"url":"http://nginx/some-endpoint", "sleep":1200},
|
220
|
+
{"url":"http://nginx/another-endpoint","sleep":7200}]}'
|
221
|
+
```
|
222
|
+
|
223
|
+
#### AWS Elastic Beanstalk Dockerrun.aws.json example usage
|
224
|
+
|
225
|
+
*Dockerrun.aws.json*:
|
226
|
+
|
227
|
+
```json
|
228
|
+
{
|
229
|
+
"containerDefinitions": [
|
230
|
+
{
|
231
|
+
"name": "nginx",
|
232
|
+
"image": "........",
|
233
|
+
"portMappings": [
|
234
|
+
{
|
235
|
+
"hostPort": 80,
|
236
|
+
"containerPort": 80
|
237
|
+
}
|
238
|
+
],
|
239
|
+
},
|
240
|
+
{
|
241
|
+
"name": "request_repeater",
|
242
|
+
"image": "pobble/request_repeater",
|
243
|
+
"essential": true,
|
244
|
+
"memory": 150,
|
245
|
+
"links": [ "nginx" ],
|
246
|
+
"environment": [
|
247
|
+
{
|
248
|
+
"name": "URLS",
|
249
|
+
"value":"{\"urls\":[{\"url\":\"http://nginx/some-endpoint\",\"sleep\":1300},{\"url\":\"http://nginx/other-endpoint\",\"sleep\":1200000}]}"
|
250
|
+
|
251
|
+
}
|
252
|
+
]
|
253
|
+
}
|
254
|
+
]
|
255
|
+
}
|
256
|
+
```
|
257
|
+
|
258
|
+
#### Kill the container
|
259
|
+
|
260
|
+
```bash
|
261
|
+
$ docker kill $(docker ps | grep request_repeater | awk "{print \$1}")
|
262
|
+
|
263
|
+
# sudo version
|
264
|
+
$ sudo docker kill $(sudo docker ps | grep request_repeater | awk "{print \$1}")
|
265
|
+
```
|
266
|
+
|
267
|
+
## Minimum Sleeptime
|
268
|
+
|
269
|
+
In order to avoid docker container / gem to use all CPU resources there is a minimum sleep
|
270
|
+
time implementend set to `500 miliseconds`. If you need to use this
|
271
|
+
image without this limit provide one more extra enviroment variable `MINIMUMSLEEP`:
|
272
|
+
|
273
|
+
```
|
274
|
+
$ URL=https://www.my-app.dot/execute-something.html SLEEPFOR=100 MINIMUMSLEEP=0 bundle exec request_repeater
|
275
|
+
|
276
|
+
$ docker run -e "SLEEPFOR=300" -e 'MINIMUMSLEEP=300' -e "URL=http://www.my-app.dot/execute-something.html" pobble/request_repeater # 300 ms
|
277
|
+
|
278
|
+
$ docker run -e "SLEEPFOR=0" -e 'MINIMUMSLEEP=0' -e "URL=http://www.my-app.dot/execute-something.html" pobble/request_repeater # no limit
|
279
|
+
```
|
280
|
+
|
281
|
+
## Alternatives
|
282
|
+
|
283
|
+
This Ruby Gem (and Docker image) is attempt to rewrite [little_bastard golang Docker image](https://github.com/equivalent/little_bastard)
|
284
|
+
which has a issue with memory leak causing eventually docker container to
|
285
|
+
restart after several hours of activity, but can handle more requests
|
286
|
+
per second. If you need something that does more requests per second
|
287
|
+
(e.g.: testing your app against DDOS attack)
|
288
|
+
then [Little Bastard](https://hub.docker.com/r/pobble/request_repeater/)
|
289
|
+
image is better for you.
|
290
|
+
|
291
|
+
`pobble/request_repeater` aims to provide stable flow of
|
292
|
+
repeating requests without crushing over time.
|
31
293
|
|
32
294
|
## License
|
33
295
|
|
data/Rakefile
ADDED
data/lib/request_repeater.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: request_repeater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Valent
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- Gemfile
|
98
98
|
- LICENSE.txt
|
99
99
|
- README.md
|
100
|
+
- Rakefile
|
100
101
|
- bin/console
|
101
102
|
- bin/run
|
102
103
|
- bin/setup
|