Transport Client (#89)
* port changes * Task monitor and setup merge from the staging * Restructure + additional interface * Add NewOverlayClient * integrated DHT client interface * added test for interface * PR comments addressed * lint issue * added generated protobuf * adding new interface * added the interface framework * deleted file * fixes compilation errors and integrates new dhtcclient interface * merged netstat latest changes and dht new interface chagnes * fixed the address's port * adding comments * PR comments addressed * netclient interface dial method added * rename and integrated transportclient with minio gateway * rename and code clean up * made changes based on the Dennis's changes on the kad-client * Code review comment changes based on kaloyan review comments * reverted the changes to be similar to master * removed unused file * renamed to transportclient * added the review changes * store the address of the client * updates per the code review comments, changes-> added error retry connection attempt logic, added error conditions including nil parameters * updated the test case to test the bad address passed condition * updated the code per code review comments * Bolt backed overlay cache (#94) * wip * add separate `Process` tests for bolt and redis-backed overlay * more testing * fix gitignore * fix linter error * goimports goimports GOIMPORTS GoImPortS!!!! * fix port madness * forgot to add * add `mux` as handler and shorten context timeouts * gofreakingimports * fix comments * refactor test & add logger/monkit registry * debugging travis * add comment * Set redisAddress to empty string for bolt-test * travis experiment * refactoring tests * Merge remote-tracking branch 'upstream/master' into bolt-backed-overlay-cache * Automatically build, tag and push docker images on merge to master (#103) * port changes * build overlay on successful merge to master * fixes to Makefile * permissions * dep ensure * gopath * let's try vgo * remove dep * maybe alpine is the issue * tagging go version on build * stupid vgo * vgo * adding tags to push * quotes * local linting fixes & stupid travis * prepend storjlabs to docker tag (#108) * port changes * fixing tag name * Use continue instead of return in table tests (#106) I did a dumb mistake for some of the table tests, which made some of the test cases not being executed. * pkg/kademlia tests and restructuring (#97) * port changes * Merge remote-tracking branch 'upstream/master' * Merge remote-tracking branch 'upstream/master' * Merge remote-tracking branch 'upstream/master' * files created * Merge remote-tracking branch 'upstream/master' into coyle/kad-tests * wip * Merge remote-tracking branch 'upstream/master' into coyle/kad-tests * wip * remove bkad dependencie from tests * wip * wip * wip * wip * wip * updated coyle/kademlia * wip * cleanup * ports * overlay upgraded * linter fixes * piecestore kademlia newID * add changes from kad demo * PR comments addresses * go func * force travis build * fixed merge conflicts * fixed merge conflicts * Merge branch 'coyle/kad-tests' of https://github.com/coyle/storj into coyle/kad-tests * linter issues * linting issues * fixed merge conflicts * linter is stupid * Coyle/docker fix (#109) * port changes * Merge remote-tracking branch 'upstream/master' * Merge remote-tracking branch 'upstream/master' * Merge remote-tracking branch 'upstream/master' * Merge remote-tracking branch 'upstream/master' * Merge remote-tracking branch 'upstream/master' * Merge branch 'master' of https://github.com/storj/storj * fixing tag name * no idea * testing * changes * testing on travis * testing * changes to travis build * new approach * Merge branch 'master' into coyle/docker-fix * hardcode version (#111) * hardcode version * adding coveralls / code coverage (#112) * adding coveralls * adding code coverage badge * fixing badges * verbose * swap tests and coverage * extra line * maybe * maybe * moar * gover maybe * testing * cleanup * protos/netstate: remove stuff we're not using (#100) * protos/netstate: remove stuff we're not using * protos/netstate: add metadata field for segmentstore * fix netstate client test * pkg/process: start replacing pkg/process with cobra helpers (#98) * Implement psclient interface (#107) * Implement psclient interface * Add string method to pieceID type * try to fix linter errors * Whoops missed an error * More linter errors * Typo * Lol double typo * Get everything working, begin adding tests for psclient rpc * goimports * Forgot to change the piecestore cli when changed the piecestore code * Fix CLI * remove ID length, added validator to pieceID * Move grpc ranger to client Change client PUT api to take a reader rather than return a writer * GRPCRanger -> PieceRanger; Make PieceRanger a RangeCloser * Forgot to remove offset * Added message upon successful store * Do that thing dennis and kaloyan wanted * goimports * Make closeConn a part of the interface for psclient * Use interface * Removed uneccessary new lines * goimport * Whoops * Actually we don't want to use the interface in Piece Ranger * Renamed piecestore in examples to piecestore-client; moved piecestore-cli to examples * Make comments look nicer * modified transport client based on the the design discussion * modified transport client based on the the design discussion * added the as discussed connection cache interface functionality * added the as discussed connection cache interface functionality * transport client changes * transport client per code review changes * per the code review comments * transport client incorporates review comments * fixes lint warnings * lint warning fixes....client interface has to be Client * client.go changes * transport.go changes * added test case * added test cases * comment fix * comment fix
This commit is contained in:
parent
900f67e3d0
commit
26f68fa774
26
pkg/transport/client.go
Normal file
26
pkg/transport/client.go
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright (C) 2018 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
package transport
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zeebo/errs"
|
||||
"google.golang.org/grpc"
|
||||
monkit "gopkg.in/spacemonkeygo/monkit.v2"
|
||||
|
||||
proto "storj.io/storj/protos/overlay"
|
||||
)
|
||||
|
||||
var (
|
||||
mon = monkit.Package()
|
||||
//Error is the errs class of standard Transport Client errors
|
||||
Error = errs.Class("transport error")
|
||||
)
|
||||
|
||||
// Client defines the interface to an transport client.
|
||||
type Client interface {
|
||||
DialUnauthenticated(ctx context.Context, addr proto.NodeAddress) (*grpc.ClientConn, error)
|
||||
DialNode(ctx context.Context, node proto.Node) (*grpc.ClientConn, error)
|
||||
}
|
38
pkg/transport/transport.go
Normal file
38
pkg/transport/transport.go
Normal file
@ -0,0 +1,38 @@
|
||||
// Copyright (C) 2018 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
package transport
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
proto "storj.io/storj/protos/overlay"
|
||||
)
|
||||
|
||||
// Transport interface structure
|
||||
type Transport struct {
|
||||
}
|
||||
|
||||
// DialNode using the authenticated mode
|
||||
func (o *Transport) DialNode(ctx context.Context, node proto.Node) (conn *grpc.ClientConn, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
if node.Address == nil {
|
||||
return nil, Error.New("no address")
|
||||
}
|
||||
/* TODO@ASK security feature under development */
|
||||
return o.DialUnauthenticated(ctx, *node.Address)
|
||||
}
|
||||
|
||||
// DialUnauthenticated using unauthenticated mode
|
||||
func (o *Transport) DialUnauthenticated(ctx context.Context, addr proto.NodeAddress) (conn *grpc.ClientConn, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
if addr.Address == "" {
|
||||
return nil, Error.New("no address")
|
||||
}
|
||||
|
||||
return grpc.Dial(addr.Address, grpc.WithInsecure())
|
||||
}
|
48
pkg/transport/transport_test.go
Normal file
48
pkg/transport/transport_test.go
Normal file
@ -0,0 +1,48 @@
|
||||
// Copyright (C) 2018 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
package transport
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
proto "storj.io/storj/protos/overlay"
|
||||
)
|
||||
|
||||
func TestDialNode(t *testing.T) {
|
||||
oc := Transport{}
|
||||
|
||||
// node.Address.Address == "" condition test
|
||||
node := proto.Node{
|
||||
Id: "DUMMYID1",
|
||||
Address: &proto.NodeAddress{
|
||||
Transport: proto.NodeTransport_TCP,
|
||||
Address: "",
|
||||
},
|
||||
}
|
||||
conn, err := oc.DialNode(context.Background(), node)
|
||||
assert.Error(t, err)
|
||||
assert.Nil(t, conn)
|
||||
|
||||
// node.Address == nil condition test
|
||||
node = proto.Node{
|
||||
Id: "DUMMYID2",
|
||||
Address: nil,
|
||||
}
|
||||
conn, err = oc.DialNode(context.Background(), node)
|
||||
assert.Error(t, err)
|
||||
assert.Nil(t, conn)
|
||||
|
||||
// node is valid argument condition test
|
||||
node = proto.Node{
|
||||
Id: "DUMMYID3",
|
||||
Address: &proto.NodeAddress{
|
||||
Transport: proto.NodeTransport_TCP,
|
||||
Address: "127.0.0.0:9000",
|
||||
},
|
||||
}
|
||||
conn, err = oc.DialNode(context.Background(), node)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, conn)
|
||||
}
|
Loading…
Reference in New Issue
Block a user