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