package module
Version: v1.1.0 Latest Latest

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

Go to latest
Published: Nov 28, 2018 License: Apache-2.0 Imports: 18 Imported by: 9



grpcx is a wapper for grpc.




This section is empty.


This section is empty.


func NewGetHTTPHandle

func NewGetHTTPHandle(factory func(echo.Context) (interface{}, error), handler func(interface{}) (*JSONResult, error)) func(echo.Context) error

NewGetHTTPHandle return get http handle

func NewJSONBodyHTTPHandle

func NewJSONBodyHTTPHandle(factory func() interface{}, handler func(interface{}) (*JSONResult, error)) func(echo.Context) error

NewJSONBodyHTTPHandle returns a http handle JSON body

func ReadJSONFromBody

func ReadJSONFromBody(ctx echo.Context, value interface{}) error

ReadJSONFromBody read json body


type API

type API struct {
	Name string
	HTTP APIEntrypoint

API api

type APIEntrypoint

type APIEntrypoint struct {

APIEntrypoint api http entrypoint

type ClientCreator

type ClientCreator func(string, *grpc.ClientConn) interface{}

ClientCreator create a grpc client

type ClientOption

type ClientOption func(*clientOptions)

ClientOption is client create option

func WithDirectAddresses

func WithDirectAddresses(addrs ...string) ClientOption

WithDirectAddresses returns a direct addresses option

func WithEtcdServiceDiscovery

func WithEtcdServiceDiscovery(prefix string, client *clientv3.Client) ClientOption

WithEtcdServiceDiscovery returns a etcd discovery option

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

WithTimeout returns a timeout option

type GRPCClient

type GRPCClient struct {
	// contains filtered or unexported fields

GRPCClient is a grpc client

func NewGRPCClient

func NewGRPCClient(creator ClientCreator, opts ...ClientOption) *GRPCClient

NewGRPCClient returns a GRPC Client

func (*GRPCClient) Close

func (c *GRPCClient) Close() error

Close close

func (*GRPCClient) GetServiceClient

func (c *GRPCClient) GetServiceClient(name string) (interface{}, error)

GetServiceClient returns a grpc client

type GRPCServer

type GRPCServer struct {
	// contains filtered or unexported fields

GRPCServer is a grpc server

func NewGRPCServer

func NewGRPCServer(addr string, register ServiceRegister, opts ...ServerOption) *GRPCServer

NewGRPCServer returns a grpc server

func (*GRPCServer) GracefulStop

func (s *GRPCServer) GracefulStop()

GracefulStop stop the grpc server

func (*GRPCServer) Start

func (s *GRPCServer) Start() error

Start start this api server

type JSONResult

type JSONResult struct {
	Code int         `json:"code"`
	Data interface{} `json:"data"`

JSONResult json result

type Publisher

type Publisher interface {
	Publish(service string, meta naming.Update) error

Publisher a service publish

type ServerOption

type ServerOption func(*serverOptions)

ServerOption service side option

func WithEtcdPublisher

func WithEtcdPublisher(client *clientv3.Client, prefix string, ttl int64, timeout time.Duration) ServerOption

WithEtcdPublisher use etcd to publish service

func WithHTTPServer

func WithHTTPServer(addr string, httpSetup func(*echo.Echo)) ServerOption

WithHTTPServer with http server

type Service

type Service struct {
	Name     string
	Metadata interface{}
	// contains filtered or unexported fields

Service is a service define

func NewService

func NewService(name string, metadata interface{}, opts ...ServiceOption) Service

NewService returns a Service

type ServiceOption

type ServiceOption func(*serviceOptions)

ServiceOption service options

type ServiceRegister

type ServiceRegister func(*grpc.Server) []Service

ServiceRegister registry grpc services

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to