2018-07-19 15:48:08 +01:00
|
|
|
// Copyright (C) 2018 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information
|
|
|
|
|
|
|
|
package node
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2018-08-23 16:20:11 +01:00
|
|
|
"github.com/zeebo/errs"
|
2018-07-19 15:48:08 +01:00
|
|
|
|
2018-08-23 16:20:11 +01:00
|
|
|
"storj.io/storj/pkg/pool"
|
2018-08-24 05:01:03 +01:00
|
|
|
"storj.io/storj/pkg/provider"
|
2018-07-19 15:48:08 +01:00
|
|
|
"storj.io/storj/pkg/transport"
|
|
|
|
proto "storj.io/storj/protos/overlay"
|
|
|
|
)
|
|
|
|
|
2018-08-23 16:20:11 +01:00
|
|
|
//NodeClientErr is the class for all errors pertaining to node client operations
|
|
|
|
var NodeClientErr = errs.Class("node client error")
|
|
|
|
|
2018-07-19 15:48:08 +01:00
|
|
|
// NewNodeClient instantiates a node client
|
2018-08-24 05:01:03 +01:00
|
|
|
func NewNodeClient(identity *provider.FullIdentity, self proto.Node) (Client, error) {
|
|
|
|
client := transport.NewClient(identity)
|
2018-07-19 15:48:08 +01:00
|
|
|
return &Node{
|
|
|
|
self: self,
|
2018-08-24 05:01:03 +01:00
|
|
|
tc: client,
|
2018-07-19 15:48:08 +01:00
|
|
|
cache: pool.NewConnectionPool(),
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Client is the Node client communication interface
|
|
|
|
type Client interface {
|
|
|
|
Lookup(ctx context.Context, to proto.Node, find proto.Node) ([]*proto.Node, error)
|
|
|
|
}
|