rpc

package
v1.3.3-testnet Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolHttp = "HTTP"
	ProtocolWS   = "WS"
)

Variables

View Source
var (
	// DefaultShutdownTimeout is default timeout to shutdown RPC server.
	DefaultShutdownTimeout = 3 * time.Second
)

Functions

func HookMiddlewares

func HookMiddlewares(provider *providers.MiddlewarableProvider, url, space string)

func HookRedirectHttpHeader

func HookRedirectHttpHeader()

HookRedirectHttpHeader registers an event handler before sending client HTTP request, which will forward HTTP headers to the requested RPC service.

func MustInit

func MustInit()

func MustNewCfxClient

func MustNewCfxClient(url string, options ...ClientOption) *sdk.Client

func MustNewCfxClientFromViper

func MustNewCfxClientFromViper(options ...ClientOption) *sdk.Client

func MustNewCfxWsClientFromViper

func MustNewCfxWsClientFromViper(options ...ClientOption) *sdk.Client

func MustNewEthClient

func MustNewEthClient(url string, options ...ClientOption) *web3go.Client

func MustNewEthClientFromViper

func MustNewEthClientFromViper(options ...ClientOption) *web3go.Client

func NewCfxClient

func NewCfxClient(url string, options ...ClientOption) (*sdk.Client, error)

func NewEthClient

func NewEthClient(url string, options ...ClientOption) (*web3go.Client, error)

func Url2NodeName

func Url2NodeName(url string) string

Types

type ClientOption

type ClientOption func(opt ClientOptioner)

func WithCircuitBreaker

func WithCircuitBreaker(maxFail int, failTimeWindow, openColdTime time.Duration) ClientOption

func WithClientHookMetrics

func WithClientHookMetrics(hook bool) ClientOption

func WithClientMaxConnsPerHost

func WithClientMaxConnsPerHost(maxConns int) ClientOption

func WithClientRequestTimeout

func WithClientRequestTimeout(reqTimeout time.Duration) ClientOption

func WithClientRetryCount

func WithClientRetryCount(retry int) ClientOption

func WithClientRetryInterval

func WithClientRetryInterval(retryInterval time.Duration) ClientOption

type ClientOptioner

type ClientOptioner interface {
	SetRetryCount(retry int)
	SetRetryInterval(retryInterval time.Duration)
	SetRequestTimeout(reqTimeout time.Duration)
	SetMaxConnsPerHost(maxConns int)
	SetHookMetrics(hook bool)
	SetCircuitBreaker(maxFail int, failTimeWindow, openColdTime time.Duration)
}

type Protocol

type Protocol string

type Server

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

Server serves JSON RPC services.

func MustNewServer

func MustNewServer(name string, rpcs map[string]interface{}, middlewares ...handlers.Middleware) *Server

MustNewServer creates an instance of Server with specified RPC services.

func (*Server) MustServe

func (s *Server) MustServe(endpoint string, protocol Protocol)

MustServe serves RPC server in blocking way or panics if failed.

func (*Server) MustServeGraceful

func (s *Server) MustServeGraceful(
	ctx context.Context, wg *sync.WaitGroup, endpoint string, protocol Protocol,
)

MustServeGraceful serves RPC server in a goroutine until graceful shutdown.

func (*Server) String

func (s *Server) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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