1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Refine the regression test tool, add missing files

This commit is contained in:
winlin 2021-03-04 14:03:01 +08:00
parent a29d0a6a24
commit bb3bd1705e
8 changed files with 1333 additions and 3 deletions

47
trunk/3rdparty/srs-bench/srs/stat.go vendored Normal file
View file

@ -0,0 +1,47 @@
package srs
import (
"context"
"encoding/json"
"github.com/ossrs/go-oryx-lib/logger"
"net/http"
"strings"
)
type statRTC struct {
Publishers struct {
Expect int `json:"expect"`
Alive int `json:"alive"`
} `json:"publishers"`
Subscribers struct {
Expect int `json:"expect"`
Alive int `json:"alive"`
} `json:"subscribers"`
PeerConnection interface{} `json:"random-pc"`
}
var StatRTC statRTC
func HandleStat(ctx context.Context, mux *http.ServeMux, l string) {
if strings.HasPrefix(l, ":") {
l = "127.0.0.1" + l
}
logger.Tf(ctx, "Handle http://%v/api/v1/sb/rtc", l)
mux.HandleFunc("/api/v1/sb/rtc", func(w http.ResponseWriter, r *http.Request) {
res := &struct {
Code int `json:"code"`
Data interface{} `json:"data"`
}{
0, &StatRTC,
}
b, err := json.Marshal(res)
if err != nil {
logger.Wf(ctx, "marshal %v err %+v", res, err)
return
}
w.Write(b)
})
}