feat: build vehicle data platform and production pipeline
This commit is contained in:
19
go/vehicle-gateway/internal/envelope/source.go
Normal file
19
go/vehicle-gateway/internal/envelope/source.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package envelope
|
||||
|
||||
import "strings"
|
||||
|
||||
// NormalizeSourceEndpointKey returns the stable, low-cardinality source key used
|
||||
// by identity lookup and statistics source tracking.
|
||||
func NormalizeSourceEndpointKey(endpoint string) string {
|
||||
endpoint = strings.TrimSpace(endpoint)
|
||||
if endpoint == "" {
|
||||
return ""
|
||||
}
|
||||
if strings.HasPrefix(strings.ToLower(endpoint), "mqtt://") {
|
||||
return "mqtt"
|
||||
}
|
||||
if host, _, ok := strings.Cut(endpoint, ":"); ok {
|
||||
return strings.TrimSpace(host)
|
||||
}
|
||||
return endpoint
|
||||
}
|
||||
Reference in New Issue
Block a user