client

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2020 License: Apache-2.0, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(net Network) *Client

func (*Client) HandleProviderResponse

func (c *Client) HandleProviderResponse(msg []byte)

HandleProviderResponse is called to handle a QueryResponse from a provider

func (*Client) HandleProviderStream

func (c *Client) HandleProviderStream(s network.Stream)

HandleProviderStream reads the first message and calls HandleProviderResponse Note: implements the libp2p StreamHandler interface

func (*Client) Start

func (c *Client) Start() error

Start starts the client's network

func (*Client) Stop

func (c *Client) Stop() error

Stop stops the client's network

func (*Client) SubmitQuery

func (c *Client) SubmitQuery(ctx context.Context, params shared.Params) error

SubmitQuery encodes a query and submits it to the network to be gossiped

func (*Client) SubscribeToQueryResponses

func (c *Client) SubscribeToQueryResponses(subscriber ClientSubscriber, params shared.Params) Unsubscribe

SubscribeQueryResponses registers a subscriber as a listener for a specific payload CID. It returns an unsubscribe method that can be called to terminate the subscription.

type ClientSubscriber

type ClientSubscriber func(resp shared.QueryResponse)

type Network

type Network interface {
	Start() error
	Stop() error

	// Publish broadcasts a message over pub sub on the default topic
	Publish(ctx context.Context, msg []byte) error
	// Returns all the hosts multiaddrs
	MultiAddrs() []string

	RegisterStreamHandler(id core.ProtocolID, handler network.StreamHandler)
}

Network defines the libp2p network interface used by the client

type Unsubscribe

type Unsubscribe func()

Jump to

Keyboard shortcuts

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