blob: a4c49ca67d0e709963769a40e881cd8707be371c [file] [log] [blame]
William Kurkianea869482019-04-09 15:16:11 -04001/*
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 (
19 ca "github.com/opencord/voltha-protos/go/inter_container"
20 "time"
21)
22
23const (
24 PartitionConsumer = iota
25 GroupCustomer = iota
26)
27
28const (
29 OffsetNewest = -1
30 OffsetOldest = -2
31)
32
33const (
34 GroupIdKey = "groupId"
35 Offset = "offset"
36)
37
38const (
39 DefaultKafkaHost = "127.0.0.1"
40 DefaultKafkaPort = 9092
41 DefaultGroupName = "voltha"
42 DefaultSleepOnError = 1
43 DefaultProducerFlushFrequency = 10
44 DefaultProducerFlushMessages = 10
45 DefaultProducerFlushMaxmessages = 100
46 DefaultProducerReturnSuccess = true
47 DefaultProducerReturnErrors = true
48 DefaultProducerRetryMax = 3
49 DefaultProducerRetryBackoff = time.Millisecond * 100
50 DefaultConsumerMaxwait = 100
51 DefaultMaxProcessingTime = 100
52 DefaultConsumerType = PartitionConsumer
53 DefaultNumberPartitions = 3
54 DefaultNumberReplicas = 1
55 DefaultAutoCreateTopic = false
56)
57
58// MsgClient represents the set of APIs a Kafka MsgClient must implement
59type Client interface {
60 Start() error
61 Stop()
62 CreateTopic(topic *Topic, numPartition int, repFactor int) error
63 DeleteTopic(topic *Topic) error
64 Subscribe(topic *Topic, kvArgs ...*KVArg) (<-chan *ca.InterContainerMessage, error)
65 UnSubscribe(topic *Topic, ch <-chan *ca.InterContainerMessage) error
66 Send(msg interface{}, topic *Topic, keys ...string) error
67}