wu-sheng commented on code in PR #12953:
URL: https://github.com/apache/skywalking/pull/12953#discussion_r1910380098


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/watermark/WatermarkGRPCInterceptor.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.watermark;
+
+import io.grpc.ForwardingServerCallListener;
+import io.grpc.Metadata;
+import io.grpc.ServerCall;
+import io.grpc.ServerCallHandler;
+import io.grpc.ServerInterceptor;
+import io.grpc.Status;
+
+/**
+ * gRPCWatermarkInterceptor is a gRPC interceptor that checks if the watermark 
is exceeded before processing the request.
+ */
+public class WatermarkGRPCInterceptor extends WatermarkListener implements 
ServerInterceptor {
+    public static WatermarkGRPCInterceptor INSTANCE;
+
+    private WatermarkGRPCInterceptor() {
+        super("gRPC-Watermark-Interceptor");
+    }
+
+    public static WatermarkGRPCInterceptor create() {
+        INSTANCE = new WatermarkGRPCInterceptor();
+        return INSTANCE;
+    }
+
+    @Override
+    public <REQ, RESP> ServerCall.Listener<REQ> interceptCall(final 
ServerCall<REQ, RESP> call,
+                                                              final Metadata 
headers,
+                                                              final 
ServerCallHandler<REQ, RESP> next) {
+        if (isWatermarkExceeded()) {
+            call.close(Status.RESOURCE_EXHAUSTED.withDescription("Watermark 
exceeded"), new Metadata());
+            return new ServerCall.Listener<REQ>() {
+            };
+        }

Review Comment:
   Added periodical output. One output per minute.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to