Documentation ¶
Index ¶
- Constants
- Variables
- func HookMiddlewares(provider *providers.MiddlewarableProvider, url, space string, ...)
- func HookRedirectHttpHeader()
- func MustInit()
- func MustNewCfxClient(url string, options ...ClientOption) *sdk.Client
- func MustNewCfxClientsFromViper(options ...ClientOption) (clients []*sdk.Client)
- func MustNewEthClient(url string, options ...ClientOption) *web3go.Client
- func MustNewEthClientsFromViper(options ...ClientOption) (clients []*web3go.Client)
- func NewCfxClient(url string, options ...ClientOption) (*sdk.Client, error)
- func NewEthClient(url string, options ...ClientOption) (*web3go.Client, error)
- func Url2NodeName(url string) string
- type ClientOption
- func WithCircuitBreaker(maxFail int, failTimeWindow, openColdTime time.Duration) ClientOption
- func WithClientHookCache(hook bool) ClientOption
- func WithClientHookMetrics(hook bool) ClientOption
- func WithClientMaxConnsPerHost(maxConns int) ClientOption
- func WithClientRequestTimeout(reqTimeout time.Duration) ClientOption
- func WithClientRetryCount(retry int) ClientOption
- func WithClientRetryInterval(retryInterval time.Duration) ClientOption
- type ClientOptioner
- type MiddlewareHookFlag
- type Protocol
- type Server
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, flags ...MiddlewareHookFlag)
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 MustNewCfxClient ¶
func MustNewCfxClient(url string, options ...ClientOption) *sdk.Client
func MustNewCfxClientsFromViper ¶
func MustNewCfxClientsFromViper(options ...ClientOption) (clients []*sdk.Client)
func MustNewEthClient ¶
func MustNewEthClient(url string, options ...ClientOption) *web3go.Client
func MustNewEthClientsFromViper ¶
func MustNewEthClientsFromViper(options ...ClientOption) (clients []*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 ¶
Types ¶
type ClientOption ¶
type ClientOption func(opt ClientOptioner)
func WithCircuitBreaker ¶
func WithCircuitBreaker(maxFail int, failTimeWindow, openColdTime time.Duration) ClientOption
func WithClientHookCache ¶
func WithClientHookCache(hook bool) 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) SetHookCache(hook bool) SetCircuitBreaker(maxFail int, failTimeWindow, openColdTime time.Duration) }
type MiddlewareHookFlag ¶
type MiddlewareHookFlag int
MiddlewareHookFlag represents the type for middleware hook flags.
const ( // MiddlewareHookNone represents no middleware hooks enabled. MiddlewareHookNone MiddlewareHookFlag = 0 // MiddlewareHookAll enables all middleware hooks. MiddlewareHookAll MiddlewareHookFlag = ^MiddlewareHookFlag(0) // MiddlewareHookLog enables logging middleware hook. MiddlewareHookLog MiddlewareHookFlag = 1 << iota // MiddlewareHookLogMetrics enables metrics logging middleware hook. MiddlewareHookLogMetrics // MiddlewareHookCache enables cache middleware hook. MiddlewareHookCache )
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.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.