Skip to content

Commit

Permalink
refine naming; impl display
Browse files Browse the repository at this point in the history
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
  • Loading branch information
MyonKeminta committed Oct 9, 2018
1 parent 0957b2b commit e160a0c
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/raftstore/coprocessor/region_collection.rs
Expand Up @@ -42,7 +42,7 @@ const CHANNEL_BUFFER_SIZE: usize = usize::MAX; // Unbounded
/// `RaftStoreEvent` Represents events dispatched from raftstore coprocessor.
#[derive(Debug)]
enum RaftStoreEvent {
NewRegion { region: Region },
CreateRegion { region: Region },
UpdateRegion { region: Region },
DestroyRegion { region: Region },
RoleChange { region: Region, role: StateRole },
Expand All @@ -56,6 +56,7 @@ impl Display for RaftStoreEvent {

/// `RegionCollection` has its own thread (namely RegionCollectionWorker). Queries and updates are
/// done by sending commands to the thread.
#[derive(Debug)]
enum RegionCollectionMsg {
RaftStoreEvent(RaftStoreEvent),
SeekRegion {
Expand All @@ -66,9 +67,21 @@ enum RegionCollectionMsg {
},
}

// So we can derive `Debug` on `RegionCollectionMsg`
impl Debug for SeekRegionFilter {
fn fmt(&self, f: &mut Formatter) -> FmtResult {
write!(f, "<filter>")
}
}
impl Debug for SeekRegionCallback {
fn fmt(&self, f: &mut Formatter) -> FmtResult {
write!(f, "<callback>")
}
}

impl Display for RegionCollectionMsg {
fn fmt(&self, f: &mut Formatter) -> FmtResult {
write!(f, "RegionCollectionMsg(fmt unimplemented)")
Debug::fmt(self, f)
}
}

Expand All @@ -85,7 +98,7 @@ impl RegionChangeObserver for EventSender {
fn on_region_changed(&self, context: &mut ObserverContext, event: RegionChangeEvent) {
let region = context.region().clone();
let event = match event {
RegionChangeEvent::Create => RaftStoreEvent::NewRegion { region },
RegionChangeEvent::Create => RaftStoreEvent::CreateRegion { region },
RegionChangeEvent::Update => RaftStoreEvent::UpdateRegion { region },
RegionChangeEvent::Destroy => RaftStoreEvent::DestroyRegion { region },
};
Expand Down Expand Up @@ -270,7 +283,7 @@ impl RegionCollectionWorker {

fn handle_raftstore_event(&mut self, event: RaftStoreEvent) {
match event {
RaftStoreEvent::NewRegion { region } => {
RaftStoreEvent::CreateRegion { region } => {
self.handle_create_region(region);
}
RaftStoreEvent::UpdateRegion { region } => {
Expand Down

0 comments on commit e160a0c

Please sign in to comment.