Skip to content
Open
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
24 changes: 2 additions & 22 deletions crates/corro-types/src/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,35 +199,15 @@ impl From<SocketAddr> for Actor {
}
}

pub struct ActorAddr {
id: ActorId,
addr: SocketAddr,
}

impl PartialEq for ActorAddr {
fn eq(&self, other: &Self) -> bool {
// this happens if we're announcing ourselves to another node
// we don't yet have any info about them, except their gossip addr
if self.id.is_nil() || other.id.is_nil() {
self.addr.eq(&other.addr)
} else {
self.id.eq(&other.id)
}
}
}

impl Identity for Actor {
type Addr = ActorAddr;
type Addr = SocketAddr;

// Since a client outside the cluster will not be aware of our
// `bump` field, we implement the optional trait method
// `has_same_prefix` to allow anyone that knows our `addr`
// to join our cluster.
fn addr(&self) -> Self::Addr {
ActorAddr {
id: self.id,
addr: self.addr,
}
self.addr
}

// And by implementing `renew` we enable automatic rejoining:
Expand Down
Loading