Start cleaning up linter errors. (#358)
* Start cleaning up linter errors. For #357 * Fix unmarshalling NullTime values * More linter fixes * Remove commented code * Move defer up * Consolidate error check lines * Move error check to make sure row iteration was successful * Cleaner error check + do not recreate pipe if it exists * Consolidate hashing to generate client id
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/owncast/owncast/config"
|
||||
"github.com/owncast/owncast/utils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type ypDetailsResponse struct {
|
||||
@@ -41,6 +42,8 @@ func GetYPResponse(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
json.NewEncoder(w).Encode(response)
|
||||
|
||||
err := json.NewEncoder(w).Encode(response)
|
||||
if err != nil {
|
||||
log.Errorln(err)
|
||||
}
|
||||
}
|
||||
|
||||
19
yp/yp.go
19
yp/yp.go
@@ -47,15 +47,9 @@ func NewYP(getStatusFunc func() models.Status) *YP {
|
||||
// Start is run when a live stream begins to start pinging YP.
|
||||
func (yp *YP) Start() {
|
||||
yp.timer = time.NewTicker(pingInterval)
|
||||
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case <-yp.timer.C:
|
||||
yp.ping()
|
||||
}
|
||||
}
|
||||
}()
|
||||
for range yp.timer.C {
|
||||
yp.ping()
|
||||
}
|
||||
|
||||
yp.ping()
|
||||
}
|
||||
@@ -92,7 +86,7 @@ func (yp *YP) ping() {
|
||||
}
|
||||
|
||||
pingURL := config.Config.GetYPServiceHost() + "/ping"
|
||||
resp, err := http.Post(pingURL, "application/json", bytes.NewBuffer(req))
|
||||
resp, err := http.Post(pingURL, "application/json", bytes.NewBuffer(req)) //nolint
|
||||
if err != nil {
|
||||
log.Errorln(err)
|
||||
return
|
||||
@@ -105,7 +99,10 @@ func (yp *YP) ping() {
|
||||
}
|
||||
|
||||
pingResponse := ypPingResponse{}
|
||||
json.Unmarshal(body, &pingResponse)
|
||||
err = json.Unmarshal(body, &pingResponse)
|
||||
if err != nil {
|
||||
log.Errorln(err)
|
||||
}
|
||||
|
||||
if !pingResponse.Success {
|
||||
if !_inErrorState {
|
||||
|
||||
Reference in New Issue
Block a user