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:
Gabe Kangas
2020-11-14 18:39:53 -08:00
committed by GitHub
parent c76b7229a5
commit 4d2066a76d
34 changed files with 248 additions and 143 deletions

View File

@@ -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)
}
}

View File

@@ -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 {