rpcinterface

package
v0.0.0-...-a4d8579 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: Apache-2.0 Imports: 4 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 interface {
	NewRequest(service ServiceType, rpcEndpoint Endpoint, opt interface{}) (*Request, error)
	Do(req *Request, v interface{}) (*http.Response, error) // @TODO probably need wrapped/generic response? Not back compat though
	SetBaseURL(url *url.URL) error
	SetCacheValidTime(validTime time.Duration)

	// SubscribeSelf subscribes to responses to requests from this service
	SubscribeSelf() error
	// Subscribe adds a subscription to events from a particular service
	Subscribe(service string) error
	// ListenSync Listens for async responses over the connection in a synchronous fashion, blocking anything else
	ListenSync(handler WebsocketResponseHandler) error
}

Client defines the interface for a client HTTP (standard RPC) and websockets are the two supported now

type ClientOptionFunc

type ClientOptionFunc func(client Client) error

ClientOptionFunc can be used to customize a new RPC client.

type Endpoint

type Endpoint string

Endpoint represents and RPC Method

type Request

type Request struct {
	Service  ServiceType
	Endpoint Endpoint
	Data     interface{}
	Request  *http.Request
}

Request is a wrapped http.Request that indicates the service we're making the RPC call to

type ServiceType

type ServiceType uint8

ServiceType is a type that refers to a particular service

const (
	// ServiceDaemon the daemon
	ServiceDaemon ServiceType = iota

	// ServiceFullNode the full node service
	ServiceFullNode

	// ServiceFarmer the farmer service
	ServiceFarmer

	// ServiceHarvester the harvester service
	ServiceHarvester

	// ServiceWallet the wallet service
	ServiceWallet

	// ServiceTimelord is the timelord service
	ServiceTimelord

	// ServicePeer full node service, but for communicating with full nodes using the public protocol
	ServicePeer

	// ServiceCrawler crawler service
	ServiceCrawler
)

type WebsocketResponseHandler

type WebsocketResponseHandler func(*types.WebsocketResponse, error)

WebsocketResponseHandler is a function that is called to process a received websocket response

Jump to

Keyboard shortcuts

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