Documentation
¶
Index ¶
- Constants
- Variables
- func SNBase62[T utils.IntType](id T) string
- func ServiceMethod(m string) (string, string, error)
- type Handler
- type Option
- func WithBroker(broker broker.Broker) Option
- func WithBrokerOpts(options []broker.SubscribeOption) Option
- func WithComponents(components ...micro.Component) 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
- type Service
Constants ¶
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,不对外 Hooks []micro.PreExecuteHook // 执行前 }
func ExtractComponent ¶
ExtractComponent 解析组件 返回的map是可以走网关的Handlers 返回的列表是所有Handlers
func ExtractComponents ¶
func (*Handler) BuildArgs ¶
func (handler *Handler) BuildArgs(ctx context.Context, protocol string, query url.Values, body []byte) ([]reflect.Value, error)
BuildArgs rpc转发将请求转数据转化为反射调用参数
type Option ¶
type Option func(*Options)
func WithBroker ¶
func WithBrokerOpts ¶
func WithBrokerOpts(options []broker.SubscribeOption) Option
func WithComponents ¶
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 { //Broker broker.DefaultBroker, Id uint32 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 }
func NewOptions ¶
type RPCServer ¶
type RPCServer struct { tp.UnimplementedTransportServer sync.RWMutex // contains filtered or unexported fields }
func (*RPCServer) Deregister ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) SubscriberAll ¶
func (*Service) UnsubscribeAll ¶
Click to show internal directories.
Click to hide internal directories.