client

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2020 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package client is an umbrella client for all TemporalX gRPC services, while also providing some convenience functions.

Index

Constants

This section is empty.

Variables

View Source
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) Close

func (c *Client) Close() error

Close is used to terminate our grpc client connection

func (*Client) ConnectToPeer

func (c *Client) ConnectToPeer(ctx context.Context, multiaddr string) error

ConnectToPeer is a convenience function to connect to a single peer

func (*Client) Connected

func (c *Client) Connected(ctx context.Context, peer string) (bool, error)

Connected is a convenience function for checking if the given peer is connected to our node

func (*Client) DisconnectFromPeer

func (c *Client) DisconnectFromPeer(ctx context.Context, id string) error

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

func (c *Client) GetPeerCount(ctx context.Context) (int, error)

GetPeerCount is a convenience function for returning the number of peers we are connected to

func (*Client) PSGetTopics

func (c *Client) PSGetTopics(ctx context.Context) ([]string, error)

PSGetTopics is a helper function used to fetch subscribed pubsub topics

func (*Client) PSListPeers

func (c *Client) PSListPeers(ctx context.Context, topics ...string) ([]*pb.PubSubPeer, error)

PSListPeers is a helper function used to list pubsub peers

func (*Client) PSPublish

func (c *Client) PSPublish(ctx context.Context, topic string, data []byte) error

PSPublish is a helper function used to publish pubusb messages

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

type Opts

type Opts struct {
	ListenAddress string
	Insecure      bool
}

Opts is used to configure the temporalx grpc client

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL