clear linter messages

This commit is contained in:
tidwall 2021-07-10 03:59:27 -07:00
parent d3d4694691
commit d2f747933f
3 changed files with 15 additions and 27 deletions

View File

@ -1,38 +1,27 @@
package endpoint package endpoint
import ( import (
"cloud.google.com/go/pubsub"
"context" "context"
"errors"
"fmt" "fmt"
"github.com/streadway/amqp"
"google.golang.org/api/option"
"sync" "sync"
"time" "time"
"cloud.google.com/go/pubsub"
"google.golang.org/api/option"
) )
const pubsubExpiresAfter = time.Second * 30 const pubsubExpiresAfter = time.Second * 30
var errMissingGoogleCredentials = errors.New("Could not find GCP credentials - no credential path was submitted and envar GOOGLE_APPLICATION_CREDENTIALS is not set")
// SQSConn is an endpoint connection // SQSConn is an endpoint connection
type PubSubConn struct { type PubSubConn struct {
mu sync.Mutex mu sync.Mutex
ep Endpoint ep Endpoint
svc *pubsub.Client svc *pubsub.Client
topic *pubsub.Topic topic *pubsub.Topic
channel *amqp.Channel
ex bool ex bool
t time.Time t time.Time
} }
func (conn *PubSubConn) generatePubSubURL() string {
if conn.ep.SQS.PlainURL != "" {
return conn.ep.SQS.PlainURL
}
return "projects/" + conn.ep.PubSub.Project + "/topics/" + conn.ep.PubSub.Topic
}
func (conn *PubSubConn) close() { func (conn *PubSubConn) close() {
if conn.svc != nil { if conn.svc != nil {
conn.svc.Close() conn.svc.Close()
@ -93,7 +82,7 @@ func (conn *PubSubConn) Expired() bool {
conn.mu.Lock() conn.mu.Lock()
defer conn.mu.Unlock() defer conn.mu.Unlock()
if !conn.ex { if !conn.ex {
if time.Now().Sub(conn.t) > pubsubExpiresAfter { if time.Since(conn.t) > pubsubExpiresAfter {
conn.ex = true conn.ex = true
conn.close() conn.close()
} }

View File

@ -335,8 +335,7 @@ func makemsg(
} }
func fenceMatchObject(fence *liveFenceSwitches, obj geojson.Object) bool { func fenceMatchObject(fence *liveFenceSwitches, obj geojson.Object) bool {
gobj, _ := obj.(geojson.Object) if obj == nil {
if gobj == nil {
return false return false
} }
if fence.roam.on { if fence.roam.on {
@ -346,11 +345,11 @@ func fenceMatchObject(fence *liveFenceSwitches, obj geojson.Object) bool {
switch fence.cmd { switch fence.cmd {
case "nearby": case "nearby":
// nearby is an INTERSECT on a Circle // nearby is an INTERSECT on a Circle
return gobj.Intersects(fence.obj) return obj.Intersects(fence.obj)
case "within": case "within":
return gobj.Within(fence.obj) return obj.Within(fence.obj)
case "intersects": case "intersects":
return gobj.Intersects(fence.obj) return obj.Intersects(fence.obj)
} }
return false return false
} }

View File

@ -778,7 +778,7 @@ func (server *Server) handleInputCommand(client *Client, msg *Message) error {
cmd := msg.Command() cmd := msg.Command()
defer func() { defer func() {
took := time.Now().Sub(start).Seconds() took := time.Since(start).Seconds()
cmdDurations.With(prometheus.Labels{"cmd": cmd}).Observe(took) cmdDurations.With(prometheus.Labels{"cmd": cmd}).Observe(took)
}() }()