rpc

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2018 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterGatewayHandler

func RegisterGatewayHandler(name string, h GatewayHandler)

RegisterGatewayHandler registers a new http gateway handler for gRPC service

func RegisterService

func RegisterService(name string, s Service)

RegisterService registers a new gRPC service

func RegisterServiceWithGatewayHandler

func RegisterServiceWithGatewayHandler(name string, s Service, h GatewayHandler)

RegisterServiceWithGatewayHandler registers a gRPC service with gateway handler

Types

type Config

type Config struct {
	Enabled bool       `mapstructure:"enabled"`
	Address string     `mapstructure:"address"`
	Port    int        `mapstructure:"port"`
	HTTP    HTTPConfig `mapstructure:"http"`
}

Config defines the configurations of rpc server

type GRPCServer

type GRPCServer interface {
	GetChainReader() service.ChainReader
	GetTxHandler() service.TxHandler
	GetEventBus() eventbus.Bus
	Stop()
}

GRPCServer interface breaks cycle import dependency

type GatewayHandler

type GatewayHandler func(context.Context, *runtime.ServeMux, string, []grpc.DialOption) error

GatewayHandler defines the register func of http gateway handler for gRPC service

type HTTPConfig

type HTTPConfig struct {
	Address string `mapstructure:"address"`
	Port    int    `mapstructure:"port"`
}

HTTPConfig defines the address/port of rest api over http

type Server

type Server struct {
	ChainReader service.ChainReader
	TxHandler   service.TxHandler
	// contains filtered or unexported fields
}

Server defines the rpc server

func NewServer

func NewServer(parent goprocess.Process, cfg *Config, cr service.ChainReader, txh service.TxHandler, bus eventbus.Bus) (*Server, error)

NewServer creates a RPC server instance.

func (*Server) GetChainReader

func (s *Server) GetChainReader() service.ChainReader

GetChainReader returns an interface to observe chain state

func (*Server) GetEventBus

func (s *Server) GetEventBus() eventbus.Bus

GetEventBus returns a interface to publish events

func (*Server) GetTxHandler

func (s *Server) GetTxHandler() service.TxHandler

GetTxHandler returns a handler to deal with transactions

func (*Server) Proc

func (s *Server) Proc() goprocess.Process

Proc returns the goprocess

func (*Server) Run

func (s *Server) Run() error

Run gRPC service

func (*Server) Stop

func (s *Server) Stop()

Stop gRPC service

type Service

type Service func(s *Server)

Service defines the grpc service func

Jump to

Keyboard shortcuts

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