Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #68 from jaffee/rename-proto
Browse files Browse the repository at this point in the history
rename internal package to avoid name conflicts with protobufs
  • Loading branch information
jaffee authored Oct 3, 2017
2 parents caab511 + d85eb05 commit 7254204
Show file tree
Hide file tree
Showing 9 changed files with 354 additions and 103 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ before_install:
- go get -u github.com/golang/dep/cmd/dep
addons:
script:
- dep ensure && $HOME/gopath/bin/goveralls -service=travis-ci -ignore "internal/public.pb.go" -flags="-tags=integration"
- dep ensure && $HOME/gopath/bin/goveralls -service=travis-ci -ignore "gopilosa_pbuf/public.pb.go" -flags="-tags=integration"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cover:
go test -cover -tags=integration

generate:
protoc --go_out=. internal/public.proto
protoc --go_out=. gopilosa_pbuf/public.proto

test:
go test
Expand Down
18 changes: 9 additions & 9 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import (
"time"

"github.com/golang/protobuf/proto"
"github.com/pilosa/go-pilosa/internal"
pbuf "github.com/pilosa/go-pilosa/gopilosa_pbuf"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -120,7 +120,7 @@ func (c *Client) Query(query PQLQuery, options *QueryOptions) (*QueryResponse, e
if err != nil {
return nil, err
}
iqr := &internal.QueryResponse{}
iqr := &pbuf.QueryResponse{}
err = proto.Unmarshal(buf, iqr)
if err != nil {
return nil, err
Expand Down Expand Up @@ -439,7 +439,7 @@ func (c *Client) fetchFragmentNodes(indexName string, slice uint64) ([]fragmentN
return fragmentNodes, nil
}

func (c *Client) importNode(uri *URI, request *internal.ImportRequest) error {
func (c *Client) importNode(uri *URI, request *pbuf.ImportRequest) error {
data, err := proto.Marshal(request)
if err != nil {
return errors.Wrap(err, "marshaling to protobuf")
Expand All @@ -451,7 +451,7 @@ func (c *Client) importNode(uri *URI, request *internal.ImportRequest) error {
return errors.Wrap(resp.Body.Close(), "closing import response body")
}

func (c *Client) importValueNode(uri *URI, request *internal.ImportValueRequest) error {
func (c *Client) importValueNode(uri *URI, request *pbuf.ImportValueRequest) error {
data, _ := proto.Marshal(request)
// request.Marshal never returns an error
_, err := c.doRequest(uri, "POST", "/import-value", protobufHeaders, bytes.NewReader(data))
Expand Down Expand Up @@ -626,7 +626,7 @@ func newHTTPClient(options *ClientOptions) *http.Client {
}

func makeRequestData(query string, options *QueryOptions) ([]byte, error) {
request := &internal.QueryRequest{
request := &pbuf.QueryRequest{
Query: query,
ColumnAttrs: options.Columns,
ExcludeAttrs: options.ExcludeAttrs,
Expand All @@ -649,7 +649,7 @@ func matchError(msg string) error {
return nil
}

func bitsToImportRequest(indexName string, frameName string, slice uint64, bits []Bit) *internal.ImportRequest {
func bitsToImportRequest(indexName string, frameName string, slice uint64, bits []Bit) *pbuf.ImportRequest {
rowIDs := make([]uint64, 0, len(bits))
columnIDs := make([]uint64, 0, len(bits))
timestamps := make([]int64, 0, len(bits))
Expand All @@ -658,7 +658,7 @@ func bitsToImportRequest(indexName string, frameName string, slice uint64, bits
columnIDs = append(columnIDs, bit.ColumnID)
timestamps = append(timestamps, bit.Timestamp)
}
return &internal.ImportRequest{
return &pbuf.ImportRequest{
Index: indexName,
Frame: frameName,
Slice: slice,
Expand All @@ -668,14 +668,14 @@ func bitsToImportRequest(indexName string, frameName string, slice uint64, bits
}
}

func valsToImportRequest(indexName string, frameName string, slice uint64, fieldName string, vals []FieldValue) *internal.ImportValueRequest {
func valsToImportRequest(indexName string, frameName string, slice uint64, fieldName string, vals []FieldValue) *pbuf.ImportValueRequest {
columnIDs := make([]uint64, 0, len(vals))
values := make([]uint64, 0, len(vals))
for _, val := range vals {
columnIDs = append(columnIDs, val.ColumnID)
values = append(values, val.Value)
}
return &internal.ImportValueRequest{
return &pbuf.ImportValueRequest{
Index: indexName,
Frame: frameName,
Slice: slice,
Expand Down
12 changes: 6 additions & 6 deletions client_it_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import (
"time"

"github.com/golang/protobuf/proto"
"github.com/pilosa/go-pilosa/internal"
pbuf "github.com/pilosa/go-pilosa/gopilosa_pbuf"
)

var index *Index
Expand Down Expand Up @@ -1177,7 +1177,7 @@ func TestImportNodeFails(t *testing.T) {
t.Fatal(err)
}
client := NewClientWithURI(uri)
importRequest := &internal.ImportRequest{
importRequest := &pbuf.ImportRequest{
ColumnIDs: []uint64{},
RowIDs: []uint64{},
Timestamps: []int64{},
Expand Down Expand Up @@ -1207,20 +1207,20 @@ func TestImportNodeProtobufMarshalFails(t *testing.T) {
}

func TestResponseWithInvalidType(t *testing.T) {
qr := &internal.QueryResponse{
qr := &pbuf.QueryResponse{
Err: "",
ColumnAttrSets: []*internal.ColumnAttrSet{
ColumnAttrSets: []*pbuf.ColumnAttrSet{
{
ID: 0,
Attrs: []*internal.Attr{
Attrs: []*pbuf.Attr{
{
Type: 9999,
StringValue: "NOVAL",
},
},
},
},
Results: []*internal.QueryResult{},
Results: []*pbuf.QueryResult{},
}
data, err := proto.Marshal(qr)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ package pilosa_test
import (
"testing"

pilosa "github.com/pilosa/go-pilosa"
"github.com/pilosa/go-pilosa"
)

func TestQueryWithError(t *testing.T) {
Expand Down
Loading

0 comments on commit 7254204

Please sign in to comment.