micro

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BasePrefix    = "wph-micro-base:8081"
	UserPrefix    = "wph-micro-user:8082"
	ProductPrefix = "wph-micro-product:8083"
	OrderPrefix   = "wph-micro-order:8084"
	FlowPrefix    = "wph-micro-flow:8085"
	ReportPrefix  = "wph-micro-report:8086"
	AuthPrefix    = "wph-micro-auth:8087"
)

Variables

View Source
var (
	BaseRPC    = RPCServiceDef{ServiceAddr: "wph-micro-base:10001", MicroServiceName: "wph-micro-base"}
	UserRPC    = RPCServiceDef{ServiceAddr: "wph-micro-user:10002", MicroServiceName: "wph-micro-user"}
	ProductRPC = RPCServiceDef{ServiceAddr: "wph-micro-product:10003", MicroServiceName: "wph-micro-product"}
	OrderRPC   = RPCServiceDef{ServiceAddr: "wph-micro-order:10004", MicroServiceName: "wph-micro-order"}
	FlowRPC    = RPCServiceDef{ServiceAddr: "wph-micro-flow:10005", MicroServiceName: "wph-micro-flow"}
	ReportRPC  = RPCServiceDef{ServiceAddr: "wph-micro-report:10006", MicroServiceName: "wph-micro-report"}
	AuthRPC    = RPCServiceDef{ServiceAddr: "wph-micro-auth:10007", MicroServiceName: "wph-micro-auth"}
)

Functions

func Auth

func Auth(path string) string

func Base

func Base(path string) string

func CreateHttpSpan

func CreateHttpSpan(req *http.Request) (context.Context, opentracing.Span, map[string]string)

创建HTTP span

func CreateRPCClientSpan

func CreateRPCClientSpan(ctx context.Context, operationName string, info *RPCServiceDef) (context.Context, opentracing.Span, map[string]string)

创建RPC客户端span

func CreateRPCServerSpan

func CreateRPCServerSpan(ctx context.Context, operationName string) (context.Context, opentracing.Span, map[string]string)

创建RPC服务端span

func Flow

func Flow(path string) string

func Order

func Order(path string) string

func Product

func Product(path string) string

func Report

func Report(path string) string

func User

func User(path string) string

Types

type ErrTracing

type ErrTracing struct {
	// contains filtered or unexported fields
}

预定义错误类型等

func (ErrTracing) Error

func (e ErrTracing) Error() string

type NilArg

type NilArg interface{}

服务端

type RPCClient

type RPCClient struct {
	client.XClient

	Ctx context.Context
	// contains filtered or unexported fields
}

客户端

func NewAuthClient

func NewAuthClient(ctx context.Context, serviceName string) *RPCClient

func NewBaseClient

func NewBaseClient(ctx context.Context, serviceName string) *RPCClient

func NewFlowClient

func NewFlowClient(ctx context.Context, serviceName string) *RPCClient

func NewOrderClient

func NewOrderClient(ctx context.Context, serviceName string) *RPCClient

func NewProductClient

func NewProductClient(ctx context.Context, serviceName string) *RPCClient

func NewRPCClient

func NewRPCClient(ctx context.Context, serverAddr string, serviceName string) *RPCClient

新建客户端实例

func NewReportClient

func NewReportClient(ctx context.Context, serviceName string) *RPCClient

func NewUserClient

func NewUserClient(ctx context.Context, serviceName string) *RPCClient

func (*RPCClient) Broadcast

func (c *RPCClient) Broadcast(serviceMethod string, args interface{}, reply interface{}) error

广播请求

func (*RPCClient) Call

func (c *RPCClient) Call(serviceMethod string, args interface{}, reply interface{}) error

同步发送请求

func (*RPCClient) Close

func (c *RPCClient) Close() error

关闭客户端

func (*RPCClient) Go

func (c *RPCClient) Go(serviceMethod string, args interface{}, reply interface{}, done chan *client.Call) (*client.Call, error)

异步发送请求

func (*RPCClient) SendFile

func (c *RPCClient) SendFile(serviceMethod string, fileName string, rateInBytesPerSecond int64) error

发送文件

func (*RPCClient) SendRaw

func (c *RPCClient) SendRaw(serviceMethod string, r *protocol.Message) (map[string]string, []byte, error)

发送原始消息

type RPCServer

type RPCServer struct {
	server.Server
	// contains filtered or unexported fields
}

func NewRPCServer

func NewRPCServer(fns ...ServerFn) *RPCServer

新建服务端实例

func (*RPCServer) Serve

func (s *RPCServer) Serve(network, address string) (err error)

type RPCServiceDef

type RPCServiceDef struct {
	ServiceAddr      string
	MicroServiceName string
	RPCServiceName   string
}

type ServerFn

type ServerFn func(*RPCServer)

func SetRPCServerLogger

func SetRPCServerLogger(l *logger.Logger) ServerFn

type ServerPlugin

type ServerPlugin struct {
}

func (*ServerPlugin) PostWriteResponse

func (p *ServerPlugin) PostWriteResponse(ctx context.Context, req *protocol.Message, res *protocol.Message, err error) error

type TracingWrapper

type TracingWrapper struct {
	Span opentracing.Span
}

func GetTracingWrapper

func GetTracingWrapper(ctx context.Context) *TracingWrapper

func GetTracingWrapperWithName

func GetTracingWrapperWithName(ctx context.Context, spanName string) *TracingWrapper

func (*TracingWrapper) Finish

func (c *TracingWrapper) Finish()

func (*TracingWrapper) Log

func (c *TracingWrapper) Log(msg string)

func (*TracingWrapper) LogError

func (c *TracingWrapper) LogError(err error)

func (*TracingWrapper) LogFields

func (c *TracingWrapper) LogFields(fields ...otlog.Field)

func (*TracingWrapper) LogKV

func (c *TracingWrapper) LogKV(alternatingKeyValues ...interface{})

span.LogKV(

"event", "soft error",
"type", "cache timeout",
"waited.millis", 1500)

Jump to

Keyboard shortcuts

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