Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/v1/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ tonic::include_proto!("greptime.v1.meta");
mod mailbox;

use std::collections::HashMap;
use std::fmt::{Display, Formatter};
use std::hash::{Hash, Hasher};

pub const PROTOCOL_VERSION: u64 = 1;
Expand Down Expand Up @@ -57,6 +58,27 @@ impl Hash for Peer {

impl Eq for Peer {}

impl Display for Peer {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "peer-{}({})", self.id, self.addr)
}
}

impl Peer {
pub fn new(id: u64, addr: impl Into<String>) -> Self {
Self {
id,
addr: addr.into(),
}
}
pub fn empty(id: u64) -> Self {
Self {
id,
addr: String::new(),
}
}
}

impl RequestHeader {
#[inline]
pub fn new(member_id: u64, role: Role, tracing_context: HashMap<String, String>) -> Self {
Expand Down