1. Go Micro接口详解

    通信相关接口

    1.1.2. Codec编码接口

    1. ReadHeader(*Message, MessageType) error
    2. ReadBody(interface{}) error
    3. Write(*Message, interface{}) error
    4. Close() error
    5. String() string
    6. }

    服务注册发现的实现:etcd、consul、mdns、kube-DNS、zk

    1.1.4. Selector负载均衡

    1. Init(opts ...Option) error
    2. Options() Options
    3. // Select returns a function which should return the next node
    4. Select(service string, opts ...SelectOption) (Next, error)
    5. // Mark sets the success/error against a node
    6. // Reset returns state back to zero for a service
    7. Reset(service string)
    8. // Close renders the selector unusable
    9. Close() error
    10. // Name of the selector
    11. String() string
    12. }

    pull push watch

    1.1.6. Client客户端接口

    1. type Client interface {
    2. Init(...Option) error
    3. NewMessage(topic string, msg interface{}, opts ...MessageOption) Message
    4. NewRequest(service, method string, req interface{}, reqOpts ...RequestOption) Request
    5. Stream(ctx context.Context, req Request, opts ...CallOption) (Stream, error)
    6. Publish(ctx context.Context, msg Message, opts ...PublishOption) error
    7. String() string
    8. }

    1.1.8. Serveice接口

    1. type Service interface {
    2. Init(...Option)
    3. Options() Options
    4. Client() client.Client
    5. Server() server.Server
    6. Run() error
    7. String() string
    8. }