Documentation
¶
Index ¶
- func NewGetHTTPHandle(factory func(echo.Context) (interface{}, error), ...) func(echo.Context) error
- func NewJSONBodyHTTPHandle(factory func() interface{}, handler func(interface{}) (*JSONResult, error)) func(echo.Context) error
- func ReadJSONFromBody(ctx echo.Context, value interface{}) error
- type API
- type APIEntrypoint
- type ClientCreator
- type ClientOption
- type GRPCClient
- type GRPCServer
- type JSONResult
- type Publisher
- type ServerOption
- type Service
- type ServiceOption
- type ServiceRegister
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
ReadJSONFromBody read json body
Types ¶
type APIEntrypoint ¶
type APIEntrypoint struct {
GET, PUT, DELETE, POST string
}
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 ¶
GRPCClient is a grpc client
func NewGRPCClient ¶
func NewGRPCClient(creator ClientCreator, opts ...ClientOption) *GRPCClient
NewGRPCClient returns a GRPC Client
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
type JSONResult ¶
type JSONResult struct { Code int `json:"code"` Data interface{} `json:"data"` }
JSONResult json result
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 ServiceRegister ¶
ServiceRegister registry grpc services