for _, m := range allMethods { if m.ID == id { method = &Method{} *method = *m } } return method } // ManagedServices is the central list of running services var ManagedServices = Services{ items: make(map[string]*Service, 0), } // services id generator instance var serviceIdGen, _ = shared.NewIDGen("service") // methods id generator instance var methodIdGen, _ = shared.NewIDGen("method") // StopAll stops all services, blocks until everything is shut down. func StopAll() { as := ManagedServices.AllServices() var waiters []func() for _, s := range as { lg.V(10).Infof("stopping service %v", s) if s.Running() { s.Stop() waiters = append(waiters, s.Wait) } }
} // Notification represents a user notifcation event which also can have some // interactivity configured. type Notification struct { ID string `json:"id"` // UUID EventTime time.Time `json:"eventTime"` // A timestamp associated with the notification Level string `json:"level"` // info,success,danger,warning: for styling Priority int `json:"priority"` // Priority ranges from -2 to 2. -2 is lowest priority. 2 is highest. Zero is default. Title string `json:"title"` // header Message string `json:"message"` // body Actions []NotificationAction `json:"actions"` Dismissable bool `json:"dismissable"` // can the user dismiss this } var notificationIDgen, _ = shared.NewIDGen("notify") func prepareNotifications(notifications []Notification) []Notification { for k, v := range notifications { if v.ID == "" { v.ID = notificationIDgen.New() notifications[k] = v } } return notifications } func GetNotifications(w rest.ResponseWriter, r *rest.Request) { if UITEST { GetNotificationsUITest(w, r) return