mirror of https://github.com/tidwall/tile38.git
clear linter messages
This commit is contained in:
parent
d3d4694691
commit
d2f747933f
|
@ -1,38 +1,27 @@
|
|||
package endpoint
|
||||
|
||||
import (
|
||||
"cloud.google.com/go/pubsub"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/streadway/amqp"
|
||||
"google.golang.org/api/option"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"cloud.google.com/go/pubsub"
|
||||
"google.golang.org/api/option"
|
||||
)
|
||||
|
||||
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
|
||||
type PubSubConn struct {
|
||||
mu sync.Mutex
|
||||
ep Endpoint
|
||||
svc *pubsub.Client
|
||||
topic *pubsub.Topic
|
||||
channel *amqp.Channel
|
||||
ex bool
|
||||
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() {
|
||||
if conn.svc != nil {
|
||||
conn.svc.Close()
|
||||
|
@ -93,7 +82,7 @@ func (conn *PubSubConn) Expired() bool {
|
|||
conn.mu.Lock()
|
||||
defer conn.mu.Unlock()
|
||||
if !conn.ex {
|
||||
if time.Now().Sub(conn.t) > pubsubExpiresAfter {
|
||||
if time.Since(conn.t) > pubsubExpiresAfter {
|
||||
conn.ex = true
|
||||
conn.close()
|
||||
}
|
||||
|
|
|
@ -335,8 +335,7 @@ func makemsg(
|
|||
}
|
||||
|
||||
func fenceMatchObject(fence *liveFenceSwitches, obj geojson.Object) bool {
|
||||
gobj, _ := obj.(geojson.Object)
|
||||
if gobj == nil {
|
||||
if obj == nil {
|
||||
return false
|
||||
}
|
||||
if fence.roam.on {
|
||||
|
@ -346,11 +345,11 @@ func fenceMatchObject(fence *liveFenceSwitches, obj geojson.Object) bool {
|
|||
switch fence.cmd {
|
||||
case "nearby":
|
||||
// nearby is an INTERSECT on a Circle
|
||||
return gobj.Intersects(fence.obj)
|
||||
return obj.Intersects(fence.obj)
|
||||
case "within":
|
||||
return gobj.Within(fence.obj)
|
||||
return obj.Within(fence.obj)
|
||||
case "intersects":
|
||||
return gobj.Intersects(fence.obj)
|
||||
return obj.Intersects(fence.obj)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -778,7 +778,7 @@ func (server *Server) handleInputCommand(client *Client, msg *Message) error {
|
|||
|
||||
cmd := msg.Command()
|
||||
defer func() {
|
||||
took := time.Now().Sub(start).Seconds()
|
||||
took := time.Since(start).Seconds()
|
||||
cmdDurations.With(prometheus.Labels{"cmd": cmd}).Observe(took)
|
||||
}()
|
||||
|
||||
|
|
Loading…
Reference in New Issue