Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Version represents the last service git tag in git history. // It's meant to be set using go build ldflags: // -ldflags "-X 'github.com/absmach/callhome.Version=0.0.0'". Version = "0.0.0" // Commit represents the service git commit hash. // It's meant to be set using go build ldflags: // -ldflags "-X 'github.com/absmach/callhome.Commit=ffffffff'". Commit = "ffffffff" // BuildTime represetns the service build time. // It's meant to be set using go build ldflags: // -ldflags "-X 'github.com/absmach/callhome.BuildTime=1970-01-01_00:00:00'". BuildTime = "1970-01-01_00:00:00" )
Functions ¶
func Health ¶ added in v0.18.0
func Health(service, instanceID string) http.HandlerFunc
Health exposes an HTTP handler for retrieving service health.
Types ¶
type CountrySummary ¶
type HealthInfo ¶ added in v0.18.0
type HealthInfo struct {
// Status contains service status.
Status string `json:"status"`
// Version contains current service version.
Version string `json:"version"`
// Commit represents the git hash commit.
Commit string `json:"commit"`
// Description contains service description.
Description string `json:"description"`
// BuildTime contains service build time.
BuildTime string `json:"build_time"`
// InstanceID contains the ID of the current service instance
InstanceID string `json:"instance_id"`
}
HealthInfo contains version endpoint response.
type LocationService ¶
type LocationService interface {
// GetLocation returns the location information for a given IP address.
GetLocation(ctx context.Context, ip string) (ip2location.IP2Locationrecord, error)
}
LocationService provides a service for obtaining location information from an IP address.
func NewLocationService ¶
func NewLocationService(dbfilepath string) (LocationService, error)
NewLocationService creates a new LocationService that uses the specified IP2Location database file.
type PageMetadata ¶
type Service ¶
type Service interface {
// Save saves the homing telemetry data and its location information.
Save(ctx context.Context, t Telemetry) error
// Retrieve retrieves homing telemetry data from the specified repository.
Retrieve(ctx context.Context, pm PageMetadata, filters TelemetryFilters) (TelemetryPage, error)
// RetrieveSummary gets distinct countries and ip addresses
RetrieveSummary(ctx context.Context, filters TelemetryFilters) (TelemetrySummary, error)
// ServeUI gets the callhome index html page
ServeUI(ctx context.Context, filters TelemetryFilters) ([]byte, error)
}
Service to receive homing telemetry data, persist and retrieve it.
func New ¶
func New(repo TelemetryRepo, locSvc LocationService) Service
New creates a new instance of the telemetry service.
type Telemetry ¶
type Telemetry struct {
Services pq.StringArray `json:"services,omitempty" db:"services"`
Service string `json:"service,omitempty" db:"service"`
Longitude float64 `json:"longitude,omitempty" db:"longitude"`
Latitude float64 `json:"latitude,omitempty" db:"latitude"`
IpAddress string `json:"-" db:"ip_address"`
MacAddress string `json:"-" db:"mac_address"`
Version string `json:"magistrala_version,omitempty" db:"mg_version"`
LastSeen time.Time `json:"last_seen" db:"service_time"`
Country string `json:"country,omitempty" db:"country"`
City string `json:"city,omitempty" db:"city"`
ServiceTime time.Time `json:"timestamp" db:"time"`
}
type TelemetryFilters ¶
type TelemetryPage ¶
type TelemetryPage struct {
PageMetadata
Telemetry []Telemetry
}
type TelemetryRepo ¶
type TelemetryRepo interface {
// Save persists the telemetry event. A non-nil error is returned to indicate
// operation failure.
Save(ctx context.Context, t Telemetry) error
// RetrieveAll retrieves all telemetry events.
RetrieveAll(ctx context.Context, pm PageMetadata, filters TelemetryFilters) (TelemetryPage, error)
// RetrieveSummary gets distinct countries, cities,services and versions in a summarised form.
RetrieveSummary(ctx context.Context, filters TelemetryFilters) (TelemetrySummary, error)
}
TelemetryRepository specifies an account persistence API.
type TelemetrySummary ¶
type TelemetrySummary struct {
Countries []CountrySummary `json:"countries,omitempty"`
Cities []string `json:"cities,omitempty"`
Services []string `json:"services,omitempty"`
Versions []string `json:"versions,omitempty"`
TotalDeployments int `json:"total_deployments,omitempty"`
}
Directories
¶
| Path | Synopsis |
|---|---|
|
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
|
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations. |
|
pkg
|
|
Click to show internal directories.
Click to hide internal directories.
