Documentation
¶
Index ¶
- Constants
- Variables
- func SNBase62[T utils.IntType](id T) string
- func ServiceMethod(m string) (string, string, error)
- type Handler
- func (handler *Handler) BuildArgs(ctx context.Context, protocol string, query url.Values, body []byte) (context.Context, []reflect.Value, error)
- func (handler *Handler) Hook(ctx context.Context, query url.Values, body []byte) (context.Context, error)
- func (handler *Handler) Match(request, response string) bool
- func (handler *Handler) UrlPath() (resource, path, method string)
- type Option
- func WithBroker(broker broker.Broker) Option
- func WithBrokerOpts(options []broker.SubscribeOption) Option
- func WithComponents(components ...micro.Component) Option
- func WithCredentials(credentials credentials.TransportCredentials) Option
- func WithGrpcOptions(opts ...grpc.ServerOption) Option
- func WithListener(listener net.Listener) Option
- func WithMax(version *micro.Version) Option
- func WithMaxMsgSize(size int) Option
- func WithMetadata(md map[string]string) Option
- func WithMin(version *micro.Version) Option
- func WithName(name string) Option
- func WithRegisterCheck(f func(context.Context) error) Option
- func WithRegisterCheckInterval(seconds time.Duration) Option
- func WithRegistry(registry micro.Registry) Option
- func WithServerId(id uint64) Option
- func WithVersion(version *micro.Version) Option
- func WithWaitGroup(wg *sync.WaitGroup) Option
- type Options
- type RPCServer
- func (g *RPCServer) Call(ctx context.Context, msg *tp.Message) (*tp.Message, error)
- func (g *RPCServer) Deregister(ctx context.Context) error
- func (g *RPCServer) Register(ctx context.Context) error
- func (g *RPCServer) Start() error
- func (g *RPCServer) Stop() error
- func (g *RPCServer) Stream(stream tp.Transport_StreamServer) error
- type Service
Constants ¶
View Source
const (
HandlerScope = "micro/server/handler"
)
View Source
const (
MaxServerSN = 62*62*62 - 1
)
Variables ¶
View Source
var ( // DefaultMaxMsgSize define maximum message size that server can send // or receive. Default value is 4MB. DefaultMaxMsgSize = 1024 * 1024 * 4 )
Functions ¶
Types ¶
type Handler ¶
type Handler struct {
Resource string // resource name
Collection string // collection name
Name string // method name
Rtype reflect.Type // 结构体
Receiver reflect.Value // receiver of method
Method reflect.Method // method stub
Query reflect.Type // 请求url query pram参数校验器
Request reflect.Type // 请求参数
QueryValidator *gojsonschema.Schema // 请求参数校验器
BodyValidator *gojsonschema.Schema // 请求载荷校验器
Response reflect.Type // 返回参数
Metadata map[string]string // 元数据
Internal bool // 内部rpc,不对外, 文档接口与http api需要屏蔽
Hooks []micro.PreExecuteHook // 执行前
}
func ExtractComponent ¶
ExtractComponent 解析组件 返回的map是rpcserver可用穿透的Handlers(可用网关代理) 返回的列表是所有Handlers
func ExtractComponents ¶
ExtractComponents 解析组件 返回的map是rpcserver可用穿透的Handlers(可用网关代理) 返回的列表是所有Handlers
func (*Handler) BuildArgs ¶
func (handler *Handler) BuildArgs(ctx context.Context, protocol string, query url.Values, body []byte) (context.Context, []reflect.Value, error)
BuildArgs rpc转发将请求转数据转化为反射调用参数
type Option ¶
type Option func(*Options)
func WithBroker ¶
func WithBrokerOpts ¶
func WithBrokerOpts(options []broker.SubscribeOption) Option
func WithComponents ¶
func WithCredentials ¶
func WithCredentials(credentials credentials.TransportCredentials) Option
WithCredentials 设置证书
func WithGrpcOptions ¶
func WithGrpcOptions(opts ...grpc.ServerOption) Option
func WithListener ¶
func WithMaxMsgSize ¶
func WithMetadata ¶
WithMetadata associated with the server
func WithRegistry ¶
func WithServerId ¶
func WithVersion ¶
func WithWaitGroup ¶
type Options ¶
type Options struct {
Id uint64
Name string
MaxMsgSize int
Version *micro.Version // 当前服务版本号
Min *micro.Version // 支持的最小版本(默认当前版本)
Max *micro.Version // 支持的最大版本(默认当前版本)
Interval time.Duration
Listener net.Listener
Broker broker.Broker
Registry micro.Registry
Components []micro.Component
GrpcOpts []grpc.ServerOption
BrokerOpts []broker.SubscribeOption
RegisterCheck func(context.Context) error
WaitGroup *sync.WaitGroup
Metadata map[string]string
Credentials credentials.TransportCredentials
}
func NewOptions ¶
type RPCServer ¶
type RPCServer struct {
tp.UnimplementedTransportServer
sync.RWMutex
// contains filtered or unexported fields
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) UnsubscribeAll ¶
Click to show internal directories.
Click to hide internal directories.