Skip to content

Commit

Permalink
wip fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
j-bro committed Nov 1, 2023
1 parent e68565e commit c233ed5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cmd/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"encoding/json"
"flag"
"fmt"
"github.com/multiplay/go-svrquery/lib/svrquery"
"log"
"os"

"github.com/multiplay/go-svrquery/lib/svrquery"
"github.com/multiplay/go-svrquery/lib/svrquery/protocol"
"github.com/multiplay/go-svrquery/lib/svrsample"
"github.com/multiplay/go-svrquery/lib/svrsample/common"
Expand Down
21 changes: 9 additions & 12 deletions lib/svrquery/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,29 +73,26 @@ func NewClient(proto, addr string, options ...Option) (*Client, error) {
}
c.Queryer = f(c)

// TODO: move keys & timeout to transport?
for _, o := range options {
if err := o(c); err != nil {
return nil, err
}
}

var t transport
switch proto {
case "sqp":
t = &udpTransport{address: addr}
case "prom":
t = &httpTransport{address: addr}
default:
return nil, fmt.Errorf("protocol %s not supported", proto)
// defaulting to udp
t = &udpTransport{address: addr}
}
c.transport = t

for _, o := range options {
if err := o(c); err != nil {
return nil, err
}
}

if err := t.Setup(); err != nil {
return nil, fmt.Errorf("setup client transport: %w", err)
}

c.transport = t

return c, nil
}

Expand Down
5 changes: 3 additions & 2 deletions lib/svrquery/protocol/prom/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package prom
import (
"bytes"
"fmt"
"github.com/multiplay/go-svrquery/lib/svrquery/protocol"
"github.com/prometheus/common/expfmt"
"io"
"strconv"

"github.com/multiplay/go-svrquery/lib/svrquery/protocol"
"github.com/prometheus/common/expfmt"
)

const defaultBufSize = 4096
Expand Down

0 comments on commit c233ed5

Please sign in to comment.