gopkg.in/dedis/onet.v2@v2.0.0-20181115163211-c8f3724038a7/status.go (about) 1 package onet 2 3 // Status holds key/value pairs of the status to be returned to the requester. 4 type Status struct { 5 Field map[string]string 6 } 7 8 // StatusReporter is the interface that all structures that want to return a status will implement. 9 type StatusReporter interface { 10 GetStatus() *Status 11 } 12 13 // statusReporterStruct holds a map of all StatusReporters. 14 type statusReporterStruct struct { 15 statusReporters map[string]StatusReporter 16 } 17 18 // newStatusReporterStruct creates a new instance of the newStatusReporterStruct. 19 func newStatusReporterStruct() *statusReporterStruct { 20 return &statusReporterStruct{ 21 statusReporters: make(map[string]StatusReporter), 22 } 23 } 24 25 // RegisterStatusReporter registers a status reporter. 26 func (s *statusReporterStruct) RegisterStatusReporter(name string, sr StatusReporter) { 27 s.statusReporters[name] = sr 28 29 } 30 31 // ReportStatus gets the status of all StatusReporters within the Registry and 32 // puts them in a map 33 func (s *statusReporterStruct) ReportStatus() map[string]*Status { 34 m := make(map[string]*Status) 35 for key, val := range s.statusReporters { 36 m[key] = val.GetStatus() 37 } 38 return m 39 }