1 /* 2 * Copyright (C) 2017 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * the License. 15 */ 16 17 package com.google.android.mobly.snippet.rpc; 18 19 import java.lang.annotation.Documented; 20 import java.lang.annotation.ElementType; 21 import java.lang.annotation.Retention; 22 import java.lang.annotation.RetentionPolicy; 23 import java.lang.annotation.Target; 24 25 /** 26 * The {@link AsyncRpc} annotation is used to annotate server-side implementations of RPCs that 27 * trigger asynchronous events. This behaves generally the same as {@link Rpc}, but methods that are 28 * annotated with {@link AsyncRpc} are expected to take the extra parameter which is the ID to use 29 * when posting async events. 30 * 31 * <p>Sample Usage: 32 * 33 * <pre>{@code 34 * {@literal @}AsyncRpc(description = "An example showing the usage of AsyncRpc") 35 * public void doSomethingAsync(String callbackId, ...) { 36 * // start some async operation and post a Snippet Event object with the given callbackId. 37 * } 38 * }</pre> 39 * 40 * AsyncRpc methods can still return serializable values, which will be transported in the regular 41 * return value field of the Rpc protocol. 42 */ 43 @Retention(RetentionPolicy.RUNTIME) 44 @Target(ElementType.METHOD) 45 @Documented 46 public @interface AsyncRpc { 47 /** Returns brief description of the function. Should be limited to one or two sentences. */ description()48 String description(); 49 } 50