api

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: Apache-2.0 Imports: 19 Imported by: 2

Documentation

Overview

Package api is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterRpcNodeHandler

func RegisterRpcNodeHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterRpcNodeHandler registers the http handlers for service RpcNode to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterRpcNodeHandlerClient

func RegisterRpcNodeHandlerClient(ctx context.Context, mux *runtime.ServeMux, client RpcNodeClient) error

RegisterRpcNodeHandlerClient registers the http handlers for service RpcNode to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "RpcNodeClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "RpcNodeClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "RpcNodeClient" to call the correct interceptors.

func RegisterRpcNodeHandlerFromEndpoint

func RegisterRpcNodeHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterRpcNodeHandlerFromEndpoint is same as RegisterRpcNodeHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterRpcNodeHandlerServer

func RegisterRpcNodeHandlerServer(ctx context.Context, mux *runtime.ServeMux, server RpcNodeServer) error

RegisterRpcNodeHandlerServer registers the http handlers for service RpcNode to "mux". UnaryRPC :call RpcNodeServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterRpcNodeHandlerFromEndpoint instead.

func RegisterRpcNodeServer

func RegisterRpcNodeServer(s *grpc.Server, srv RpcNodeServer)

Types

type RpcNodeClient

type RpcNodeClient interface {
	// processing transaction message requests
	SendRequest(ctx context.Context, in *common.TxRequest, opts ...grpc.CallOption) (*common.TxResponse, error)
	// processing requests for message subscription
	Subscribe(ctx context.Context, in *common.TxRequest, opts ...grpc.CallOption) (RpcNode_SubscribeClient, error)
	// processing requests for message subscription by websocket
	SubscribeWS(ctx context.Context, in *common.RawTxRequest, opts ...grpc.CallOption) (RpcNode_SubscribeWSClient, error)
	// update debug status (development debugging)
	UpdateDebugConfig(ctx context.Context, in *config.DebugConfigRequest, opts ...grpc.CallOption) (*config.DebugConfigResponse, error)
	// refreshLogLevelsConfig
	RefreshLogLevelsConfig(ctx context.Context, in *config.LogLevelsRequest, opts ...grpc.CallOption) (*config.LogLevelsResponse, error)
	// get Herbt version
	GetHerbtVersion(ctx context.Context, in *config.HerbtVersionRequest, opts ...grpc.CallOption) (*config.HerbtVersionResponse, error)
	// check chain configuration and load new chain dynamically
	CheckNewBlockChainConfig(ctx context.Context, in *config.CheckNewBlockChainConfigRequest, opts ...grpc.CallOption) (*config.CheckNewBlockChainConfigResponse, error)
	// GetPoolStatus Returns the max size of config transaction pool and common transaction pool,
	// the num of config transaction in queue and pendingCache,
	// and the the num of common transaction in queue and pendingCache.
	GetPoolStatus(ctx context.Context, in *txpool.GetPoolStatusRequest, opts ...grpc.CallOption) (*txpool.TxPoolStatus, error)
	// GetTxIdsByTypeAndStage Returns config or common txIds in different stage.
	// TxType may be TxType_CONFIG_TX, TxType_COMMON_TX, (TxType_CONFIG_TX|TxType_COMMON_TX)
	// TxStage may be TxStage_IN_QUEUE, TxStage_IN_PENDING, (TxStage_IN_QUEUE|TxStage_IN_PENDING)
	GetTxIdsByTypeAndStage(ctx context.Context, in *txpool.GetTxIdsByTypeAndStageRequest, opts ...grpc.CallOption) (*txpool.GetTxIdsByTypeAndStageResponse, error)
	// GetTxsInPoolByTxIds Retrieve the transactions by the txIds from the txPool,
	// return transactions in the txPool and txIds not in txPool.
	// default query upper limit is 1w transaction, and error is returned if the limit is exceeded.
	GetTxsInPoolByTxIds(ctx context.Context, in *txpool.GetTxsInPoolByTxIdsRequest, opts ...grpc.CallOption) (*txpool.GetTxsInPoolByTxIdsResponse, error)
}

RpcNodeClient is the client API for RpcNode service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewRpcNodeClient

func NewRpcNodeClient(cc *grpc.ClientConn) RpcNodeClient

type RpcNodeServer

type RpcNodeServer interface {
	// processing transaction message requests
	SendRequest(context.Context, *common.TxRequest) (*common.TxResponse, error)
	// processing requests for message subscription
	Subscribe(*common.TxRequest, RpcNode_SubscribeServer) error
	// processing requests for message subscription by websocket
	SubscribeWS(*common.RawTxRequest, RpcNode_SubscribeWSServer) error
	// update debug status (development debugging)
	UpdateDebugConfig(context.Context, *config.DebugConfigRequest) (*config.DebugConfigResponse, error)
	// refreshLogLevelsConfig
	RefreshLogLevelsConfig(context.Context, *config.LogLevelsRequest) (*config.LogLevelsResponse, error)
	// get Herbt version
	GetHerbtVersion(context.Context, *config.HerbtVersionRequest) (*config.HerbtVersionResponse, error)
	// check chain configuration and load new chain dynamically
	CheckNewBlockChainConfig(context.Context, *config.CheckNewBlockChainConfigRequest) (*config.CheckNewBlockChainConfigResponse, error)
	// GetPoolStatus Returns the max size of config transaction pool and common transaction pool,
	// the num of config transaction in queue and pendingCache,
	// and the the num of common transaction in queue and pendingCache.
	GetPoolStatus(context.Context, *txpool.GetPoolStatusRequest) (*txpool.TxPoolStatus, error)
	// GetTxIdsByTypeAndStage Returns config or common txIds in different stage.
	// TxType may be TxType_CONFIG_TX, TxType_COMMON_TX, (TxType_CONFIG_TX|TxType_COMMON_TX)
	// TxStage may be TxStage_IN_QUEUE, TxStage_IN_PENDING, (TxStage_IN_QUEUE|TxStage_IN_PENDING)
	GetTxIdsByTypeAndStage(context.Context, *txpool.GetTxIdsByTypeAndStageRequest) (*txpool.GetTxIdsByTypeAndStageResponse, error)
	// GetTxsInPoolByTxIds Retrieve the transactions by the txIds from the txPool,
	// return transactions in the txPool and txIds not in txPool.
	// default query upper limit is 1w transaction, and error is returned if the limit is exceeded.
	GetTxsInPoolByTxIds(context.Context, *txpool.GetTxsInPoolByTxIdsRequest) (*txpool.GetTxsInPoolByTxIdsResponse, error)
}

RpcNodeServer is the server API for RpcNode service.

type RpcNode_SubscribeClient

type RpcNode_SubscribeClient interface {
	Recv() (*common.SubscribeResult, error)
	grpc.ClientStream
}

type RpcNode_SubscribeServer

type RpcNode_SubscribeServer interface {
	Send(*common.SubscribeResult) error
	grpc.ServerStream
}

type RpcNode_SubscribeWSClient

type RpcNode_SubscribeWSClient interface {
	Recv() (*common.SubscribeResult, error)
	grpc.ClientStream
}

type RpcNode_SubscribeWSServer

type RpcNode_SubscribeWSServer interface {
	Send(*common.SubscribeResult) error
	grpc.ServerStream
}

type UnimplementedRpcNodeServer

type UnimplementedRpcNodeServer struct {
}

UnimplementedRpcNodeServer can be embedded to have forward compatible implementations.

func (*UnimplementedRpcNodeServer) GetHerbtVersion

func (*UnimplementedRpcNodeServer) GetPoolStatus

func (*UnimplementedRpcNodeServer) GetTxsInPoolByTxIds

func (*UnimplementedRpcNodeServer) RefreshLogLevelsConfig

func (*UnimplementedRpcNodeServer) SendRequest

func (*UnimplementedRpcNodeServer) Subscribe

func (*UnimplementedRpcNodeServer) SubscribeWS

func (*UnimplementedRpcNodeServer) UpdateDebugConfig

Jump to

Keyboard shortcuts

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