Documentation ¶
Overview ¶
Package client is an umbrella client for all TemporalX gRPC services, while also providing some convenience functions.
Index ¶
- Variables
- type Client
- func (c *Client) Close() error
- func (c *Client) ConnectToPeer(ctx context.Context, multiaddr string) error
- func (c *Client) Connected(ctx context.Context, peer string) (bool, error)
- func (c *Client) DisconnectFromPeer(ctx context.Context, id string) error
- func (c *Client) DownloadFile(ctx context.Context, download *pb.DownloadRequest, printProgress bool, ...) (*bytes.Buffer, error)
- func (c *Client) GetPeerCount(ctx context.Context) (int, error)
- func (c *Client) PSGetTopics(ctx context.Context) ([]string, error)
- func (c *Client) PSListPeers(ctx context.Context, topics ...string) ([]*pb.PubSubPeer, error)
- func (c *Client) PSPublish(ctx context.Context, topic string, data []byte) error
- func (c *Client) PSSubscribe(ctx context.Context, topic string, discover bool, ...) error
- func (c *Client) UploadFile(ctx context.Context, file io.Reader, fileSize int64, opts *pb.UploadOptions, ...) (*pb.PutResponse, error)
- type Opts
Constants ¶
This section is empty.
Variables ¶
var ( // PrintMsgExecFunc is used to print pubsub messages as they are received PrintMsgExecFunc = func(msg *pb.PubSubResponse) { for _, msg := range msg.GetMessage() { fmt.Printf( "%s\n", au.Bold(au.Green(string(msg.GetData()))), ) } } )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { pb.FileAPIClient pb.NodeAPIClient pb.StatusAPIClient pb.PubSubAPIClient pb.AdminAPIClient pb.NameSysAPIClient // contains filtered or unexported fields }
Client is a golang thin-client to interact with a TemporalX server
func NewClient ¶
func NewClient(opts Opts, dialOpts ...grpc.DialOption) (*Client, error)
NewClient dials a connection to the grpc server and registered api endpoints
func (*Client) ConnectToPeer ¶
ConnectToPeer is a convenience function to connect to a single peer
func (*Client) Connected ¶
Connected is a convenience function for checking if the given peer is connected to our node
func (*Client) DisconnectFromPeer ¶
DisconnectFromPeer is a convenience function to disconnect from a single peer
func (*Client) DownloadFile ¶
func (c *Client) DownloadFile( ctx context.Context, download *pb.DownloadRequest, printProgress bool, grpcOpts ...grpc.CallOption, ) (*bytes.Buffer, error)
DownloadFile is a convenience function for downloading a single file
func (*Client) GetPeerCount ¶
GetPeerCount is a convenience function for returning the number of peers we are connected to
func (*Client) PSGetTopics ¶
PSGetTopics is a helper function used to fetch subscribed pubsub topics
func (*Client) PSListPeers ¶
PSListPeers is a helper function used to list pubsub peers
func (*Client) PSSubscribe ¶
func (c *Client) PSSubscribe(ctx context.Context, topic string, discover bool, msgExecFunc func(msg *pb.PubSubResponse)) error
PSSubscribe is a helper method to subscribe to a given topic It takes in a msgExecFunc argument that allows you to craft your own functions that do different executions whenever a message is received. If msgExecFunc is empty then we use a default function that prints received messages
func (*Client) UploadFile ¶
func (c *Client) UploadFile( ctx context.Context, file io.Reader, fileSize int64, opts *pb.UploadOptions, printProgress bool, grpcOpts ...grpc.CallOption, ) (*pb.PutResponse, error)
UploadFile is a convenience function for uploading a single file