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