Versions in this module Expand all Collapse all v1 v1.0.1 Jun 27, 2023 Changes in this version + const Magic + const RandomStrategy + const RoundRobinStrategy + var DefaultOption = Option + var EmptyData = struct{} + type Call struct + Args interface{} + Done chan *Call + Error error + Reply interface{} + Seq uint64 + ServiceMethod string + type Client struct + func Dial(network, address string, opts ...*Option) (client *Client, err error) + func DialHTTP(network, address string, opts ...*Option) (client *Client, err error) + func DialRPC(rpcAddr string, opts ...*Option) (*Client, error) + func NewClient(conn net.Conn, option *Option) (*Client, error) + func NewHTTPClient(conn net.Conn, option *Option) (*Client, error) + func (c *Client) Call(ctx context.Context, serviceMethod string, args, reply interface{}) error + func (c *Client) CheckAvailable() bool + func (c *Client) Close() error + func (c *Client) Go(serviceMethod string, args, reply interface{}, done chan *Call) *Call + type DefaultDiscovery struct + func NewDefaultDiscovery(servers []string) *DefaultDiscovery + func (d *DefaultDiscovery) Get(strategy StrategyMode) (string, error) + func (d *DefaultDiscovery) GetAll() ([]string, error) + func (d *DefaultDiscovery) Refresh() error + func (d *DefaultDiscovery) Update(servers []string) error + type Discovery interface + Get func(strategy StrategyMode) (string, error) + GetAll func() ([]string, error) + Refresh func() error + Update func(servers []string) error + type Option struct + CodecType codec.Type + ConnectTimeOut time.Duration + HandleTimeOut time.Duration + Magic int + type RegistryDiscovery struct + func NewRegistryDiscovery(registryAddr string, timeout time.Duration) *RegistryDiscovery + func (rd *RegistryDiscovery) Get(strategy StrategyMode) (string, error) + func (rd *RegistryDiscovery) GetAll() ([]string, error) + func (rd *RegistryDiscovery) Refresh() error + func (rd *RegistryDiscovery) Update(servers []string) error + type Server struct + func NewServer() *Server + func (s *Server) Accept(listener net.Listener) + func (s *Server) HandleCodec(cc codec.Codec, rawProtocol protocol.Protocol) + func (s *Server) HandleConn(conn io.ReadWriteCloser) + func (s *Server) HandleHTTP() + func (s *Server) Register(instance interface{}) error + func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) + type StrategyMode int + type XZClient struct + func NewXZClient(d Discovery, strategy StrategyMode, option *Option) *XZClient + func (xzc *XZClient) Broadcast(ctx context.Context, serviceMethod string, args, reply interface{}) error + func (xzc *XZClient) Call(ctx context.Context, serviceMethod string, args, reply interface{}) error + func (xzc *XZClient) Close() error