Documentation ¶
Index ¶
- Constants
- Variables
- func FromContext(ctx context.Context) (md metadata.Metadata)
- func NewContext(md map[string]string) context.Context
- func NewContextWithTimeout(md map[string]string, timeout int) (context.Context, context.CancelFunc)
- 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
- func (s *GoRPCServer) Weight() int
- type RegistryType
- type ServerOption
Constants ¶
View Source
const ( DISCOVERY_DEFAULT_INTERVAL = 3 DISCOVERY_DEFAULT_TTL = 10 DEFAULT_RPC_TIMEOUT = 30 LOAD_BALANCE_KEY_WEIGTHT = "gomicro.LoadBalanceWeight" )
Variables ¶
View Source
var (
DefaultMaxMsgSize = 512 * 1024 * 1024 //default allow 512 MiB data transport
)
Functions ¶
func FromContext ¶
FromContext get metadata from context
func NewContext ¶
NewContext md -> metadata of RPC call, set to nil if have no any meta-data
func NewContextWithTimeout ¶ added in v2.2.0
NewContextWithTimeout md -> metadata of RPC call, set to nil if have no any meta-data timeout -> timeout seconds of RPC call
Types ¶
type GoRPC ¶
type GoRPC struct {
// contains filtered or unexported fields
}
func (*GoRPC) NewClient ¶
func (g *GoRPC) NewClient(endPoints ...string) (c *GoRPCClient)
NewClient new a go-micro client
type GoRPCClient ¶
type GoRPCClient struct {
// contains filtered or unexported fields
}
func NewClient ¶ added in v2.2.0
func NewClient(strRegistry string) (c *GoRPCClient)
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 NewServer ¶ added in v2.2.0
func NewServer(strRegistry string, option *ServerOption) (s *GoRPCServer)
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
func (*GoRPCServer) Weight ¶ added in v2.6.1
func (s *GoRPCServer) Weight() int
Server weight of load balance
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
type ServerOption ¶ added in v2.2.0
type ServerOption 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] Weight int // server weight of load balance [optional] Metadata map[string]string // register node metadata [optional] }
Click to show internal directories.
Click to hide internal directories.