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; 022 023import org.apache.yetus.audience.InterfaceAudience; 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 * <code> 032 * (stub, controller, rpcCallback) -> { 033 * XXXRequest request = ...; // prepare the request 034 * stub.xxx(controller, request, rpcCallback); 035 * } 036 * </code> 037 * </pre> 038 * 039 * And if already have the {@code request}, the lambda expression will be: 040 * 041 * <pre> 042 * <code> 043 * (stub, controller, rpcCallback) -> stub.xxx(controller, request, rpcCallback) 044 * </code> 045 * </pre> 046 * 047 * @param <S> the type of the protobuf Service you want to call. 048 * @param <R> the type of the return value. 049 */ 050@InterfaceAudience.Public 051@FunctionalInterface 052public interface ServiceCaller<S, R> { 053 054 /** 055 * Represent the actual protobuf rpc call. 056 * @param stub the asynchronous stub 057 * @param controller the rpc controller, has already been prepared for you 058 * @param rpcCallback the rpc callback, has already been prepared for you 059 */ 060 void call(S stub, RpcController controller, RpcCallback<R> rpcCallback); 061}