blob: a4c49ca67d0e709963769a40e881cd8707be371c [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 (
William Kurkiandaa6bb22019-03-07 12:26:28 -050019 ca "github.com/opencord/voltha-protos/go/inter_container"
khenaidoo4c1a5bf2018-11-29 15:53:42 -050020 "time"
khenaidoo43c82122018-11-22 18:38:28 -050021)
22
23const (
khenaidoo4c1a5bf2018-11-29 15:53:42 -050024 PartitionConsumer = iota
25 GroupCustomer = iota
26)
27
28const (
khenaidoo731697e2019-01-29 16:03:29 -050029 OffsetNewest = -1
30 OffsetOldest = -2
31)
32
33const (
khenaidooca301322019-01-09 23:06:32 -050034 GroupIdKey = "groupId"
khenaidoo731697e2019-01-29 16:03:29 -050035 Offset = "offset"
khenaidooca301322019-01-09 23:06:32 -050036)
37
38const (
khenaidoo4c1a5bf2018-11-29 15:53:42 -050039 DefaultKafkaHost = "127.0.0.1"
40 DefaultKafkaPort = 9092
khenaidooca301322019-01-09 23:06:32 -050041 DefaultGroupName = "voltha"
khenaidoo4c1a5bf2018-11-29 15:53:42 -050042 DefaultSleepOnError = 1
khenaidoo8f474192019-04-03 17:20:44 -040043 DefaultProducerFlushFrequency = 10
44 DefaultProducerFlushMessages = 10
45 DefaultProducerFlushMaxmessages = 100
khenaidoo90847922018-12-03 14:47:51 -050046 DefaultProducerReturnSuccess = true
khenaidoo4c1a5bf2018-11-29 15:53:42 -050047 DefaultProducerReturnErrors = true
48 DefaultProducerRetryMax = 3
49 DefaultProducerRetryBackoff = time.Millisecond * 100
khenaidoo8f474192019-04-03 17:20:44 -040050 DefaultConsumerMaxwait = 100
khenaidoo4c1a5bf2018-11-29 15:53:42 -050051 DefaultMaxProcessingTime = 100
52 DefaultConsumerType = PartitionConsumer
53 DefaultNumberPartitions = 3
54 DefaultNumberReplicas = 1
55 DefaultAutoCreateTopic = false
khenaidoo43c82122018-11-22 18:38:28 -050056)
57
58// MsgClient represents the set of APIs a Kafka MsgClient must implement
59type Client interface {
khenaidoo4c1a5bf2018-11-29 15:53:42 -050060 Start() error
khenaidoo43c82122018-11-22 18:38:28 -050061 Stop()
khenaidoo4c1a5bf2018-11-29 15:53:42 -050062 CreateTopic(topic *Topic, numPartition int, repFactor int) error
khenaidoo43c82122018-11-22 18:38:28 -050063 DeleteTopic(topic *Topic) error
khenaidooca301322019-01-09 23:06:32 -050064 Subscribe(topic *Topic, kvArgs ...*KVArg) (<-chan *ca.InterContainerMessage, error)
khenaidoo43c82122018-11-22 18:38:28 -050065 UnSubscribe(topic *Topic, ch <-chan *ca.InterContainerMessage) error
khenaidoo4c1a5bf2018-11-29 15:53:42 -050066 Send(msg interface{}, topic *Topic, keys ...string) error
khenaidoo43c82122018-11-22 18:38:28 -050067}