Documentation ¶
Index ¶
- func Transact(pg *Postgres, txFunc func(*DBTrans) error) error
- type DBTrans
- type Postgres
- func (db *Postgres) DeleteDisconnectedServices(thresholdSeconds int32) ([]*storage.Service, error)
- func (db *Postgres) DeleteServicesByID(svcIDs []string) ([]*storage.Service, error)
- func (db *Postgres) DestructiveMigrateForTests() error
- func (db *Postgres) EmptyStorage() error
- func (db *Postgres) GetDeploymentsCount() (int32, error)
- func (db *Postgres) GetDisconnectedServices(thresholdSeconds int32) ([]*storage.Service, error)
- func (db *Postgres) GetServiceFromUniqueFields(name, member string) (*storage.Service, bool)
- func (db *Postgres) GetServiceGroups(sortField string, sortAsc bool, page int32, pageSize int32, ...) ([]*storage.ServiceGroupDisplay, error)
- func (db *Postgres) GetServiceGroupsCount() (int32, error)
- func (db *Postgres) GetServiceGroupsHealthCounts(filters map[string][]string) (*storage.HealthCounts, error)
- func (db *Postgres) GetServices(sortField string, sortAsc bool, page int32, pageSize int32, ...) ([]*storage.Service, error)
- func (db *Postgres) GetServicesCount() (int32, error)
- func (db *Postgres) GetServicesDistinctValues(fieldName, queryFragment string, filters map[string][]string) ([]string, error)
- func (db *Postgres) GetServicesHealthCounts(filters map[string][]string) (*storage.HealthCounts, error)
- func (db *Postgres) GetSupervisorsCount() (int32, error)
- func (db *Postgres) GetTelemetry(ctx context.Context) (storage.Telemetry, error)
- func (db *Postgres) GetUniqueServicesFromPostgres(daysSinceLastPost int64, lastTelemetryReportedAt time.Time) (int64, error)
- func (db *Postgres) IngestHealthCheckEvent(event *habitat.HealthCheckEvent) error
- func (db *Postgres) IngestHealthCheckEventWithoutMetrics(event *habitat.HealthCheckEvent) error
- func (db *Postgres) MarkDisconnectedServices(thresholdSeconds int32) ([]*storage.Service, error)
- func (db *Postgres) ServiceGroupExists(id string) (string, bool)
- func (pg *Postgres) UpdateTelemetryReported(ctx context.Context, lastTelemetryReportedTime string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DBTrans ¶
type DBTrans struct {
*gorp.Transaction
}
type Postgres ¶
Postgres is a wrapping struct that will hold the database mapping object from the underlying db/sql implementation (gorp) plus our service config specifically for storage.
Additionally this struct implements our storage.Client interface
func ConnectAndMigrate ¶
New creates a new Postgres client, connects to the database server and runs the migrations
func (*Postgres) DeleteDisconnectedServices ¶
DeleteDisconnectedServices deletes any service records where the time elapsed since the last event is greater than the specified thresholdMinutes. After deleting the services, it also removes all supervisor, service_group, and deployment records that are not referenced by any service record because the application treats these things as emergent properties of groups of services so they shouldn't exist if there are no associated services. This also prevents the need for a second cleanup operation to delete these things.
func (*Postgres) DeleteServicesByID ¶
func (*Postgres) DestructiveMigrateForTests ¶
func (*Postgres) EmptyStorage ¶
EmptyStorage deletes all the data from the database @afiune This function is only used by our Integration Test framework
func (*Postgres) GetDeploymentsCount ¶
func (*Postgres) GetDisconnectedServices ¶
GetDisconnectedServices returns a list of disconnected services
func (*Postgres) GetServiceFromUniqueFields ¶
GetServiceFromUniqueFields retrieves a service from the db without the need of an id, it is based on the unique fields, name and member id
func (*Postgres) GetServiceGroups ¶
func (*Postgres) GetServiceGroupsCount ¶
func (*Postgres) GetServiceGroupsHealthCounts ¶
func (db *Postgres) GetServiceGroupsHealthCounts(filters map[string][]string) (*storage.HealthCounts, error)
GetServiceGroupsHealthCounts retrieves the health counts from all service groups in the database
func (*Postgres) GetServices ¶
func (db *Postgres) GetServices( sortField string, sortAsc bool, page int32, pageSize int32, filters map[string][]string, ) ([]*storage.Service, error)
GetServices returns a list of services
func (*Postgres) GetServicesCount ¶
func (*Postgres) GetServicesDistinctValues ¶
func (*Postgres) GetServicesHealthCounts ¶
func (db *Postgres) GetServicesHealthCounts(filters map[string][]string) (*storage.HealthCounts, error)
GetServicesHealthCounts retrieves the health counts from all services in the database. This function accepts a set of filters that can be applied to the SQL query to get the health counts of a subset of the services in the database
func (*Postgres) GetSupervisorsCount ¶
func (*Postgres) GetTelemetry ¶
Get last services telemetry reported timestamp
func (*Postgres) GetUniqueServicesFromPostgres ¶
func (db *Postgres) GetUniqueServicesFromPostgres(daysSinceLastPost int64, lastTelemetryReportedAt time.Time) (int64, error)
Get last 15 days services telemetry reported timestamp
func (*Postgres) IngestHealthCheckEvent ¶
func (db *Postgres) IngestHealthCheckEvent(event *habitat.HealthCheckEvent) error
process a habitat HealthCheck event and store it into the database
func (*Postgres) IngestHealthCheckEventWithoutMetrics ¶
func (db *Postgres) IngestHealthCheckEventWithoutMetrics(event *habitat.HealthCheckEvent) error
same as IngestHealthCheckEvent but without metrics
func (*Postgres) MarkDisconnectedServices ¶
func (*Postgres) ServiceGroupExists ¶
ServiceGroupExists returns the name of the service group if it exists