Skip to content

Package: Channel

Channel

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2017, 2022 Red Hat Inc and others.
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Red Hat Inc - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.client.gateway.spi;
14:
15: import java.util.Collection;
16: import java.util.Optional;
17: import java.util.concurrent.CompletionStage;
18: import java.util.concurrent.ScheduledExecutorService;
19:
20: import org.eclipse.kapua.client.gateway.ErrorHandler;
21: import org.eclipse.kapua.client.gateway.MessageHandler;
22: import org.eclipse.kapua.client.gateway.Payload;
23: import org.eclipse.kapua.client.gateway.Topic;
24:
25: public interface Channel {
26:
27: public interface Context {
28:
29: public void notifyConnected();
30:
31: public void notifyDisconnected();
32:
33: public ScheduledExecutorService executor();
34: }
35:
36: public void handleInit(Context context);
37:
38: public void handleClose(Context context);
39:
40: public <T> Optional<T> adapt(Class<T> clazz);
41:
42: public CompletionStage<?> handleSubscribe(String applicationId, Topic topic, MessageHandler messageHandler, ErrorHandler<? extends Throwable> errorHandler);
43:
44: public CompletionStage<?> handlePublish(String applicationId, Topic topic, Payload payload);
45:
46: public void handleUnsubscribe(String applicationId, Collection<Topic> topics) throws Exception;
47:
48: }