Documentation
¶
Index ¶
- func AddIncident(c context.Context, id string, serviceID string, severity Severity) error
- func CloseIncident(c context.Context, id, serviceID string) error
- func ConvertPlatforms(platforms []*Platform) (convertedPlatforms []*dashpb.Platform)
- func CreateLiveAnnouncement(c context.Context, message, creator string, platforms []*Platform) (*dashpb.Announcement, error)
- func GetAllAnnouncementsPlatforms(c context.Context, announcements []*Announcement) ([]*dashpb.Announcement, error)
- func ListAnnouncements(c context.Context, announcementIDs ...int64) ([]*dashpb.Announcement, error)
- func RetireAnnouncement(c context.Context, announcementID int64, closer string) error
- func SearchAnnouncements(c context.Context, platformName string, retired bool, limit, offset int32) ([]*dashpb.Announcement, error)
- type Announcement
- type IncidentStatus
- type Platform
- type QueryOptions
- type Service
- type ServiceIncident
- type Severity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddIncident ¶
AddIncident writes an incident to datastore.
On success, nil is returned. If no Service with the given serviceID is found or if a ServiceIncident with the same ID is found, err is returned. If there is a datastore error err is returned.
func CloseIncident ¶
CloseIncident updates an existing ServiceIncident by setting a value for the EndTime to the current time.
It returns nil on success. If there is an error getting the Incident or updating the Incident, or the Incident was never found, err will be returned.
func ConvertPlatforms ¶
ConvertPlatforms takes a slice of Platforms and returns equivalent dasphpb.Platforms.
func CreateLiveAnnouncement ¶
func CreateLiveAnnouncement(c context.Context, message, creator string, platforms []*Platform) (*dashpb.Announcement, error)
CreateLiveAnnouncement takes announcement information and Platforms to build an Announcement and adds AnnouncementKeys to all platforms and puts all structs in Datastore.
It returns (announcement, nil) on success, and (nil, err) on datastore errors.
func GetAllAnnouncementsPlatforms ¶
func GetAllAnnouncementsPlatforms(c context.Context, announcements []*Announcement) ([]*dashpb.Announcement, error)
GetAllAnnouncementsPlatforms takes Announcements that have incomplete or empty Platforms, fetches the platforms from datastore, and returns everything in dashpb.Announcements.
It returns (announcements, nil) on success, and (nil, err) on datastore or conversion errors.
func ListAnnouncements ¶
ListAnnouncements returns dashpb.Announcements for all given announcementIDs.
It returns (announcements, nil) on success, and (nil, err) on datastore or conversion errors.
func RetireAnnouncement ¶
RetireAnnouncement sets a given announcement's retired to true.
It returns nil on success and err on datastore errors.
func SearchAnnouncements ¶
func SearchAnnouncements(c context.Context, platformName string, retired bool, limit, offset int32) ([]*dashpb.Announcement, error)
SearchAnnouncements returns dashpb.Announcements. If a platformName is specified, only Announcements that are ancestor to the platform will be returned. If offset or limit are < 0, they will be ignored. The returned Announcements will be either all retired, or all not retired.
It returns (announcements, nil) on success, and (nil, err) on datastore or conversion errors.
Types ¶
type Announcement ¶
type Announcement struct { ID int64 `gae:"$id"` Retired bool StartTime time.Time EndTime time.Time Message string Creator string Closer string PlatformNames []string }
Announcement contains details of an announcement
func (*Announcement) ToProto ¶
func (a *Announcement) ToProto(platforms []*Platform) (*dashpb.Announcement, error)
ToProto takes a slice of Platforms that is assumed to belong to the Announcement a, and returns a dasphpb.Announcement equivalent.
It returns (aProto, nil) on successful conversion or (nil, err) if there was an error while converting timestamps.
type IncidentStatus ¶
type IncidentStatus int
IncidentStatus represents a status category of a ServiceIncident.
const ( // IncidentStatusAny represents a status that is either Open or Closed. IncidentStatusAny IncidentStatus = iota // IncidentStatusOpen represents the status of Open ServiceIncidents. IncidentStatusOpen // IncidentStatusClosed represents the status of Closed ServiceIncidents. IncidentStatusClosed )
type Platform ¶
type Platform struct { AnnouncementKey *datastore.Key `gae:"$parent"` Name string `gae:"$id"` URLPaths []string }
Platform contains information for where and how an ancestor Announcement should be displayed.
type QueryOptions ¶
type QueryOptions struct { After time.Time // if non-zero, a start of time range to fetch Before time.Time // if non-zero, an end of time range to fetch Status IncidentStatus // indicates the status the fetched incidents should have }
QueryOptions contains maps for additional query options that indicate interface{} value the fields should match.
func (*QueryOptions) BuildQuery ¶
func (q *QueryOptions) BuildQuery(query *datastore.Query, timeField string) (*datastore.Query, error)
BuildQuery builds a datastore Query from the values of this QueryOptions. If this QueryOptions has a non-zero After or a non-zero Before and a timeField is not provided, an error will be thrown.
It returns (query, nil) on success or (nil, err) if the timeField is empty while either After or Before is non-zero.
type Service ¶
type Service struct { ID string `gae:"$id"` // eg. "monorail", "som" Name string // eg. "Monorail", "Sheriff-O-Matic" SLA string }
Service contains basic service information and has ServiceIncidents as child entities.
func GetAllServices ¶
GetAllServices gets all Service entities from datastore.
It returns (services, nil) on success or () (nil, err) on datastore errors.
type ServiceIncident ¶
type ServiceIncident struct { ID string `gae:"$id"` ServiceKey *datastore.Key `gae:"$parent"` Open bool StartTime time.Time EndTime time.Time Severity Severity }
ServiceIncident contains incident details and its parent service key.
func GetIncident ¶
GetIncident gets the specified ServiceIncident from datastore.
It returns (incident, nil) on success, (nil, nil) if such incident is not found or (nil, err) on datastore errors
func GetServiceIncidents ¶
func GetServiceIncidents(c context.Context, serviceID string, queryOpts *QueryOptions) ([]ServiceIncident, error)
GetServiceIncidents gets all the incidents of the given service. If onlyOpen is true, this will only return open Incidents. If it is false it will return all Incidents, open and closed.
It returns (incidents, nil) on success or (nil, err) on datastore errors. If no incidents for the service were found, incidents will be empty.