Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CountrySummary ¶
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 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"` 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.