Skip to content

Commit d109a36

Browse files
committed
updated readme
1 parent b75911f commit d109a36

File tree

7 files changed

+27
-20
lines changed

7 files changed

+27
-20
lines changed

README.md

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -223,26 +223,33 @@ set --rate-limit-pr-creations with appropriate value. More example below
223223

224224
##### Default case:
225225

226+
By default, this feature is disabled. This will be enabled when argument ``--rate-limit-pr-creations`` will be passed
227+
with
228+
appropriate value.
229+
226230
```
227231
example usage: dockerfile-image-update all image-tag-store-repo-falcon //disabled
228-
example usage: dockerfile-image-update --rate-limit-pr-creations 500 all image-tag-store-repo-falcon //enabled
229232
```
230-
By default, this feature is disabled. This will be enabled when argument ``--useratelimiting`` will be passed appropriate value
231-
Above example will throttle the number of PRs cut based on default values as mentioned above i.e.,
232-
maximum 500 PRs could be sent within a period of 1 hour . To distribute the load uniformly and avoid sudden spikes,
233-
at max only 8(500/60) PRs could be sent in every 1 min. The process will go in waiting state until next PR could be sent.
234233

235234
##### Configuring the rate limit:
236235

236+
Below are some examples that will throttle the number of PRs cut based on values passed to the
237+
argument ``--rate-limit-pr-creations``
238+
The argument value should be in format ``<positive_integer>-<ISO-8601_formatted_time>``.
239+
For example ``--rate-limit-pr-creations 60-PT1H`` would mean the tool will cut 60 PRs every hour and the rate of adding
240+
a new PR will be (PT1H/60) i.e. one minute.
241+
This will distribute the load uniformly and avoid sudden spikes, The process will go in waiting state until next PR
242+
could be sent.
243+
244+
Below are some more examples:
245+
237246
```
238-
example usage:
239-
dockerfile-image-update --rate-limit-pr-creations 500 all image-tag-store-repo-falcon //DFIU can send up to 500 PRs per hour
240-
dockerfile-image-update --rate-limit-pr-creations 500-per-s all image-tag-store-repo-falcon //DFIU can send up to 500 PRs per second
241-
dockerfile-image-update --rate-limit-pr-creations 500-per-60s all image-tag-store-repo-falcon //DFIU can send up to 500 PRs per 60 second
242-
dockerfile-image-update --rate-limit-pr-creations 500-per-m all image-tag-store-repo-falcon //DFIU can send up to 500 PRs per minute
243-
dockerfile-image-update --rate-limit-pr-creations 500-per-1h all image-tag-store-repo-falcon //DFIU can send up to 500 PRs per hour
244-
dockerfile-image-update --rate-limit-pr-creations 500-per-h all image-tag-store-repo-falcon //DFIU can send up to 500 PRs per hour
245-
dockerfile-image-update --rate-limit-pr-creations 50perhour all image-tag-store-repo-falcon //DFIU will not impose any rate limiting as argument value is not valid
247+
Usage:
248+
dockerfile-image-update --rate-limit-pr-creations 60-PT1H all image-tag-store-repo-falcon //DFIU can send up to 60 PRs per hour.
249+
dockerfile-image-update --rate-limit-pr-creations 500-PT1H all image-tag-store-repo-falcon //DFIU can send up to 500 PRs per hour.
250+
dockerfile-image-update --rate-limit-pr-creations 86400-PT24H all image-tag-store-repo-falcon //DFIU can send up to 1 PRs per second.
251+
dockerfile-image-update --rate-limit-pr-creations 1-PT1S all image-tag-store-repo-falcon //Same as above. DFIU can send up to 1 PRs per second.
252+
dockerfile-image-update --rate-limit-pr-creations 5000 all image-tag-store-repo-falcon //rate limiting will be disabled because argument is not in correct format.
246253
```
247254

248255
## Developer Guide

dockerfile-image-update/src/main/java/com/salesforce/dockerfileimageupdate/subcommands/impl/All.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class All implements ExecutableWithNamespace {
3838
@Override
3939
public void execute(final Namespace ns, final DockerfileGitHubUtil dockerfileGitHubUtil) throws Exception {
4040
loadDockerfileGithubUtil(dockerfileGitHubUtil);
41-
RateLimiter rateLimiter = RateLimiter.getRateLimiter(ns);
41+
RateLimiter rateLimiter = RateLimiter.getInstance(ns);
4242
String store = ns.get(Constants.STORE);
4343
try {
4444
ImageTagStore imageTagStore = ImageStoreUtil.initializeImageTagStore(this.dockerfileGitHubUtil, store);

dockerfile-image-update/src/main/java/com/salesforce/dockerfileimageupdate/subcommands/impl/Child.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void execute(final Namespace ns, final DockerfileGitHubUtil dockerfileGit
3737
String forceTag = ns.get(Constants.FORCE_TAG);
3838
String store = ns.get(Constants.STORE);
3939
ImageStoreUtil imageStoreUtil = getImageStoreUtil();
40-
RateLimiter rateLimiter = RateLimiter.getRateLimiter(ns);
40+
RateLimiter rateLimiter = RateLimiter.getInstance(ns);
4141
try {
4242
ImageTagStore imageTagStore = imageStoreUtil.initializeImageTagStore(dockerfileGitHubUtil, store);
4343
/* Updates store if a store is specified. */

dockerfile-image-update/src/main/java/com/salesforce/dockerfileimageupdate/subcommands/impl/Parent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void execute(final Namespace ns, DockerfileGitHubUtil dockerfileGitHubUti
6060
PullRequests pullRequests = getPullRequests();
6161
GitHubPullRequestSender pullRequestSender = getPullRequestSender(dockerfileGitHubUtil, ns);
6262
GitForkBranch gitForkBranch = getGitForkBranch(ns);
63-
RateLimiter rateLimiter = RateLimiter.getRateLimiter(ns);
63+
RateLimiter rateLimiter = RateLimiter.getInstance(ns);
6464
log.info("Finding Dockerfiles with the given image...");
6565

6666
Integer gitApiSearchLimit = ns.get(Constants.GIT_API_SEARCH_LIMIT);

dockerfile-image-update/src/main/java/com/salesforce/dockerfileimageupdate/utils/RateLimit.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
* @see RateLimiter
1515
*/
1616
public class RateLimit {
17-
public static final String ERROR_MESSAGE = "Unexpected format or unit encountered, valid input is " +
18-
"<integer>-<ISO-8601_formatted_time> Example: 500-PT1S means(500 per second) \n" +
17+
private static final String ERROR_MESSAGE = "Unexpected format or unit encountered, valid input is " +
18+
"<positive_integer>-<ISO-8601_formatted_time> Example: 500-PT1S means(500 per second) \n" +
1919
"500-PT1M means(500 per Minute)";
2020
private static final Logger log = LoggerFactory.getLogger(RateLimit.class);
2121
private final long rate; //Maximum count of PRs to be sent per rLimitDuration

dockerfile-image-update/src/main/java/com/salesforce/dockerfileimageupdate/utils/RateLimiter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public RateLimiter() {
7575
* null otherwise.
7676
* @see net.sourceforge.argparse4j.inf.Namespace Namespace
7777
*/
78-
public static RateLimiter getRateLimiter(Namespace ns) {
78+
public static RateLimiter getInstance(Namespace ns) {
7979
String rateLimitPRCreation = ns.get(Constants.RATE_LIMIT_PR_CREATION);
8080
RateLimiter rateLimiter = null;
8181

dockerfile-image-update/src/test/java/com/salesforce/dockerfileimageupdate/utils/RateLimiterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void testGetRateLimiter(String envVariableVal, Class expectedReturnType,
7979
Map<String, Object> nsMap = ImmutableMap.of(
8080
Constants.RATE_LIMIT_PR_CREATION, envVariableVal);
8181
Namespace ns = new Namespace(nsMap);
82-
RateLimiter rateLimiter = RateLimiter.getRateLimiter(ns);
82+
RateLimiter rateLimiter = RateLimiter.getInstance(ns);
8383

8484
if (isnull) {
8585
assertNull(rateLimiter);

0 commit comments

Comments
 (0)