Andrea Campanella | 378e21a | 2017-06-07 12:09:59 +0200 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of 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, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.grpc.api; |
| 17 | |
| 18 | import com.google.common.annotations.Beta; |
| 19 | import io.grpc.ManagedChannel; |
| 20 | import io.grpc.stub.StreamObserver; |
| 21 | |
| 22 | import java.util.Optional; |
| 23 | |
| 24 | /** |
| 25 | * Implementation to add or remove an observer to the managed channel. |
| 26 | * |
| 27 | */ |
| 28 | @Beta |
| 29 | public interface GrpcObserverHandler { |
| 30 | /** |
| 31 | * The implementation of this method adds an |
| 32 | * observer on a stub generated on the specific channel. |
| 33 | * This method will be called by the gRPC controller. |
| 34 | * |
| 35 | * @param channel the channel from which to derive the stub. |
| 36 | */ |
| 37 | void bindObserver(ManagedChannel channel); |
| 38 | |
| 39 | /** |
| 40 | * The implementation of this method returns the request stream |
| 41 | * observer, if any, on a stub generated on the specific channel. |
| 42 | * |
| 43 | * @return the observer on the stub, empty if observer is server-side unidirectional. |
| 44 | */ |
| 45 | Optional<StreamObserver> requestStreamObserver(); |
| 46 | |
| 47 | /** |
| 48 | * The implementation of this method removes an |
| 49 | * observer on a stub generated on the specific channel. |
| 50 | * This method will be called by the gRPC controller. |
| 51 | */ |
| 52 | void removeObserver(); |
| 53 | } |