khenaidoo | abad44c | 2018-08-03 16:58:35 -0400 | [diff] [blame] | 1 | package kafka |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | ) |
| 6 | |
| 7 | type callback func(bool, interface{}) |
| 8 | |
| 9 | // A Topic definition - may be augmented with additional attributes eventually |
| 10 | type Topic struct { |
| 11 | // The name of the topic. It must start with a letter, |
| 12 | // and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), |
| 13 | // underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent |
| 14 | // signs (`%`). |
| 15 | Name string |
| 16 | } |
| 17 | |
| 18 | type KVArg struct { |
| 19 | Key string |
| 20 | Value interface{} |
| 21 | } |
| 22 | |
| 23 | // Client represents the set of APIs a Messaging Client must implement - In progress |
| 24 | type Client interface { |
| 25 | Start() |
| 26 | Stop() |
| 27 | Subscribe(ctx context.Context, topic *Topic, cb callback, targetInterfaces ...interface{}) |
| 28 | Publish(ctx context.Context, rpc string, cb callback, topic *Topic, waitForResponse bool, kvArgs ...*KVArg) |
| 29 | Unsubscribe(ctx context.Context, topic *Topic) |
| 30 | } |