LCOV - code coverage report
Current view: top level - server/cancellation - RequestStateProvider.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 4 4 100.0 %
Date: 2022-11-19 15:00:39 Functions: 1 1 100.0 %

          Line data    Source code
       1             : // Copyright (C) 2021 The Android Open Source Project
       2             : //
       3             : // Licensed under the Apache License, Version 2.0 (the "License");
       4             : // you may not use this file except in compliance with the License.
       5             : // You may obtain a copy of the License at
       6             : //
       7             : // http://www.apache.org/licenses/LICENSE-2.0
       8             : //
       9             : // Unless required by applicable law or agreed to in writing, software
      10             : // distributed under the License is distributed on an "AS IS" BASIS,
      11             : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12             : // See the License for the specific language governing permissions and
      13             : // limitations under the License.
      14             : 
      15             : package com.google.gerrit.server.cancellation;
      16             : 
      17             : import com.google.gerrit.common.Nullable;
      18             : 
      19             : /** Interface that provides information about the state of the current request. */
      20             : public interface RequestStateProvider {
      21             :   /**
      22             :    * Checks whether the current request is cancelled.
      23             :    *
      24             :    * <p>Invoked by Gerrit to check whether the current request is cancelled and should be aborted.
      25             :    *
      26             :    * <p>If the current request is cancelled {@link OnCancelled#onCancel(Reason, String)} is invoked
      27             :    * on the provided callback.
      28             :    *
      29             :    * @param onCancelled callback that should be invoked if the request is cancelled
      30             :    */
      31             :   void checkIfCancelled(OnCancelled onCancelled);
      32             : 
      33             :   /** Callback interface to be invoked if a request is cancelled. */
      34             :   @FunctionalInterface
      35             :   interface OnCancelled {
      36             :     /**
      37             :      * Callback that is invoked if the request is cancelled.
      38             :      *
      39             :      * @param reason the reason for the cancellation of the request
      40             :      * @param message an optional message providing details about the cancellation
      41             :      */
      42             :     void onCancel(Reason reason, @Nullable String message);
      43             :   }
      44             : 
      45             :   /** Reason why a request is cancelled. */
      46         105 :   enum Reason {
      47             :     /** The client got disconnected or has cancelled the request. */
      48         105 :     CLIENT_CLOSED_REQUEST,
      49             : 
      50             :     /** The deadline that the client provided for the request exceeded. */
      51         105 :     CLIENT_PROVIDED_DEADLINE_EXCEEDED,
      52             : 
      53             :     /**
      54             :      * A server-side deadline for the request exceeded.
      55             :      *
      56             :      * <p>Server-side deadlines are usually configurable, but may also be hard-coded.
      57             :      */
      58         105 :     SERVER_DEADLINE_EXCEEDED;
      59             :   }
      60             : }

Generated by: LCOV version 1.16+git.20220603.dfeb750