[bisq-network/bisq] Define gRPC api call rate constraints (#5103)

Stan notifications at github.com
Mon Jan 25 18:45:47 CET 2021


@ghubstan commented on this pull request.



> +        Optional<ServerInterceptor> rateMeteringInterceptor = rateMeteringInterceptor();
+        return rateMeteringInterceptor.map(serverInterceptor ->
+                new ServerInterceptor[]{serverInterceptor}).orElseGet(() -> new ServerInterceptor[0]);
+    }
+
+    final Optional<ServerInterceptor> rateMeteringInterceptor() {
+        CallRateMeteringInterceptor defaultCallRateMeteringInterceptor =
+                new CallRateMeteringInterceptor(new HashMap<>() {{
+                    // You can only register mainnet dispute agents in the UI.
+                    // Do not limit devs' ability to register test agents.
+                    put("registerDisputeAgent", new GrpcCallRateMeter(1, SECONDS));
+                }});
+
+        return getCustomRateMeteringInterceptor(coreApi.getConfig().appDataDir, this.getClass())
+                .or(() -> Optional.of(defaultCallRateMeteringInterceptor));
+    }

Commit c996240 only factors out repeated calls to 'new CallRateMeteringInterceptor'.

I want to leave the `rateMeteringInterceptor` methods there because I expect there will be a need for other types of interceptors in the future, and I want it to be clear that the calling `final ServerInterceptor[] interceptors()` method should get them from a `<type>Interceptor` method.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/5103#discussion_r563918960
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20210125/e204ebd1/attachment.htm>


More information about the bisq-github mailing list