Support scheduled message IDs in logging.
GitOrigin-RevId: 4641da410f4cc5c683bfdc2dd67de5dea153fc26
This commit is contained in:
parent
917a3af6ac
commit
67e007eebd
@ -63,8 +63,7 @@ MessageType MessageId::get_type() const {
|
||||
}
|
||||
}
|
||||
|
||||
ServerMessageId MessageId::get_server_message_id() const {
|
||||
CHECK(id == 0 || is_server());
|
||||
ServerMessageId MessageId::get_server_message_id_force() const {
|
||||
return ServerMessageId(narrow_cast<int32>(id >> SERVER_ID_SHIFT));
|
||||
}
|
||||
|
||||
@ -84,18 +83,36 @@ MessageId MessageId::get_next_message_id(MessageType type) const {
|
||||
}
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, MessageId message_id) {
|
||||
if (message_id.is_scheduled()) {
|
||||
string_builder << "scheduled ";
|
||||
|
||||
if (!message_id.is_valid_scheduled()) {
|
||||
return string_builder << "invalid message " << message_id.get();
|
||||
}
|
||||
if (message_id.is_scheduled_server()) {
|
||||
return string_builder << "server message " << message_id.get_scheduled_server_message_id_force();
|
||||
}
|
||||
if (message_id.is_local()) {
|
||||
return string_builder << "local message " << message_id.get_scheduled_server_message_id_force();
|
||||
}
|
||||
if (message_id.is_yet_unsent()) {
|
||||
return string_builder << "yet unsent message " << message_id.get_scheduled_server_message_id_force();
|
||||
}
|
||||
return string_builder << "bugged message " << message_id.get();
|
||||
}
|
||||
|
||||
if (!message_id.is_valid()) {
|
||||
return string_builder << "invalid message " << message_id.get();
|
||||
}
|
||||
if (message_id.is_server()) {
|
||||
return string_builder << "server message " << (message_id.get() >> MessageId::SERVER_ID_SHIFT);
|
||||
return string_builder << "server message " << message_id.get_server_message_id_force().get();
|
||||
}
|
||||
if (message_id.is_local()) {
|
||||
return string_builder << "local message " << (message_id.get() >> MessageId::SERVER_ID_SHIFT) << '.'
|
||||
return string_builder << "local message " << message_id.get_server_message_id_force().get() << '.'
|
||||
<< (message_id.get() & MessageId::FULL_TYPE_MASK);
|
||||
}
|
||||
if (message_id.is_yet_unsent()) {
|
||||
return string_builder << "yet unsent message " << (message_id.get() >> MessageId::SERVER_ID_SHIFT) << '.'
|
||||
return string_builder << "yet unsent message " << message_id.get_server_message_id_force().get() << '.'
|
||||
<< (message_id.get() & MessageId::FULL_TYPE_MASK);
|
||||
}
|
||||
return string_builder << "bugged message " << message_id.get();
|
||||
|
@ -40,6 +40,12 @@ class MessageId {
|
||||
// |-------30-------|----18---|1|--2-|
|
||||
// |send_date-2**30 |server_id|1|type|
|
||||
|
||||
ServerMessageId get_server_message_id_force() const;
|
||||
|
||||
int32 get_scheduled_server_message_id_force() const {
|
||||
return static_cast<int32>((id >> 3) & ((1 << 18) - 1));
|
||||
}
|
||||
|
||||
public:
|
||||
MessageId() = default;
|
||||
|
||||
@ -95,7 +101,10 @@ class MessageId {
|
||||
return (id & SHORT_TYPE_MASK) == 0;
|
||||
}
|
||||
|
||||
ServerMessageId get_server_message_id() const;
|
||||
ServerMessageId get_server_message_id() const {
|
||||
CHECK(id == 0 || is_server());
|
||||
return get_server_message_id_force();
|
||||
}
|
||||
|
||||
// returns greatest server message id not bigger than this message id
|
||||
MessageId get_prev_server_message_id() const {
|
||||
@ -111,7 +120,7 @@ class MessageId {
|
||||
|
||||
int32 get_scheduled_server_message_id() const {
|
||||
CHECK(is_scheduled_server());
|
||||
return static_cast<int32>((id >> 3) & ((1 << 18) - 1));
|
||||
return get_scheduled_server_message_id_force();
|
||||
}
|
||||
|
||||
bool operator==(const MessageId &other) const {
|
||||
|
Loading…
Reference in New Issue
Block a user