blob: 8cc19999d928ef7132141dce961ddd5aff22f55e [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 (
khenaidoo79232702018-12-04 11:00:41 -050019 ca "github.com/opencord/voltha-go/protos/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 (
khenaidooca301322019-01-09 23:06:32 -050029 GroupIdKey = "groupId"
30)
31
32const (
khenaidoo4c1a5bf2018-11-29 15:53:42 -050033 DefaultKafkaHost = "127.0.0.1"
34 DefaultKafkaPort = 9092
khenaidooca301322019-01-09 23:06:32 -050035 DefaultGroupName = "voltha"
khenaidoo4c1a5bf2018-11-29 15:53:42 -050036 DefaultSleepOnError = 1
37 DefaultProducerFlushFrequency = 5
38 DefaultProducerFlushMessages = 1
39 DefaultProducerFlushMaxmessages = 5
khenaidoo90847922018-12-03 14:47:51 -050040 DefaultProducerReturnSuccess = true
khenaidoo4c1a5bf2018-11-29 15:53:42 -050041 DefaultProducerReturnErrors = true
42 DefaultProducerRetryMax = 3
43 DefaultProducerRetryBackoff = time.Millisecond * 100
44 DefaultConsumerMaxwait = 10
45 DefaultMaxProcessingTime = 100
46 DefaultConsumerType = PartitionConsumer
47 DefaultNumberPartitions = 3
48 DefaultNumberReplicas = 1
49 DefaultAutoCreateTopic = false
khenaidoo43c82122018-11-22 18:38:28 -050050)
51
52// MsgClient represents the set of APIs a Kafka MsgClient must implement
53type Client interface {
khenaidoo4c1a5bf2018-11-29 15:53:42 -050054 Start() error
khenaidoo43c82122018-11-22 18:38:28 -050055 Stop()
khenaidoo4c1a5bf2018-11-29 15:53:42 -050056 CreateTopic(topic *Topic, numPartition int, repFactor int) error
khenaidoo43c82122018-11-22 18:38:28 -050057 DeleteTopic(topic *Topic) error
khenaidooca301322019-01-09 23:06:32 -050058 Subscribe(topic *Topic, kvArgs ...*KVArg) (<-chan *ca.InterContainerMessage, error)
khenaidoo43c82122018-11-22 18:38:28 -050059 UnSubscribe(topic *Topic, ch <-chan *ca.InterContainerMessage) error
khenaidoo4c1a5bf2018-11-29 15:53:42 -050060 Send(msg interface{}, topic *Topic, keys ...string) error
khenaidoo43c82122018-11-22 18:38:28 -050061}