@@ -748,50 +748,36 @@ func GetIncidentListBySocketID(ctx *gin.Context) {
748748// @Router /dish/streamer/stats [get]
749749func GetStreamerStats (ctx * gin.Context ) {
750750 var counter int
751- var key string = "stats"
751+ var exportedStats = map [ string ] StreamerStats {}
752752
753753 if CacheStreamer == nil {
754754 ctx .IndentedJSON (http .StatusInternalServerError , gin.H {
755755 "code" : http .StatusInternalServerError ,
756756 "count" : counter ,
757757 "package" : pkgName ,
758758 "message" : "cannot access streamer cache" ,
759- "key" : key ,
760759 })
761760 return
762761 }
763762
764- rawStat , ok := CacheSockets .Get (key )
765- if ! ok {
766- ctx .IndentedJSON (http .StatusNotFound , gin.H {
767- "code" : http .StatusNotFound ,
768- "count" : counter ,
769- "package" : pkgName ,
770- "message" : "no streamer statistics" ,
771- "key" : key ,
772- })
773- return
774- }
763+ rawStats , counter := CacheStreamer .GetAll ()
775764
776- stat , ok := rawStat .(StreamerStats )
777- if ! ok {
778- ctx .IndentedJSON (http .StatusInternalServerError , gin.H {
779- "code" : http .StatusInternalServerError ,
780- "count" : counter ,
781- "package" : pkgName ,
782- "message" : "could not assert type dish.StreamerStats" ,
783- "key" : key ,
784- })
785- return
765+ // loop over string-map of interface{}
766+ for key , rawStat := range rawStats {
767+ stat , ok := rawStat .(StreamerStats )
768+ if ! ok {
769+ continue
770+ }
771+
772+ exportedStats [key ] = stat
786773 }
787774
788- counter ++
789775 ctx .IndentedJSON (http .StatusOK , gin.H {
790776 "code" : http .StatusOK ,
791777 "count" : counter ,
792- "item " : stat ,
778+ "items " : exportedStats ,
793779 "message" : "ok, dumping streamer statistics" ,
794- "key " : key ,
780+ "package " : pkgName ,
795781 })
796782 return
797783}
0 commit comments