Documentation ¶
Index ¶
- Constants
- Variables
- func FromContext(ctx context.Context) (md metadata.Metadata)
- func NewContext(md map[string]string, timeout int) context.Context
- type Discovery
- type GoRPC
- type GoRPCClient
- func (c *GoRPCClient) Call(ctx context.Context, req client.Request, rsp interface{}, ...) error
- func (c *GoRPCClient) Init(opts ...client.Option) error
- func (c *GoRPCClient) NewMessage(topic string, msg interface{}, opts ...client.MessageOption) client.Message
- func (c *GoRPCClient) NewRequest(service, endpoint string, req interface{}, reqOpts ...client.RequestOption) client.Request
- func (c *GoRPCClient) Options() client.Options
- func (c *GoRPCClient) Publish(ctx context.Context, msg client.Message, opts ...client.PublishOption) error
- func (c *GoRPCClient) Stream(ctx context.Context, req client.Request, opts ...client.CallOption) (client.Stream, error)
- func (c *GoRPCClient) String() string
- type GoRPCServer
- func (s *GoRPCServer) Close() error
- func (s *GoRPCServer) Handle(h server.Handler) error
- func (s *GoRPCServer) Init(opts ...server.Option) error
- func (s *GoRPCServer) NewHandler(h interface{}, opts ...server.HandlerOption) server.Handler
- func (s *GoRPCServer) NewSubscriber(topic string, sb interface{}, opts ...server.SubscriberOption) server.Subscriber
- func (s *GoRPCServer) Options() server.Options
- func (s *GoRPCServer) Start() error
- func (s *GoRPCServer) Stop() error
- func (s *GoRPCServer) String() string
- func (s *GoRPCServer) Subscribe(subscriber server.Subscriber) error
- type RegistryType
Constants ¶
View Source
const ( DISCOVERY_DEFAULT_INTERVAL = 3 DISCOVERY_DEFAULT_TTL = 10 DEFAULT_RPC_TIMEOUT = 30 )
Variables ¶
View Source
var (
DefaultMaxMsgSize = 512 * 1024 * 1024 //default allow 512 MiB data transport
)
Functions ¶
func FromContext ¶
FromContext get metadata from context
Types ¶
type Discovery ¶
type Discovery struct { ServiceName string // register service name [required] RpcAddr string // register server RPC address [required] Interval int // register interval default 3 seconds [optional] TTL int // register TTL default 10 seconds [optional] Endpoints []string // register endpoints of etcd/consul/zookeeper eg. ["192.168.0.10:2379","192.168.0.11:2379"] }
type GoRPC ¶
type GoRPC struct {
// contains filtered or unexported fields
}
func NewGoRPC ¶
func NewGoRPC(registryType RegistryType, maxSize ...int) (g *GoRPC)
sizes: max send or receive msg size in byte
func (*GoRPC) NewClient ¶
func (g *GoRPC) NewClient(endPoints ...string) (c *GoRPCClient)
NewClient new a go-micro client
func (*GoRPC) NewServer ¶
func (g *GoRPC) NewServer(discovery *Discovery) (s *GoRPCServer)
NewServer new a go-micro server
type GoRPCClient ¶
type GoRPCClient struct {
// contains filtered or unexported fields
}
func (*GoRPCClient) Call ¶
func (c *GoRPCClient) Call(ctx context.Context, req client.Request, rsp interface{}, opts ...client.CallOption) error
func (*GoRPCClient) NewMessage ¶
func (c *GoRPCClient) NewMessage(topic string, msg interface{}, opts ...client.MessageOption) client.Message
func (*GoRPCClient) NewRequest ¶
func (c *GoRPCClient) NewRequest(service, endpoint string, req interface{}, reqOpts ...client.RequestOption) client.Request
func (*GoRPCClient) Options ¶
func (c *GoRPCClient) Options() client.Options
func (*GoRPCClient) Publish ¶
func (c *GoRPCClient) Publish(ctx context.Context, msg client.Message, opts ...client.PublishOption) error
func (*GoRPCClient) Stream ¶
func (c *GoRPCClient) Stream(ctx context.Context, req client.Request, opts ...client.CallOption) (client.Stream, error)
func (*GoRPCClient) String ¶
func (c *GoRPCClient) String() string
type GoRPCServer ¶
type GoRPCServer struct {
// contains filtered or unexported fields
}
func (*GoRPCServer) Close ¶
func (s *GoRPCServer) Close() error
func (*GoRPCServer) Handle ¶
func (s *GoRPCServer) Handle(h server.Handler) error
Register a handler
func (*GoRPCServer) Init ¶
func (s *GoRPCServer) Init(opts ...server.Option) error
Initialise options
func (*GoRPCServer) NewHandler ¶
func (s *GoRPCServer) NewHandler(h interface{}, opts ...server.HandlerOption) server.Handler
Create a new handler
func (*GoRPCServer) NewSubscriber ¶
func (s *GoRPCServer) NewSubscriber(topic string, sb interface{}, opts ...server.SubscriberOption) server.Subscriber
Create a new subscriber
func (*GoRPCServer) Subscribe ¶
func (s *GoRPCServer) Subscribe(subscriber server.Subscriber) error
Register a subscriber
type RegistryType ¶
type RegistryType int
const ( RegistryType_MDNS RegistryType = 0 // multicast DNS RegistryType_ETCD RegistryType = 1 // etcd )
func ParseRegistry ¶ added in v2.1.0
func ParseRegistry(strRegistry string) (typ RegistryType, endpoints []string)
"etcd://192.168.1.108:2379,192.168.1.109:2379" "consul://192.168.1.108:8500,192.168.1.109:8500" "zk://192.168.1.108:2181, 192.168.1.109:2181"
func (RegistryType) String ¶
func (t RegistryType) String() string
Click to show internal directories.
Click to hide internal directories.