[bisq-network/bisq] Define gRPC api call rate constraints (#5103)
Stan
notifications at github.com
Mon Jan 25 18:15:06 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));
+ }
But we could create an interceptor factory class to factor out some of the repetition.
--
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_r563895393
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20210125/986ee949/attachment.htm>
More information about the bisq-github
mailing list