@Test public void testOverlappingCallerIdButDifferentEndpointBuckets() { TokenBucketAdmissionController controller = new TokenBucketAdmissionController( Arrays.asList(SHARED_GETTERS_CONFIGURATION, SHARED_ANY_CONFIGURATION), titusRuntime ); AdmissionControllerRequest createRequest = AdmissionControllerRequest.newBuilder() .withCallerId("myUser") .withEndpointName("createX") .build(); AdmissionControllerRequest getRequest = AdmissionControllerRequest.newBuilder() .withCallerId("myUser") .withEndpointName("getX") .build(); AdmissionControllerResponse createResponse = controller.apply(createRequest); assertThat(createResponse.getReasonMessage()).contains(SHARED_ANY_CONFIGURATION.getName()); AdmissionControllerResponse getResponse = controller.apply(getRequest); assertThat(getResponse.getReasonMessage()).contains(SHARED_GETTERS_CONFIGURATION.getName()); }
@Override public AdmissionControllerResponse apply(AdmissionControllerRequest request) { return findTokenBucket(request).map(this::consume).orElse(DEFAULT_OK); }
TokenBucketAdmissionController implements AdmissionController { @Override public AdmissionControllerResponse apply(AdmissionControllerRequest request) { return findTokenBucket(request).map(this::consume).orElse(DEFAULT_OK); } }
TokenBucketAdmissionController implements AdmissionController { @Override public AdmissionControllerResponse apply(AdmissionControllerRequest request) { return findTokenBucket(request).map(this::consume).orElse(DEFAULT_OK); } TokenBucketAdmissionController(List<TokenBucketConfiguration> tokenBucketConfigurations,
                                          TitusRuntime titusRuntime); }
TokenBucketAdmissionController implements AdmissionController { @Override public AdmissionControllerResponse apply(AdmissionControllerRequest request) { return findTokenBucket(request).map(this::consume).orElse(DEFAULT_OK); } TokenBucketAdmissionController(List<TokenBucketConfiguration> tokenBucketConfigurations,
                                          TitusRuntime titusRuntime); @Override AdmissionControllerResponse apply(AdmissionControllerRequest request); }
TokenBucketAdmissionController implements AdmissionController { @Override public AdmissionControllerResponse apply(AdmissionControllerRequest request) { return findTokenBucket(request).map(this::consume).orElse(DEFAULT_OK); } TokenBucketAdmissionController(List<TokenBucketConfiguration> tokenBucketConfigurations,
                                          TitusRuntime titusRuntime); @Override AdmissionControllerResponse apply(AdmissionControllerRequest request);  }