Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
Change-Id: I256df930c969c4c81850d66d85a72488abd5529b
  • Loading branch information
VinozzZ committed Mar 18, 2020
1 parent e166fbf commit 11139e9
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 99 deletions.
3 changes: 0 additions & 3 deletions drpcconn/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ import (
"storj.io/drpc/drpcwire"
)

// INVOKE_HEADER_VERSION_1 indicates version 1 of invoke header.
const INVOKE_HEADER_VERSION_1 = 1

// Options controls configuration settings for a conn.
type Options struct {
// Manager controls the options we pass to the manager of this conn.
Expand Down
4 changes: 0 additions & 4 deletions drpcmanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"storj.io/drpc"
"storj.io/drpc/drpcctx"
"storj.io/drpc/drpcdebug"

"storj.io/drpc/drpcmetadata"
"storj.io/drpc/drpcsignal"
"storj.io/drpc/drpcstream"
Expand Down Expand Up @@ -193,9 +192,6 @@ func (m *Manager) NewServerStream(ctx context.Context) (stream *drpcstream.Strea

case drpcwire.KindInvoke:
if metadata.ID.Stream == pkt.ID.Stream {
// we use the first two bytes as the version flag to indicate whether
// there's metadata stored in the invoke message.
// If so, we should store the metadata onto the stream context
msg, err := drpcmetadata.Decode(metadata.Data)
if err != nil {
return nil, "", err
Expand Down
6 changes: 0 additions & 6 deletions drpcmetadata/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,3 @@

// Package drpcmetadata define the structure of the metadata supported by drpc library.
package drpcmetadata

import "github.com/spacemonkeygo/monkit/v3"

var mon = monkit.Package()

//go:generate bash -c "go install storj.io/drpc/cmd/protoc-gen-drpc && protoc --drpc_out=plugins=drpc:. ./proto/metadata.proto"
6 changes: 3 additions & 3 deletions drpcmetadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
ppb "storj.io/drpc/drpcmetadata/proto"
)

// INVOKE_METADATA_VERSION_1 indicates the version of InvokeMetadata message is 1.
const INVOKE_METADATA_VERSION_1 = 1
// InvokMetadataVersion1 indicates the version of InvokeMetadata message is 1.
const InvokMetadataVersion1 = 1

// Metadata is a mapping from metadata key to value.
type Metadata map[string]string
Expand All @@ -40,7 +40,7 @@ func (md Metadata) AddPairs(ctx context.Context) context.Context {
// Encode generates byte form of the metadata and appends it onto the passed in buffer.
func (md Metadata) Encode(buffer []byte) ([]byte, error) {
msg := ppb.InvokeMetadata{
Version: INVOKE_METADATA_VERSION_1,
Version: InvokMetadataVersion1,
Data: md,
}

Expand Down
8 changes: 8 additions & 0 deletions drpcmetadata/proto/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.

// Package proto defines the proto messages exposed by drpc for
// sending metadata across the wire.
package proto

//go:generate bash -c "go install storj.io/drpc/cmd/protoc-gen-drpc && protoc --drpc_out=plugins=drpc:. metadata.proto"
31 changes: 15 additions & 16 deletions drpcmetadata/proto/metadata.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 1 addition & 14 deletions drpcwire/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

package drpcwire

import (
"bytes"
"fmt"
)
import "fmt"

//go:generate stringer -type=Kind -trimprefix=Kind_ -output=packet_string.go

Expand Down Expand Up @@ -161,13 +158,3 @@ func (p Packet) String() string {
return fmt.Sprintf("<s:%d m:%d kind:%s data:%d>",
p.ID.Stream, p.ID.Message, p.Kind, len(p.Data))
}

// IsVersioned checks wether a given packet contains versioning bytes.
// Currently, we use the first two bytes to indicate versioning.
func (p Packet) IsVersioned() bool {
if len(p.Data) < 3 {
return false
}

return bytes.Equal(p.Data[:2], []byte{0, 0})
}
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ require (
github.com/spacemonkeygo/monkit/v3 v3.0.4
github.com/zeebo/assert v1.1.0
github.com/zeebo/errs v1.2.2
storj.io/monkit-jaeger v0.0.0-20200305222653-48145d285891
)
20 changes: 0 additions & 20 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,40 +1,20 @@
github.com/apache/thrift v0.12.0 h1:pODnxUFNcjP9UTLZGTdeh+j16A8lJbRvD3rOtrk/7bs=
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/spacemonkeygo/errors v0.0.0-20171212215202-9064522e9fd1/go.mod h1:7NL9UAYQnRM5iKHUCld3tf02fKb5Dft+41+VckASUy0=
github.com/spacemonkeygo/monkit/v3 v3.0.4 h1:Ay+PZirv+qfd4sqcT+X/U3BnC7AcIaqp/IXh0oV36k8=
github.com/spacemonkeygo/monkit/v3 v3.0.4/go.mod h1:JcK1pCbReQsOsMKF/POFSZCq7drXFybgGmbc27tuwes=
github.com/spacemonkeygo/monotime v0.0.0-20180824235756-e3f48a95f98a h1:8+cCjxhToanKmxLIbuyBNe2EnpgwhiivsIaRJstDRFA=
github.com/spacemonkeygo/monotime v0.0.0-20180824235756-e3f48a95f98a/go.mod h1:ul4bvvnCOPZgq8w0nTkSmWVg/hauVpFS97Am1YM1XXo=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/zeebo/assert v1.1.0 h1:hU1L1vLTHsnO8x8c9KAR5GmM5QscxHg5RNU5z5qbUWY=
github.com/zeebo/assert v1.1.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
github.com/zeebo/errs v1.2.2 h1:5NFypMTuSdoySVTqlNs1dEoU21QVamMQJxW/Fii5O7g=
github.com/zeebo/errs v1.2.2/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g=
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/spacemonkeygo/monkit-zipkin.v2 v2.0.0-20190419051645-ef9e56ba1633 h1:Z8UpEZC24VCgbDEi8Urgi0vgqWkstn6q8/h8GMJ8BgI=
gopkg.in/spacemonkeygo/monkit-zipkin.v2 v2.0.0-20190419051645-ef9e56ba1633/go.mod h1:pEbh8z/a1Jj9ZHhVsVhLfCZJKE/DVv3twibVY47FWPs=
gopkg.in/spacemonkeygo/monkit.v2 v2.0.0-20180827161543-6ebf5a752f9b h1:zkhw+LuPvld5/ZwIlpYzd4DX/r0KxTvhEpo+2lcrp9k=
gopkg.in/spacemonkeygo/monkit.v2 v2.0.0-20180827161543-6ebf5a752f9b/go.mod h1:6UQdi0rNB4YDNwVYP8fJNmjLNaU8MA84WCdXStx3Spo=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
storj.io/monkit-jaeger v0.0.0-20200305222653-48145d285891 h1:8kEmGLyH6HtU+f/Kt9sDLZ9kY1UK1i29YhFI+qr8/NI=
storj.io/monkit-jaeger v0.0.0-20200305222653-48145d285891/go.mod h1:a018CXJ7hJPKYsMDyrdxwsYe1cq8w6691nSwNK5J5Ls=
16 changes: 0 additions & 16 deletions internal/grpccompat/go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE=
Expand All @@ -18,17 +15,11 @@ github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/spacemonkeygo/errors v0.0.0-20171212215202-9064522e9fd1/go.mod h1:7NL9UAYQnRM5iKHUCld3tf02fKb5Dft+41+VckASUy0=
github.com/spacemonkeygo/monkit/v3 v3.0.4 h1:Ay+PZirv+qfd4sqcT+X/U3BnC7AcIaqp/IXh0oV36k8=
github.com/spacemonkeygo/monkit/v3 v3.0.4/go.mod h1:JcK1pCbReQsOsMKF/POFSZCq7drXFybgGmbc27tuwes=
github.com/spacemonkeygo/monotime v0.0.0-20180824235756-e3f48a95f98a h1:8+cCjxhToanKmxLIbuyBNe2EnpgwhiivsIaRJstDRFA=
github.com/spacemonkeygo/monotime v0.0.0-20180824235756-e3f48a95f98a/go.mod h1:ul4bvvnCOPZgq8w0nTkSmWVg/hauVpFS97Am1YM1XXo=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/zeebo/assert v1.1.0 h1:hU1L1vLTHsnO8x8c9KAR5GmM5QscxHg5RNU5z5qbUWY=
github.com/zeebo/assert v1.1.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
github.com/zeebo/errs v1.2.2 h1:5NFypMTuSdoySVTqlNs1dEoU21QVamMQJxW/Fii5O7g=
Expand All @@ -45,8 +36,6 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJV
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g=
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -71,10 +60,5 @@ google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZi
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1 h1:wdKvqQk7IttEw92GoRyKG2IDrUIpgpj6H6m81yfeMW0=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/spacemonkeygo/monkit-zipkin.v2 v2.0.0-20190419051645-ef9e56ba1633/go.mod h1:pEbh8z/a1Jj9ZHhVsVhLfCZJKE/DVv3twibVY47FWPs=
gopkg.in/spacemonkeygo/monkit.v2 v2.0.0-20180827161543-6ebf5a752f9b/go.mod h1:6UQdi0rNB4YDNwVYP8fJNmjLNaU8MA84WCdXStx3Spo=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
storj.io/monkit-jaeger v0.0.0-20200305222653-48145d285891/go.mod h1:a018CXJ7hJPKYsMDyrdxwsYe1cq8w6691nSwNK5J5Ls=
6 changes: 1 addition & 5 deletions internal/integration/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"net"

"github.com/zeebo/errs"

"storj.io/drpc/drpcconn"
"storj.io/drpc/drpcctx"
"storj.io/drpc/drpcerr"
Expand All @@ -29,11 +28,8 @@ func createConnection(server DRPCServiceServer) (DRPCServiceClient, func()) {
c1, c2 := net.Pipe()

mux := drpcmux.New()
traceHandler := handler{
mu: mux,
}
_ = DRPCRegisterService(mux, server)
srv := drpcserver.New(&traceHandler)
srv := drpcserver.New(mux)
ctx.Run(func(ctx context.Context) { _ = srv.ServeOne(ctx, c1) })
conn := drpcconn.New(c2)

Expand Down
19 changes: 8 additions & 11 deletions internal/integration/simple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,28 @@ import (
"io"
"testing"

"github.com/spacemonkeygo/monkit/v3"
"github.com/zeebo/assert"

"storj.io/drpc/drpcctx"
"storj.io/drpc/drpcerr"
)

var mon = monkit.Package()

func TestSimple(t *testing.T) {
tracker := drpcctx.NewTracker(context.Background())
defer tracker.Wait()
defer tracker.Cancel()
ctx := drpcctx.NewTracker(context.Background())
defer ctx.Wait()
defer ctx.Cancel()

cli, close := createConnection(standardImpl)
defer close()

{
out, err := cli.Method1(tracker, &In{In: 1})
out, err := cli.Method1(ctx, &In{In: 1})
assert.NoError(t, err)
assert.DeepEqual(t, out, &Out{Out: 1})
}

{
stream, err := cli.Method2(tracker)
stream, err := cli.Method2(ctx)
assert.NoError(t, err)
assert.NoError(t, stream.Send(&In{In: 2}))
assert.NoError(t, stream.Send(&In{In: 2}))
Expand All @@ -42,7 +39,7 @@ func TestSimple(t *testing.T) {
}

{
stream, err := cli.Method3(tracker, &In{In: 3})
stream, err := cli.Method3(ctx, &In{In: 3})
assert.NoError(t, err)
for {
out, err := stream.Recv()
Expand All @@ -55,7 +52,7 @@ func TestSimple(t *testing.T) {
}

{
stream, err := cli.Method4(tracker)
stream, err := cli.Method4(ctx)
assert.NoError(t, err)
assert.NoError(t, stream.Send(&In{In: 4}))
assert.NoError(t, stream.Send(&In{In: 4}))
Expand All @@ -73,7 +70,7 @@ func TestSimple(t *testing.T) {
}

{
_, err := cli.Method1(tracker, &In{In: 5})
_, err := cli.Method1(ctx, &In{In: 5})
assert.Error(t, err)
assert.Equal(t, drpcerr.Code(err), 5)
}
Expand Down

0 comments on commit 11139e9

Please sign in to comment.