khenaidoo | bf6e7bb | 2018-08-14 22:27:29 -0400 | [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 | */ |
khenaidoo | abad44c | 2018-08-03 16:58:35 -0400 | [diff] [blame] | 16 | package kafka |
| 17 | |
| 18 | import ( |
| 19 | "context" |
| 20 | ) |
| 21 | |
| 22 | type callback func(bool, interface{}) |
| 23 | |
| 24 | // A Topic definition - may be augmented with additional attributes eventually |
| 25 | type Topic struct { |
| 26 | // The name of the topic. It must start with a letter, |
| 27 | // and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), |
| 28 | // underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent |
| 29 | // signs (`%`). |
| 30 | Name string |
| 31 | } |
| 32 | |
| 33 | type KVArg struct { |
| 34 | Key string |
| 35 | Value interface{} |
| 36 | } |
| 37 | |
| 38 | // Client represents the set of APIs a Messaging Client must implement - In progress |
| 39 | type Client interface { |
| 40 | Start() |
| 41 | Stop() |
| 42 | Subscribe(ctx context.Context, topic *Topic, cb callback, targetInterfaces ...interface{}) |
| 43 | Publish(ctx context.Context, rpc string, cb callback, topic *Topic, waitForResponse bool, kvArgs ...*KVArg) |
| 44 | Unsubscribe(ctx context.Context, topic *Topic) |
| 45 | } |