2021-04-19 05:42:47 +00: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.
|
|
|
|
|
2022-03-03 13:57:56 +00:00
|
|
|
package server
|
2021-01-13 09:26:57 +00:00
|
|
|
|
2021-12-21 13:53:18 +00:00
|
|
|
// ProducerMessage that will be written to rocksdb
|
2021-01-13 09:26:57 +00:00
|
|
|
type ProducerMessage struct {
|
2022-11-25 15:11:12 +00:00
|
|
|
Payload []byte
|
|
|
|
Properties map[string]string
|
2021-01-13 09:26:57 +00:00
|
|
|
}
|
|
|
|
|
2021-09-26 10:29:56 +00:00
|
|
|
// Consumer is rocksmq consumer
|
2021-03-19 11:33:21 +00:00
|
|
|
type Consumer struct {
|
|
|
|
Topic string
|
|
|
|
GroupName string
|
|
|
|
MsgMutex chan struct{}
|
|
|
|
}
|
|
|
|
|
2021-09-23 08:59:54 +00:00
|
|
|
// ConsumerMessage that consumed from rocksdb
|
2021-01-13 09:26:57 +00:00
|
|
|
type ConsumerMessage struct {
|
2022-11-25 15:11:12 +00:00
|
|
|
MsgID UniqueID
|
|
|
|
Payload []byte
|
|
|
|
Properties map[string]string
|
2021-01-13 09:26:57 +00:00
|
|
|
}
|
|
|
|
|
2021-09-26 10:29:56 +00:00
|
|
|
// RocksMQ is an interface thatmay be implemented by the application
|
2021-12-29 09:46:22 +00:00
|
|
|
// to do message queue operations based on rocksdb
|
2021-03-19 11:33:21 +00:00
|
|
|
type RocksMQ interface {
|
|
|
|
CreateTopic(topicName string) error
|
|
|
|
DestroyTopic(topicName string) error
|
|
|
|
CreateConsumerGroup(topicName string, groupName string) error
|
|
|
|
DestroyConsumerGroup(topicName string, groupName string) error
|
2021-09-22 09:21:00 +00:00
|
|
|
Close()
|
2021-01-15 08:06:35 +00:00
|
|
|
|
2021-12-17 15:44:42 +00:00
|
|
|
RegisterConsumer(consumer *Consumer) error
|
2022-03-15 06:45:22 +00:00
|
|
|
GetLatestMsg(topicName string) (int64, error)
|
2023-04-03 08:44:23 +00:00
|
|
|
CheckTopicValid(topicName string) error
|
2021-01-15 08:06:35 +00:00
|
|
|
|
2021-09-26 09:38:07 +00:00
|
|
|
Produce(topicName string, messages []ProducerMessage) ([]UniqueID, error)
|
2021-03-19 11:33:21 +00:00
|
|
|
Consume(topicName string, groupName string, n int) ([]ConsumerMessage, error)
|
|
|
|
Seek(topicName string, groupName string, msgID UniqueID) error
|
2021-09-30 12:51:40 +00:00
|
|
|
SeekToLatest(topicName, groupName string) error
|
2021-12-17 15:44:42 +00:00
|
|
|
ExistConsumerGroup(topicName string, groupName string) (bool, *Consumer, error)
|
2021-05-26 09:31:09 +00:00
|
|
|
|
|
|
|
Notify(topicName, groupName string)
|
2021-01-13 09:26:57 +00:00
|
|
|
}
|