mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-06-28 15:27:43 +00:00
Fix more warnings
This commit is contained in:
parent
1aa1046073
commit
ced892fd1a
4 changed files with 8 additions and 28 deletions
|
@ -505,7 +505,7 @@ func SendMessage(conn *websocket.Conn, msg ClientMessage) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalClientMessage unpacks websocket TextMessage into a ClientMessage provided in the `v` parameter.
|
// UnmarshalClientMessage unpacks websocket TextMessage into a ClientMessage provided in the `v` parameter.
|
||||||
func UnmarshalClientMessage(data []byte, payloadType int, v interface{}) (err error) {
|
func UnmarshalClientMessage(data []byte, _ int, v interface{}) (err error) {
|
||||||
var spaceIdx int
|
var spaceIdx int
|
||||||
|
|
||||||
out := v.(*ClientMessage)
|
out := v.(*ClientMessage)
|
||||||
|
@ -550,7 +550,8 @@ func (cm *ClientMessage) parseOrigArguments() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func MarshalClientMessage(clientMessage interface{}) (payloadType int, data []byte, err error) {
|
// returns payloadType, data, err
|
||||||
|
func MarshalClientMessage(clientMessage interface{}) (int, []byte, error) {
|
||||||
var msg ClientMessage
|
var msg ClientMessage
|
||||||
var ok bool
|
var ok bool
|
||||||
msg, ok = clientMessage.(ClientMessage)
|
msg, ok = clientMessage.(ClientMessage)
|
||||||
|
|
|
@ -209,7 +209,7 @@ func updateSysMem() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// HTTPShowStatistics handles the /stats endpoint. It writes out the Statistics object as indented JSON.
|
// HTTPShowStatistics handles the /stats endpoint. It writes out the Statistics object as indented JSON.
|
||||||
func HTTPShowStatistics(w http.ResponseWriter, r *http.Request) {
|
func HTTPShowStatistics(w http.ResponseWriter, _ *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
|
||||||
updateStatsIfNeeded()
|
updateStatsIfNeeded()
|
||||||
|
|
|
@ -46,11 +46,6 @@ var uniqueCtrWritingToken chan usageToken
|
||||||
|
|
||||||
var CounterLocation *time.Location = time.FixedZone("UTC-5", int((time.Hour*-5)/time.Second))
|
var CounterLocation *time.Location = time.FixedZone("UTC-5", int((time.Hour*-5)/time.Second))
|
||||||
|
|
||||||
func TruncateToMidnight(at time.Time) time.Time {
|
|
||||||
year, month, day := at.Date()
|
|
||||||
return time.Date(year, month, day, 0, 0, 0, 0, CounterLocation)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCounterPeriod calculates the start and end timestamps for the HLL measurement period that includes the 'at' timestamp.
|
// GetCounterPeriod calculates the start and end timestamps for the HLL measurement period that includes the 'at' timestamp.
|
||||||
func GetCounterPeriod(at time.Time) (start time.Time, end time.Time) {
|
func GetCounterPeriod(at time.Time) (start time.Time, end time.Time) {
|
||||||
year, month, day := at.Date()
|
year, month, day := at.Date()
|
||||||
|
@ -132,7 +127,7 @@ func HTTPShowHLL(w http.ResponseWriter, r *http.Request) {
|
||||||
hllFileServer.ServeHTTP(w, r)
|
hllFileServer.ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func HTTPWriteHLL(w http.ResponseWriter, r *http.Request) {
|
func HTTPWriteHLL(w http.ResponseWriter, _ *http.Request) {
|
||||||
writeHLL()
|
writeHLL()
|
||||||
w.WriteHeader(200)
|
w.WriteHeader(200)
|
||||||
w.Write([]byte("ok"))
|
w.Write([]byte("ok"))
|
||||||
|
@ -150,9 +145,7 @@ func loadUniqueUsers() {
|
||||||
now := time.Now().In(CounterLocation)
|
now := time.Now().In(CounterLocation)
|
||||||
uniqueCounter.Start, uniqueCounter.End = GetCounterPeriod(now)
|
uniqueCounter.Start, uniqueCounter.End = GetCounterPeriod(now)
|
||||||
err = loadHLL(now, &uniqueCounter)
|
err = loadHLL(now, &uniqueCounter)
|
||||||
isIgnorableError := err != nil && (false ||
|
isIgnorableError := err != nil && (os.IsNotExist(err) || err == io.EOF)
|
||||||
(os.IsNotExist(err)) ||
|
|
||||||
(err == io.EOF))
|
|
||||||
|
|
||||||
if isIgnorableError {
|
if isIgnorableError {
|
||||||
// file didn't finish writing
|
// file didn't finish writing
|
||||||
|
@ -227,10 +220,10 @@ func rolloverCounters_do() {
|
||||||
|
|
||||||
// Attempt to rescue the data into the log
|
// Attempt to rescue the data into the log
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
bytes, err := uniqueCounter.Counter.GobEncode()
|
by, err := uniqueCounter.Counter.GobEncode()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
enc := base64.NewEncoder(base64.StdEncoding, &buf)
|
enc := base64.NewEncoder(base64.StdEncoding, &buf)
|
||||||
enc.Write(bytes)
|
enc.Write(by)
|
||||||
enc.Close()
|
enc.Close()
|
||||||
log.Print("data for ", GetHLLFilename(uniqueCounter.Start), ":", buf.String())
|
log.Print("data for ", GetHLLFilename(uniqueCounter.Start), ":", buf.String())
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,17 +161,3 @@ func RemoveFromSliceCl(ary *[]*ClientInfo, val *ClientInfo) bool {
|
||||||
*ary = slice
|
*ary = slice
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddToSliceB(ary *[]bunchSubscriber, client *ClientInfo, mid int) bool {
|
|
||||||
newSub := bunchSubscriber{Client: client, MessageID: mid}
|
|
||||||
slice := *ary
|
|
||||||
for _, v := range slice {
|
|
||||||
if v == newSub {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
slice = append(slice, newSub)
|
|
||||||
*ary = slice
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue