Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1048 from zalando/INC-44977-hacky-throttle
Browse files Browse the repository at this point in the history
INC-44977: reverted changes;
  • Loading branch information
Vyacheslav Stepanov authored May 8, 2019
2 parents a420d10 + a275d3f commit 621f8a8
Showing 1 changed file with 0 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;

Expand All @@ -56,7 +55,6 @@
import static org.zalando.problem.Status.INTERNAL_SERVER_ERROR;
import static org.zalando.problem.Status.NOT_FOUND;
import static org.zalando.problem.Status.SERVICE_UNAVAILABLE;
import static org.zalando.problem.Status.TOO_MANY_REQUESTS;
import static org.zalando.problem.Status.UNPROCESSABLE_ENTITY;

@RestController
Expand All @@ -72,7 +70,6 @@ public class SubscriptionStreamController {
private final MetricRegistry metricRegistry;
private final SubscriptionDbRepository subscriptionDbRepository;
private final SubscriptionValidationService subscriptionValidationService;
private final Random random;

@Autowired
public SubscriptionStreamController(final SubscriptionStreamerFactory subscriptionStreamerFactory,
Expand All @@ -91,7 +88,6 @@ public SubscriptionStreamController(final SubscriptionStreamerFactory subscripti
this.metricRegistry = metricRegistry;
this.subscriptionDbRepository = subscriptionDbRepository;
this.subscriptionValidationService = subscriptionValidationService;
this.random = new Random();
}

class SubscriptionOutputImpl implements SubscriptionOutput {
Expand Down Expand Up @@ -216,12 +212,6 @@ private StreamingResponseBody stream(final String subscriptionId,
SubscriptionStreamer streamer = null;
final SubscriptionOutputImpl output = new SubscriptionOutputImpl(response, outputStream);
try {
if ("stups_zalos".equals(client.getClientId()) && random.nextInt(10) >= 5) {
writeProblemResponse(response, outputStream,
Problem.valueOf(TOO_MANY_REQUESTS, "Application stups_zalos is throttled"));
return;
}

if (blacklistService.isSubscriptionConsumptionBlocked(subscriptionId, client.getClientId())) {
writeProblemResponse(response, outputStream,
Problem.valueOf(FORBIDDEN, "Application or event type is blocked"));
Expand Down

0 comments on commit 621f8a8

Please sign in to comment.