Documentation
¶
Index ¶
- Variables
- func NewSelf(zone, service, id string) *discovery.Service
- type AppConfigure
- type AppInfo
- type ChannelList
- type ClosedChannel
- type Configure
- type ConsulConfigure
- type DCenterBridge
- func (dc *DCenterBridge) ChannelsLoop(channelMsg GetChannelMsg, channelClosed ClosedChannel) error
- func (dc *DCenterBridge) CreateChannel(zone, serviceName, id string) (channel.Channel, error)
- func (dc *DCenterBridge) CreateChannelForTest(zone, serviceName, id, host string) (channel.Channel, error)
- func (dc *DCenterBridge) DeleteChannel(zone, serviceName, id string) error
- func (dc *DCenterBridge) DiscoveryServers(zone, service string) ([]discovery.Service, error)
- func (dc *DCenterBridge) GetChannelList() ChannelList
- func (dc *DCenterBridge) GetListenerList() ListenerList
- func (dc *DCenterBridge) ListenAndServe() error
- func (dc *DCenterBridge) SendData(zone, serviceName string, data []byte) error
- func (dc *DCenterBridge) WaitQuit()
- type Datacenter
- type DiscoveryConfigure
- type EtcdConfigure
- type GetChannelMsg
- type ListenerList
- type QuicConfigure
- type ServerConfigure
- type WebsocketConfigure
- type WebsocketsConfigure
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrChannelNotFound = errors.New("channel not found")
View Source
var ErrNoDiscovery = errors.New("no discovery")
View Source
var ErrNoServer = errors.New("no server")
View Source
var SWG = sync.WaitGroup{}
SWG -
Functions ¶
Types ¶
type AppConfigure ¶
type AppConfigure struct {
AppInfo `yaml:",inline"`
Mode string `yaml:"mode" json:"mode" comment:"运行模式"`
Log logger.LogConfigure `yaml:"log" json:"log" comment:"日志配置"`
Servers ServerConfigure `yaml:"servers" json:"servers" comment:"服务列表"`
Discovery DiscoveryConfigure `yaml:"discovery" json:"discovery" comment:"服务发现"`
}
type AppInfo ¶
type AppInfo struct {
Zone string `yaml:"zone" json:"zone" comment:"区域:cn-001"`
Service string `yaml:"service" json:"service" comment:"服务类别:gw-dcb-service"`
Id string `yaml:"id" json:"id" comment:"服务Id:gw-node1"`
}
AppInfo - local app info.
type ChannelList ¶
type ChannelList struct {
Info map[string][]channel.ChannelInfo `json:"info" comment:"桥通道服务列表"`
}
func (ChannelList) String ¶
func (l ChannelList) String() string
type ClosedChannel ¶ added in v0.0.2
type Configure ¶
type Configure struct {
AppConfigure `yaml:"app" json:"app" comment:"应用配置"`
}
Configure -
func LoadConfigure ¶
LoadConfigure - load configure from file.
type ConsulConfigure ¶
type ConsulConfigure struct {
Up bool `yaml:"up" json:"up" comment:"是否启用"`
Host string `yaml:"host" json:"host" comment:"http://Ip:Port"`
Token string `yaml:"token" json:"token" comment:"acl认证"`
}
ConsulConfigure-
type DCenterBridge ¶
type DCenterBridge struct {
// contains filtered or unexported fields
}
DCenterBridge - 区域桥通道.
func NewDCenterBridge ¶
func NewDCenterBridge(ctx context.Context, done chan bool, config *Configure) *DCenterBridge
NewDCenterBridge -
func (*DCenterBridge) ChannelsLoop ¶
func (dc *DCenterBridge) ChannelsLoop(channelMsg GetChannelMsg, channelClosed ClosedChannel) error
ChannelsLoop -
func (*DCenterBridge) CreateChannel ¶
func (dc *DCenterBridge) CreateChannel(zone, serviceName, id string) (channel.Channel, error)
CreateChannel - 创建桥通道.
func (*DCenterBridge) CreateChannelForTest ¶
func (dc *DCenterBridge) CreateChannelForTest(zone, serviceName, id, host string) (channel.Channel, error)
func (*DCenterBridge) DeleteChannel ¶
func (dc *DCenterBridge) DeleteChannel(zone, serviceName, id string) error
func (*DCenterBridge) DiscoveryServers ¶ added in v0.0.5
func (dc *DCenterBridge) DiscoveryServers(zone, service string) ([]discovery.Service, error)
func (*DCenterBridge) GetChannelList ¶
func (dc *DCenterBridge) GetChannelList() ChannelList
GetChannelList -
func (*DCenterBridge) GetListenerList ¶
func (dc *DCenterBridge) GetListenerList() ListenerList
func (*DCenterBridge) ListenAndServe ¶
func (dc *DCenterBridge) ListenAndServe() error
ListenAndServe -
type Datacenter ¶
type Datacenter interface {
ListenAndServe() error // 启动服务监听.
WaitQuit() // 等待退出.
ChannelsLoop(GetChannelMsg, ClosedChannel) error // client loop.
DiscoveryServers(zone, service string) ([]discovery.Service, error) // 发现桥通道:区域|服务名称.
CreateChannel(zone, service, id string) (channel.Channel, error) // 创建桥通道:区域|服务名称.
DeleteChannel(zone, service, id string) error // 删除桥通道:区域|服务名称.
SendData(zone, service string, data []byte) error // 发送数据:区域|服务名称|数据.
CreateChannelForTest(zone, service, id, host string) (channel.Channel, error) // for test, no use production.
GetChannelList() ChannelList // 获取桥通道列表.
GetListenerList() ListenerList // 获取监听服务列表.
}
Datacenter - datacenter bridge interface.
func NewDCenterBridgeWithClient ¶
func NewDCenterBridgeWithClient(ctx context.Context, done chan bool, self AppInfo, options ...interface{}) Datacenter
NewDCenterBridgeWithClient - client use.
func NewDCenterBridgeWithServer ¶
func NewDCenterBridgeWithServer(ctx context.Context, done chan bool, self AppInfo, options ...interface{}) Datacenter
NewDCenterBridge - server use.
type DiscoveryConfigure ¶
type DiscoveryConfigure struct {
Consul ConsulConfigure `yaml:"consul" json:"consul" comment:"Consul服务发现"`
Etcd EtcdConfigure `yaml:"etcd" json:"etcd" comment:"Etcd服务发现"`
}
DiscoveryConfigure -
type EtcdConfigure ¶
type EtcdConfigure struct {
Up bool `yaml:"up" json:"up" comment:"是否启用"`
Endpoints []string `yaml:"endpoints" json:"endpoints" comment:"[]Ip:Port"`
Prefix string `yaml:"prefix" json:"prefix" comment:"service prefix /dcbridge."`
GrantedTTL int64 `yaml:"ttl" json:"ttl" comment:"service granted ttl in seconds"`
}
type GetChannelMsg ¶
GetChannelMsg - get bridge channel message.
type ListenerList ¶
type ListenerList struct {
Self AppInfo `json:"app" comment:"本地服务信息"`
Listens []string `json:"listens" comment:"监听地址列表"`
}
ListenerList -
func (ListenerList) String ¶
func (l ListenerList) String() string
type QuicConfigure ¶
type QuicConfigure struct {
Up bool `yaml:"up" json:"up" comment:"是否启用"`
Host string `yaml:"host" json:"host" comment:"quic://Ip:Port"`
CertFile string `yaml:"certfile" json:"certfile" comment:"certfile"`
KeyFile string `yaml:"keyfile" json:"keyfile" comment:"keyfile"`
QueueSize int `yaml:"queueSize" json:"queueSize" comment:"队列大小"`
BufferSize int `yaml:"bufferSize" json:"bufferSize" comment:"缓存大小"`
}
type ServerConfigure ¶
type ServerConfigure struct {
Ws WebsocketConfigure `yaml:"ws" json:"ws" comment:"Ws服务配置"`
Wss WebsocketsConfigure `yaml:"wss" json:"wss" comment:"Wss服务配置"`
Quic QuicConfigure `yaml:"quic" json:"quic" comment:"Quic服务配置"`
}
ServerConfigure -
type WebsocketConfigure ¶
type WebsocketConfigure struct {
Up bool `yaml:"up" json:"up" comment:"是否启用"`
Host string `yaml:"host" json:"host" comment:"ws://Ip:Port/bridge"`
// Prefix string `yaml:"prefix" json:"prefix" comment:"uri prefix"`
QueueSize int `yaml:"queueSize" json:"queueSize" comment:"队列大小"`
BufferSize int `yaml:"bufferSize" json:"bufferSize" comment:"缓存大小"`
}
WebsocketConfigure -
type WebsocketsConfigure ¶
type WebsocketsConfigure struct {
Up bool `yaml:"up" json:"up" comment:"是否启用"`
Host string `yaml:"host" json:"host" comment:"ws://Ip:Port/bridge"`
CertFile string `yaml:"certfile" json:"certfile" comment:"certfile"`
KeyFile string `yaml:"keyfile" json:"keyfile" comment:"keyfile"`
QueueSize int `yaml:"queueSize" json:"queueSize" comment:"队列大小"`
BufferSize int `yaml:"bufferSize" json:"bufferSize" comment:"缓存大小"`
}
WebsocketsConfigure -
Click to show internal directories.
Click to hide internal directories.