redis引入未完成
This commit is contained in:
82
redisstream/mq_compat.h
Normal file
82
redisstream/mq_compat.h
Normal file
@@ -0,0 +1,82 @@
|
||||
#ifndef MQ_COMPAT_H
|
||||
#define MQ_COMPAT_H
|
||||
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace mqcompat {
|
||||
|
||||
enum ConsumeStatus {
|
||||
CONSUME_SUCCESS = 0,
|
||||
RECONSUME_LATER = 1
|
||||
};
|
||||
|
||||
class MQMessageExt {
|
||||
public:
|
||||
MQMessageExt()
|
||||
: bornTimestamp_(0),
|
||||
queueId_(0),
|
||||
queueOffset_(0) {
|
||||
}
|
||||
|
||||
MQMessageExt(const std::string& topic,
|
||||
const std::string& tags,
|
||||
const std::string& keys,
|
||||
const std::string& body,
|
||||
int64_t bornTs,
|
||||
const std::string& msgId)
|
||||
: topic_(topic),
|
||||
tags_(tags),
|
||||
keys_(keys),
|
||||
body_(body),
|
||||
bornTimestamp_(bornTs),
|
||||
queueId_(0),
|
||||
queueOffset_(0),
|
||||
msgId_(msgId),
|
||||
streamId_(msgId) {
|
||||
}
|
||||
|
||||
const std::string& getTopic() const { return topic_; }
|
||||
const std::string& getTags() const { return tags_; }
|
||||
const std::string& getKeys() const { return keys_; }
|
||||
const std::string& getBody() const { return body_; }
|
||||
|
||||
int64_t getBornTimestamp() const { return bornTimestamp_; }
|
||||
int getQueueId() const { return queueId_; }
|
||||
int64_t getQueueOffset() const { return queueOffset_; }
|
||||
|
||||
const std::string& getMsgId() const { return msgId_; }
|
||||
const std::string& getStreamId() const { return streamId_; }
|
||||
|
||||
void setTopic(const std::string& v) { topic_ = v; }
|
||||
void setTags(const std::string& v) { tags_ = v; }
|
||||
void setKeys(const std::string& v) { keys_ = v; }
|
||||
void setBody(const std::string& v) { body_ = v; }
|
||||
void setBornTimestamp(int64_t v) { bornTimestamp_ = v; }
|
||||
void setQueueId(int v) { queueId_ = v; }
|
||||
void setQueueOffset(int64_t v) { queueOffset_ = v; }
|
||||
|
||||
void setMsgId(const std::string& v) { msgId_ = v; }
|
||||
|
||||
void setStreamId(const std::string& v) {
|
||||
streamId_ = v;
|
||||
if (msgId_.empty()) {
|
||||
msgId_ = v;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::string topic_;
|
||||
std::string tags_;
|
||||
std::string keys_;
|
||||
std::string body_;
|
||||
int64_t bornTimestamp_;
|
||||
int queueId_;
|
||||
int64_t queueOffset_;
|
||||
std::string msgId_;
|
||||
std::string streamId_;
|
||||
};
|
||||
|
||||
} // namespace mqcompat
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user