-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Publish connecitivity events to a new topic (#227)
- Loading branch information
Showing
32 changed files
with
880 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package transformers | ||
|
||
import ( | ||
"github.com/teslamotors/fleet-telemetry/protos" | ||
) | ||
|
||
// VehicleConnectivityToMap converts a VehicleConnectivity proto message to a map representation | ||
func VehicleConnectivityToMap(vehicleConnectivity *protos.VehicleConnectivity) map[string]interface{} { | ||
return map[string]interface{}{ | ||
"Vin": vehicleConnectivity.GetVin(), | ||
"ConnectionID": vehicleConnectivity.GetConnectionId(), | ||
"Status": vehicleConnectivity.GetStatus().String(), | ||
"CreatedAt": vehicleConnectivity.CreatedAt.AsTime().Unix(), | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
datastore/simple/transformers/vehicle_connectivity_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package transformers_test | ||
|
||
import ( | ||
"time" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/teslamotors/fleet-telemetry/datastore/simple/transformers" | ||
"github.com/teslamotors/fleet-telemetry/protos" | ||
|
||
"google.golang.org/protobuf/types/known/timestamppb" | ||
) | ||
|
||
var _ = Describe("VehicleConnectivity", func() { | ||
Describe("VehicleConnectivityToMap", func() { | ||
var ( | ||
connectivity *protos.VehicleConnectivity | ||
) | ||
|
||
BeforeEach(func() { | ||
connectivity = &protos.VehicleConnectivity{ | ||
Vin: "Vin1", | ||
ConnectionId: "connection1", | ||
CreatedAt: timestamppb.New(time.Now()), | ||
Status: protos.ConnectivityEvent_CONNECTED, | ||
} | ||
}) | ||
|
||
It("includes all expected data", func() { | ||
result := transformers.VehicleConnectivityToMap(connectivity) | ||
Expect(result).To(HaveLen(4)) | ||
Expect(result["Vin"]).To(Equal("Vin1")) | ||
Expect(result["ConnectionID"]).To(Equal("connection1")) | ||
Expect(result["CreatedAt"]).To(BeNumerically("~", time.Now().Unix(), 1)) | ||
Expect(result["Status"]).To(Equal("CONNECTED")) | ||
}) | ||
|
||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,36 @@ | ||
{ | ||
"host": "0.0.0.0", | ||
"port": 443, | ||
"log_level": "info", | ||
"json_log_enable": true, | ||
"namespace": "tesla_telemetry", | ||
"reliable_ack": false, | ||
"monitoring": { | ||
"prometheus_metrics_port": 9090, | ||
"profiler_port": 4269, | ||
"profiling_path": "/tmp/trace.out" | ||
}, | ||
"rate_limit": { | ||
"enabled": true, | ||
"message_interval_time": 30, | ||
"message_limit": 1000 | ||
}, | ||
"records": { | ||
"alerts": [ | ||
"logger" | ||
], | ||
"errors": [ | ||
"logger" | ||
], | ||
"V": [ | ||
"logger" | ||
] | ||
}, | ||
"tls": { | ||
"server_cert": "/etc/certs/server/tls.crt", | ||
"server_key": "/etc/certs/server/tls.key" | ||
} | ||
"host": "0.0.0.0", | ||
"port": 443, | ||
"log_level": "info", | ||
"json_log_enable": true, | ||
"namespace": "tesla_telemetry", | ||
"reliable_ack": false, | ||
"monitoring": { | ||
"prometheus_metrics_port": 9090, | ||
"profiler_port": 4269, | ||
"profiling_path": "/tmp/trace.out" | ||
}, | ||
"rate_limit": { | ||
"enabled": true, | ||
"message_interval_time": 30, | ||
"message_limit": 1000 | ||
}, | ||
"records": { | ||
"alerts": [ | ||
"logger" | ||
], | ||
"errors": [ | ||
"logger" | ||
], | ||
"V": [ | ||
"logger" | ||
], | ||
"connectivity": [ | ||
"logger" | ||
] | ||
}, | ||
"tls": { | ||
"server_cert": "/etc/certs/server/tls.crt", | ||
"server_key": "/etc/certs/server/tls.key" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.