storj/satellite/contact/client.go
Egon Elbre 5d016425f1 satellite/{contact,downtime,overlay}: use NodeURL
Change-Id: I555a479a89e0ddbf0499898bdbc8574282cd6846
2020-05-20 11:09:05 +00:00

41 lines
864 B
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package contact
import (
"context"
"storj.io/common/pb"
"storj.io/common/rpc"
"storj.io/common/storj"
)
type client struct {
conn *rpc.Conn
client pb.DRPCContactClient
}
// dialNodeURL dials the target contact endpoint
func dialNodeURL(ctx context.Context, dialer rpc.Dialer, nodeurl storj.NodeURL) (*client, error) {
conn, err := dialer.DialNodeURL(ctx, nodeurl)
if err != nil {
return nil, err
}
return &client{
conn: conn,
client: pb.NewDRPCContactClient(conn),
}, nil
}
// pingNode pings a node
func (client *client) pingNode(ctx context.Context, req *pb.ContactPingRequest) (*pb.ContactPingResponse, error) {
return client.client.PingNode(ctx, req)
}
// Close closes the connection
func (client *client) Close() error {
return client.conn.Close()
}