55 "sync"
66 "time"
77
8+ brevapiv2 "buf.build/gen/go/brevdev/devplane/protocolbuffers/go/brevapi/v2"
89 "github.com/brevdev/brev-cli/pkg/brevdaemon/agent/client"
910 agentconfig "github.com/brevdev/brev-cli/pkg/brevdaemon/agent/config"
1011 "github.com/brevdev/brev-cli/pkg/brevdaemon/agent/health"
@@ -15,6 +16,7 @@ import (
1516 "github.com/brevdev/brev-cli/pkg/errors"
1617 "go.uber.org/zap"
1718 "golang.org/x/sync/errgroup"
19+ "google.golang.org/protobuf/types/known/timestamppb"
1820)
1921
2022// Agent is the top-level interface that drives the agent lifecycle.
@@ -37,7 +39,7 @@ type agent struct {
3739 tunnel tunnelProcess
3840
3941 statusReporter * health.Reporter
40- statusUpdates chan client. HeartbeatStatus
42+ statusUpdates chan * brevapiv2. BrevCloudNodeStatus
4143}
4244
4345var (
@@ -72,13 +74,13 @@ func NewAgent(cfg agentconfig.Config, log *zap.Logger) (Agent, error) {
7274 }
7375
7476 statusReporter := health .NewReporter (health.Status {
75- Phase : client . NodePhaseActive ,
77+ Phase : brevapiv2 . BrevCloudNodePhase_BREV_CLOUD_NODE_PHASE_ACTIVE ,
7678 LastTransitionTime : time .Now (),
7779 })
78- defaultStatus := client. HeartbeatStatus {
79- Phase : client . NodePhaseActive ,
80+ defaultStatus := & brevapiv2. BrevCloudNodeStatus {
81+ Phase : brevapiv2 . BrevCloudNodePhase_BREV_CLOUD_NODE_PHASE_ACTIVE ,
8082 }
81- statusUpdates := make (chan client. HeartbeatStatus , 1 )
83+ statusUpdates := make (chan * brevapiv2. BrevCloudNodeStatus , 1 )
8284
8385 hbRunner := & heartbeat.Runner {
8486 Client : cli ,
@@ -88,7 +90,7 @@ func NewAgent(cfg agentconfig.Config, log *zap.Logger) (Agent, error) {
8890 MaxInterval : defaultHeartbeatMaxInterval ,
8991 },
9092 Log : log .Named ("heartbeat" ),
91- DefaultStatus : & defaultStatus ,
93+ DefaultStatus : defaultStatus ,
9294 StatusUpdates : statusUpdates ,
9395 }
9496
@@ -185,14 +187,13 @@ func (a *agent) startStatusBridge(ctx context.Context) func() {
185187 return cancel
186188}
187189
188- func toHeartbeatStatus (status health.Status ) client. HeartbeatStatus {
189- hbStatus := client. HeartbeatStatus {
190+ func toHeartbeatStatus (status health.Status ) * brevapiv2. BrevCloudNodeStatus {
191+ hbStatus := & brevapiv2. BrevCloudNodeStatus {
190192 Phase : status .Phase ,
191193 Detail : status .Detail ,
192194 }
193195 if ! status .LastTransitionTime .IsZero () {
194- t := status .LastTransitionTime
195- hbStatus .LastTransitionTime = & t
196+ hbStatus .LastTransitionTime = timestamppb .New (status .LastTransitionTime )
196197 }
197198 return hbStatus
198199}
0 commit comments