Skip to content

Commit

Permalink
Better work with timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
resetius committed Nov 29, 2023
1 parent c2a71dc commit 1c67226
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 122 deletions.
8 changes: 2 additions & 6 deletions src/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ struct TCommandResponse: public TMessage {

static_assert(sizeof(TCommandResponse) == sizeof(TMessage) + 8);

struct TTimeout: public TMessage {
static constexpr EMessageType MessageType = EMessageType::TIMEOUT;
struct TTimeout {
static constexpr std::chrono::milliseconds Election = std::chrono::milliseconds(5000);
static constexpr std::chrono::milliseconds Heartbeat = std::chrono::milliseconds(2000);
static constexpr std::chrono::milliseconds Rpc = std::chrono::milliseconds(10000);
};

template<typename T>
Expand Down Expand Up @@ -227,7 +227,3 @@ TMessageHolder<T> NewHoldedMessage(TMessageEx h, T t) {
memcpy((char*)m.Mes + sizeof(TMessageEx), (char*)&t + sizeof(TMessageEx), sizeof(T) - sizeof(TMessageEx));
return m;
}

inline TMessageHolder<TTimeout> NewTimeout() {
return NewHoldedMessage<TTimeout>(static_cast<uint32_t>(EMessageType::TIMEOUT), sizeof(TTimeout));
}
Loading

0 comments on commit 1c67226

Please sign in to comment.