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 org.apache.yetus.audience.InterfaceAudience;
021
022import org.apache.hbase.thirdparty.com.google.protobuf.RpcCallback;
023import org.apache.hbase.thirdparty.com.google.protobuf.RpcController;
024
025/**
026 * Delegate to a protobuf rpc call.
027 * <p>
028 * Usually, it is just a simple lambda expression, like:
029 *
030 * <pre>
031 * (stub, controller, rpcCallback) -&gt; {
032 *   XXXRequest request = ...; // prepare the request
033 *   stub.xxx(controller, request, rpcCallback);
034 * }
035 * </pre>
036 *
037 * And if already have the {@code request}, the lambda expression will be:
038 *
039 * <pre>
040 * (stub, controller, rpcCallback) -&gt; stub.xxx(controller, request, rpcCallback)
041 * </pre>
042 *
043 * @param <S> the type of the protobuf Service you want to call.
044 * @param <R> the type of the return value.
045 */
046@InterfaceAudience.Public
047@FunctionalInterface
048public interface ServiceCaller<S, R> {
049
050  /**
051   * Represent the actual protobuf rpc call.
052   * @param stub        the asynchronous stub
053   * @param controller  the rpc controller, has already been prepared for you
054   * @param rpcCallback the rpc callback, has already been prepared for you
055   */
056  void call(S stub, RpcController controller, RpcCallback<R> rpcCallback);
057}