blob: 46a3967e21e4c84e25e542b6278c9987e1d56fc8 [file] [log] [blame]
Andrea Campanella378e21a2017-06-07 12:09:59 +02001/*
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 */
16package org.onosproject.grpc.api;
17
18import com.google.common.annotations.Beta;
19import io.grpc.ManagedChannel;
20import io.grpc.stub.StreamObserver;
21
22import java.util.Optional;
23
24/**
25 * Implementation to add or remove an observer to the managed channel.
26 *
27 */
28@Beta
29public 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}