Skip to content

Commit

Permalink
refactor: refactor code base
Browse files Browse the repository at this point in the history
  • Loading branch information
Tochemey committed Jan 15, 2024
1 parent 47aa05a commit f86270f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cluster/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,20 +504,26 @@ func (c *Node) listen() {
// dispatch the appropriate event
switch x := event.(type) {
case *events.NodeJoinEvent:
// TODO: need to cross check this calculation
// convert the timestamp to milliseconds
timeMilli := x.Timestamp / int64(1e6)
// create the node joined event
event := &eventspb.NodeJoined{
Address: x.NodeJoin,
Timestamp: timestamppb.New(time.Unix(x.Timestamp, 0)), // TODO: need some work here
Timestamp: timestamppb.New(time.UnixMilli(timeMilli)),
}
// serialize as any pb
eventType, _ := anypb.New(event)
// send the event to the channel
c.eventsChan <- &Event{eventType}
case *events.NodeLeftEvent:
// TODO: need to cross check this calculation
// convert the timestamp to milliseconds
timeMilli := x.Timestamp / int64(1e6)
// create the node joined event
event := &eventspb.NodeLeft{
Address: x.NodeLeft,
Timestamp: timestamppb.New(time.Unix(x.Timestamp, 0)), // TODO: need some work here
Timestamp: timestamppb.New(time.UnixMilli(timeMilli)),
}
// serialize as any pb
eventType, _ := anypb.New(event)
Expand Down

0 comments on commit f86270f

Please sign in to comment.