2021-04-19 13:42:47 +08:00
|
|
|
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
|
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
|
|
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
|
|
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
|
|
|
2021-04-02 10:01:11 +08:00
|
|
|
package mqclient
|
2021-03-26 20:10:11 +08:00
|
|
|
|
|
|
|
import "context"
|
|
|
|
|
2021-09-27 20:32:13 +08:00
|
|
|
// ProducerOptions contains the options of a producer
|
2021-03-26 20:10:11 +08:00
|
|
|
type ProducerOptions struct {
|
2021-09-24 20:48:22 +08:00
|
|
|
// The topic that this Producer will publish
|
2021-03-26 20:10:11 +08:00
|
|
|
Topic string
|
|
|
|
}
|
|
|
|
|
2021-09-27 20:32:13 +08:00
|
|
|
// ProducerMessage contains the messages of a producer
|
2021-03-26 20:10:11 +08:00
|
|
|
type ProducerMessage struct {
|
2021-10-13 11:14:39 +08:00
|
|
|
// Payload get the payload of the message
|
2021-10-13 12:44:33 +08:00
|
|
|
Payload []byte
|
2021-10-13 11:14:39 +08:00
|
|
|
// Properties are application defined key/value pairs that will be attached to the message.
|
|
|
|
// Return the properties attached to the message.
|
2021-03-26 20:10:11 +08:00
|
|
|
Properties map[string]string
|
|
|
|
}
|
|
|
|
|
2021-09-27 20:32:13 +08:00
|
|
|
// Producer is the interface that provides operations of producer
|
2021-03-26 20:10:11 +08:00
|
|
|
type Producer interface {
|
|
|
|
// return the topic which producer is publishing to
|
|
|
|
//Topic() string
|
|
|
|
|
|
|
|
// publish a message
|
2021-09-26 17:38:07 +08:00
|
|
|
Send(ctx context.Context, message *ProducerMessage) (MessageID, error)
|
2021-03-26 20:10:11 +08:00
|
|
|
|
|
|
|
Close()
|
|
|
|
}
|