Skip to content

Commit

Permalink
Removed unnecessary comments and added info logging to TelegramQuery.
Browse files Browse the repository at this point in the history
  • Loading branch information
Agadar committed Nov 20, 2019
1 parent d99470a commit 98f3636
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,24 +121,26 @@ public long estimatedDuration() {

@Override
public <T> T execute(Class<T> type) {
// Validate parameters and build base url.

validateQueryParameters();
String baseUrl = buildURL();

// For each addressee, call makeRequest(...) if it isn't a dry run.
for (int i = 0; i < nations.length && getRateLimiter().lock(); i++) {
// Build final url and wait for the rate limiter to go.

String nation = nations[i];
String url = baseUrl + nation.replace(' ', '_');
Exception exception = null;

try {
makeRequest(url, input -> null);
log.info("Queued a telegram to nation '{}'", nation);

} catch (Exception ex) {
log.error("An error occured while sending a telegram", ex);
String message = String.format("An error occured while queueing a telegram to nation '%s'", nation);
log.error(message, ex);
exception = ex;

} finally {
// Always unlock the rate limiter to prevent deadlock.
getRateLimiter().unlock();
}

Expand Down Expand Up @@ -182,8 +184,7 @@ protected void validateQueryParameters() {
@Override
protected String buildURL() {
String url = super.buildURL();
url += String.format("&client=%s&tgid=%s&key=%s&to=", clientKey, telegramId, secretKey); // Append telegram
// fields.
url += String.format("&client=%s&tgid=%s&key=%s&to=", clientKey, telegramId, secretKey);
return url;
}

Expand Down

0 comments on commit 98f3636

Please sign in to comment.