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

Stan notifications at github.com
Mon Jan 25 18:11:36 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));
+    }

Not sure how to fully answer this, but we cannot create a super class for these Grpc*Service classes, if that's what you are suggesting.  A Grpc service class must extend a class generated from a proto def.

Something else you might not realize... but ought to know:  a unique interceptor is bound to each Grpc*Service, and each interceptor has it's own unique set up rate meters.

-- 
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_r563892496
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20210125/36c872f2/attachment.htm>


More information about the bisq-github mailing list