blob: 20784b54eed73b0564b5b000e22c3484f7762b3b [file] [log] [blame]
khenaidoobf6e7bb2018-08-14 22:27:29 -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 */
khenaidooabad44c2018-08-03 16:58:35 -040016package kafka
17
18import (
19 "context"
20)
21
22type callback func(bool, interface{})
23
24// A Topic definition - may be augmented with additional attributes eventually
25type 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
33type KVArg struct {
34 Key string
35 Value interface{}
36}
37
38// Client represents the set of APIs a Messaging Client must implement - In progress
39type 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}