[#126] sdk: add sdk client for all available api requests
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
10137b44dd
commit
86e6221b76
3 changed files with 196 additions and 0 deletions
50
pkg/client/client.go
Normal file
50
pkg/client/client.go
Normal file
|
@ -0,0 +1,50 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"errors"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg"
|
||||
)
|
||||
|
||||
type (
|
||||
Client struct {
|
||||
key *ecdsa.PrivateKey
|
||||
remoteNode TransportInfo
|
||||
|
||||
opts *clientOptions
|
||||
}
|
||||
|
||||
TransportProtocol uint32
|
||||
|
||||
TransportInfo struct {
|
||||
Version pkg.Version
|
||||
Protocol TransportProtocol
|
||||
}
|
||||
)
|
||||
|
||||
const (
|
||||
Unknown TransportProtocol = iota
|
||||
GRPC
|
||||
)
|
||||
|
||||
var (
|
||||
unsupportedProtocolErr = errors.New("unsupported transport protocol")
|
||||
)
|
||||
|
||||
func New(key *ecdsa.PrivateKey, opts ...ClientOption) (*Client, error) {
|
||||
clientOptions := defaultClientOptions()
|
||||
for i := range opts {
|
||||
opts[i].apply(clientOptions)
|
||||
}
|
||||
|
||||
// todo: make handshake to check latest version
|
||||
return &Client{
|
||||
key: key,
|
||||
remoteNode: TransportInfo{
|
||||
Version: pkg.SDKVersion,
|
||||
Protocol: GRPC,
|
||||
},
|
||||
opts: clientOptions,
|
||||
}, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue