From f86270f676ed6337cba1dc924d3cb7725110a524 Mon Sep 17 00:00:00 2001 From: Tochemey Date: Mon, 15 Jan 2024 21:59:20 +0000 Subject: [PATCH] refactor: refactor code base --- cluster/node.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cluster/node.go b/cluster/node.go index 47dbe4bc..b56850e6 100644 --- a/cluster/node.go +++ b/cluster/node.go @@ -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)