42558cbf2ea3fc9257e82095e384134af00ca1cd
[dcaegen2/services/sdk.git] /
1 /*
2  * ============LICENSE_START====================================
3  * DCAEGEN2-SERVICES-SDK
4  * =========================================================
5  * Copyright (C) 2019 Nokia. All rights reserved.
6  * =========================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *       http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=====================================
19  */
20 package org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.streams.dmaap;
21
22 import static io.vavr.Predicates.not;
23
24 import io.vavr.collection.List;
25 import org.immutables.value.Value;
26 import org.jetbrains.annotations.Nullable;
27 import org.onap.dcaegen2.services.sdk.rest.services.annotations.ExperimentalApi;
28 import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.streams.AafCredentials;
29
30 /**
31  * @author <a href="mailto:piotr.jaszczyk@nokia.com">Piotr Jaszczyk</a>
32  * @since 1.1.4
33  */
34 @ExperimentalApi
35 public interface Kafka {
36
37     /**
38      * Kafka bootstrap servers as defined in Kafka client documentation under <em>bootstrap.servers</em> configuration
39      * key.
40      */
41     String bootstrapServers();
42
43     /**
44      * The name of the topic where application should publish or subscribe for the messages.
45      */
46     String topicName();
47
48     /**
49      * The credentials to use when authenticating to Kafka cluster or null when connection should be unauthenticated.
50      */
51     @Nullable AafCredentials aafCredentials();
52
53     /**
54      * AAF client role that’s requesting publish or subscribe access to the topic.
55      */
56     @Nullable String clientRole();
57
58     /**
59      * Client id for given AAF client.
60      */
61     @Nullable String clientId();
62
63     /**
64      * The limit on the size of message published to/subscribed from the topic. Can be used to set Kafka client
65      * <em>max.request.size</em> configuration property.
66      */
67     @Value.Default
68     default int maxPayloadSizeBytes() {
69         return 1024 * 1024;
70     }
71
72     /**
73      * The {@code bootstrapServers} converted to the list of servers' addresses.
74      */
75     @Value.Derived
76     default List<String> bootstrapServerList() {
77         return List.of(bootstrapServers().split(",")).filter(not(String::isEmpty));
78     }
79 }