001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.client;
019
020import com.google.protobuf.RpcCallback;
021import com.google.protobuf.RpcController;
022import org.apache.yetus.audience.InterfaceAudience;
023
024/**
025 * Delegate to a protobuf rpc call.
026 * <p>
027 * Usually, it is just a simple lambda expression, like:
028 *
029 * <pre>
030 * <code>
031 * (stub, controller, rpcCallback) -> {
032 *   XXXRequest request = ...; // prepare the request
033 *   stub.xxx(controller, request, rpcCallback);
034 * }
035 * </code>
036 * </pre>
037 *
038 * And if already have the {@code request}, the lambda expression will be:
039 *
040 * <pre>
041 * <code>
042 * (stub, controller, rpcCallback) -> stub.xxx(controller, request, rpcCallback)
043 * </code>
044 * </pre>
045 *
046 * @param <S> the type of the protobuf Service you want to call.
047 * @param <R> the type of the return value.
048 */
049@InterfaceAudience.Public
050@FunctionalInterface
051public interface ServiceCaller<S, R> {
052
053  /**
054   * Represent the actual protobuf rpc call.
055   * @param stub        the asynchronous stub
056   * @param controller  the rpc controller, has already been prepared for you
057   * @param rpcCallback the rpc callback, has already been prepared for you
058   */
059  void call(S stub, RpcController controller, RpcCallback<R> rpcCallback);
060}