blob: 0d9e3a54dfe0d22543b6d0497e01a0950a0d3cb0 [file] [log] [blame]
khenaidoo43c82122018-11-22 18:38:28 -05001/*
2 * Copyright 2018-present Open Networking Foundation
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 kafka
17
18import (
khenaidoo4c1a5bf2018-11-29 15:53:42 -050019 "time"
Abhilash S.L294ff522019-06-26 18:14:33 +053020
serkant.uluderya2ae470f2020-01-21 11:13:09 -080021 ca "github.com/opencord/voltha-protos/v3/go/inter_container"
khenaidoo43c82122018-11-22 18:38:28 -050022)
23
24const (
khenaidoo4c1a5bf2018-11-29 15:53:42 -050025 PartitionConsumer = iota
26 GroupCustomer = iota
27)
28
29const (
khenaidoo731697e2019-01-29 16:03:29 -050030 OffsetNewest = -1
31 OffsetOldest = -2
32)
33
34const (
khenaidooca301322019-01-09 23:06:32 -050035 GroupIdKey = "groupId"
khenaidoo2c6a0992019-04-29 13:46:56 -040036 Offset = "offset"
khenaidooca301322019-01-09 23:06:32 -050037)
38
39const (
khenaidoo4c1a5bf2018-11-29 15:53:42 -050040 DefaultKafkaHost = "127.0.0.1"
41 DefaultKafkaPort = 9092
Neha Sharmad1387da2020-05-07 20:07:28 +000042 DefaultKafkaAddress = DefaultKafkaHost + ":" + string(DefaultKafkaPort)
khenaidooca301322019-01-09 23:06:32 -050043 DefaultGroupName = "voltha"
khenaidoo4c1a5bf2018-11-29 15:53:42 -050044 DefaultSleepOnError = 1
khenaidoo8f474192019-04-03 17:20:44 -040045 DefaultProducerFlushFrequency = 10
46 DefaultProducerFlushMessages = 10
47 DefaultProducerFlushMaxmessages = 100
khenaidoo90847922018-12-03 14:47:51 -050048 DefaultProducerReturnSuccess = true
khenaidoo4c1a5bf2018-11-29 15:53:42 -050049 DefaultProducerReturnErrors = true
50 DefaultProducerRetryMax = 3
51 DefaultProducerRetryBackoff = time.Millisecond * 100
khenaidoo8f474192019-04-03 17:20:44 -040052 DefaultConsumerMaxwait = 100
khenaidoo4c1a5bf2018-11-29 15:53:42 -050053 DefaultMaxProcessingTime = 100
54 DefaultConsumerType = PartitionConsumer
55 DefaultNumberPartitions = 3
56 DefaultNumberReplicas = 1
57 DefaultAutoCreateTopic = false
Abhilash S.L294ff522019-06-26 18:14:33 +053058 DefaultMetadataMaxRetry = 3
Scott Bakeree6a0872019-10-29 15:59:52 -070059 DefaultLivenessChannelInterval = time.Second * 30
khenaidoo43c82122018-11-22 18:38:28 -050060)
61
62// MsgClient represents the set of APIs a Kafka MsgClient must implement
63type Client interface {
khenaidoo4c1a5bf2018-11-29 15:53:42 -050064 Start() error
khenaidoo43c82122018-11-22 18:38:28 -050065 Stop()
khenaidoo4c1a5bf2018-11-29 15:53:42 -050066 CreateTopic(topic *Topic, numPartition int, repFactor int) error
khenaidoo43c82122018-11-22 18:38:28 -050067 DeleteTopic(topic *Topic) error
khenaidooca301322019-01-09 23:06:32 -050068 Subscribe(topic *Topic, kvArgs ...*KVArg) (<-chan *ca.InterContainerMessage, error)
khenaidoo43c82122018-11-22 18:38:28 -050069 UnSubscribe(topic *Topic, ch <-chan *ca.InterContainerMessage) error
Scott Baker504b4802020-04-17 10:12:20 -070070 SubscribeForMetadata(func(fromTopic string, timestamp time.Time))
khenaidoo4c1a5bf2018-11-29 15:53:42 -050071 Send(msg interface{}, topic *Topic, keys ...string) error
Scott Bakeree6a0872019-10-29 15:59:52 -070072 SendLiveness() error
73 EnableLivenessChannel(enable bool) chan bool
serkant.uluderya2ae470f2020-01-21 11:13:09 -080074 EnableHealthinessChannel(enable bool) chan bool
khenaidoo43c82122018-11-22 18:38:28 -050075}