From 7e7a7db6aa21c29e8cc8cd1e4653be7f06794749 Mon Sep 17 00:00:00 2001 From: Justin Brooks Date: Sat, 16 Nov 2024 01:52:38 -0500 Subject: [PATCH] format heartbeat --- pkg/agent/agent.go | 7 ++++--- pkg/payloads/agent_heartbeat_generated.go | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pkg/agent/agent.go b/pkg/agent/agent.go index 8cf1f33..2239bf0 100644 --- a/pkg/agent/agent.go +++ b/pkg/agent/agent.go @@ -187,12 +187,13 @@ func (a *Agent) heartbeatRoutine() { for { select { case <-ticker.C: - log.Printf("Sending heartbeat to proxy") heartbeat := payloads.AgentHeartbeatJson{ - Type: payloads.AgentHeartbeatJsonTypeClientHeartbeat, - Timestamp: []time.Time{time.Now()}[0], + Type: payloads.AgentHeartbeatJsonTypeAgentHeartbeat, + Timestamp: time.Now().Format(time.RFC3339), } + log.Printf("Sending heartbeat to proxy: %+v", heartbeat) + data, err := json.Marshal(heartbeat) if err != nil { log.Printf("Error marshaling heartbeat: %v", err) diff --git a/pkg/payloads/agent_heartbeat_generated.go b/pkg/payloads/agent_heartbeat_generated.go index 8967816..78cb9c5 100644 --- a/pkg/payloads/agent_heartbeat_generated.go +++ b/pkg/payloads/agent_heartbeat_generated.go @@ -5,19 +5,19 @@ package payloads import "encoding/json" import "fmt" import "reflect" -import "time" + type AgentHeartbeatJson struct { // Timestamp of the heartbeat - Timestamp time.Time `json:"timestamp" yaml:"timestamp" mapstructure:"timestamp"` + Timestamp string `json:"timestamp" yaml:"timestamp" mapstructure:"timestamp"` - // Type of payload - must be client.heartbeat + // Type of payload - must be agent.heartbeat Type AgentHeartbeatJsonType `json:"type" yaml:"type" mapstructure:"type"` } type AgentHeartbeatJsonType string -const AgentHeartbeatJsonTypeClientHeartbeat AgentHeartbeatJsonType = "client.heartbeat" +const AgentHeartbeatJsonTypeAgentHeartbeat AgentHeartbeatJsonType = "agent.heartbeat" var enumValues_AgentHeartbeatJsonType = []interface{}{ "agent.heartbeat",