zoukankan      html  css  js  c++  java
  • go-micro transport 通信

      transport 用于服务之间的通信,自定义了socket接口,封装了Send、Recv、Close接口,可以有HTTP、NATS、RPC等实现,默认使用http

    type Message struct {
    	Header map[string]string
    	Body   []byte
    }
    
    type Socket interface {
    	Recv(*Message) error
    	Send(*Message) error
    	Close() error
    }
    
    type Client interface {
    	Socket
    }
    
    type Listener interface {
    	Addr() string
    	Close() error
    	Accept(func(Socket)) error
    }
    
    // Transport is an interface which is used for communication between
    // services. It uses socket send/recv semantics and had various
    // implementations {HTTP, RabbitMQ, NATS, ...}
    type Transport interface {
    	Init(...Option) error
    	Options() Options
    	Dial(addr string, opts ...DialOption) (Client, error)
    	Listen(addr string, opts ...ListenOption) (Listener, error)
    	String() string
    }
    
    type Option func(*Options)
    
    type DialOption func(*DialOptions)
    
    type ListenOption func(*ListenOptions)
    

      

    you are the best!
  • 相关阅读:
    Python基础
    XML文件的基础使用
    正则表达式的基本使用
    hafs的java_api(转载)
    HDFS常用的Shell命令(转载)
    安装hadoop2.4.1
    配置JDK环境变量
    准备Linux环境
    Winform窗体屏蔽Alt+F4强制关闭
    leetcode 0214
  • 原文地址:https://www.cnblogs.com/linguoguo/p/14681314.html
Copyright © 2011-2022 走看看