types

package
v1.5.28 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LBType      = "lb"
	ConcretType = "concret"
	FilterType  = "filter"
	DeployType  = "deploy"
	LB          = LBType
	Concret     = ConcretType
	Filter      = FilterType
	Deploy      = DeployType

	ValidCode int = 200

	ErrGetErrorResponse uint32 = 101
	ErrUnmarshalFailed  uint32 = 102
)
View Source
const (
	DefaultSubscribeMethod      = "subscribe"
	DefaultUnsubscribeMethod    = "unsubscribe"
	DefaultUnsubscribeAllMethod = "unsubscribe_all"

	DefaultTCP     = "tcp://"
	DefaultRPCPort = "80"

	DefaultPrefix     = "tm."
	DefaultEthPrefix  = "dao."
	DefaultWSEndpoint = "/websocket"
)

Variables

View Source
var (
	TMPort    = "80"
	EthPort   = "80"
	ShardPort = "80"
)

Functions

func DeleteSlice

func DeleteSlice(res []*websocket.Conn, s *websocket.Conn) []*websocket.Conn

func GetConnection

func GetConnection(addr string) (*rpcclient.HTTP, bool)

func GetEthConnection

func GetEthConnection(addr string) (*websocket.Conn, bool)

func GetURL added in v1.5.21

func GetURL(host string) (error, *util.DomainInfo)

func IsValidMessage

func IsValidMessage(msg []byte) bool

func Notify

func Notify(r *PubSubRoom, topic string, m SendMessage)

func SetDefaultPort

func SetDefaultPort(tmport, shardport, ethport string)

Types

type ClientError

type ClientError struct {
	Error   interface{}     `json:"error"`
	Connect *websocket.Conn `json:"connect"`
}

func NewServerError

func NewServerError(r interface{}, c *websocket.Conn) ClientError

type Description

type Description struct {
	Key       string `json:"key"`
	Connect   string `json:"connect"`
	Value     string `json:"value"`
	ValueType string `json:"value_type"`
}

type ErrorResponse

type ErrorResponse struct {
	Ret     interface{} `json:"ret"`
	Data    interface{} `json:"data"`
	Message string      `json:"message"`
}

type EthSubcribeMsg

type EthSubcribeMsg struct {
	JsonRpc string        `json:"jsonrpc"`
	ID      float64       `json:"id"`
	Method  string        `json:"method"`
	Params  []interface{} `json:"params"`
}

type Instance

type Instance interface {
	IsAlive() bool
	SetAlive(live bool)
	URL() *url.URL
	FailTime() int
}

type Job

type Job interface {
	Do()
}

type LBPolicy

type LBPolicy interface {
	NextPeer(backends []Instance) Instance
}

type MessageContent

type MessageContent struct {
	Method string        `json:"method"`
	Args   []Description `json:"args"`
}

func (MessageContent) CommandType

func (msg MessageContent) CommandType() string

func (MessageContent) GetTopic

func (msg MessageContent) GetTopic() string

func (MessageContent) IsUnsubscribeAll

func (msg MessageContent) IsUnsubscribeAll() bool

type NewRequestParams

type NewRequestParams struct {
	Data interface{} `json:"data"`
}

type Proxy

type Proxy interface {
	Handle(r *http.Request, backends []Instance, RequestParams map[string]string) []byte

	Response() *chan []byte
}

type ProxyType

type ProxyType string

type PubSubRoom

type PubSubRoom struct {
	RemoteClients []*websocket.Conn
	ConnMap       map[string][]*websocket.Conn

	Connections    map[string]*rpcclient.HTTP
	EthConnections map[string]*websocket.Conn
	Mutex          sync.Mutex
	// contains filtered or unexported fields
}

func (*PubSubRoom) AddShard

func (r *PubSubRoom) AddShard()

func (PubSubRoom) GetBackends

func (r PubSubRoom) GetBackends() []Instance

func (*PubSubRoom) GetPubSubRoom

func (r *PubSubRoom) GetPubSubRoom()

func (*PubSubRoom) HandleSubscribe

func (r *PubSubRoom) HandleSubscribe(topic string, c *websocket.Conn)

func (*PubSubRoom) HandleUnsubscribe

func (r *PubSubRoom) HandleUnsubscribe(topic string, c *websocket.Conn)

func (*PubSubRoom) HandleUnsubscribeAll

func (r *PubSubRoom) HandleUnsubscribeAll(c *websocket.Conn)

func (*PubSubRoom) HasClientConnect

func (r *PubSubRoom) HasClientConnect() bool

func (*PubSubRoom) HasEthConnections

func (r *PubSubRoom) HasEthConnections() bool

func (*PubSubRoom) HasTMConnections

func (r *PubSubRoom) HasTMConnections() bool

func (*PubSubRoom) Receive

func (r *PubSubRoom) Receive(c *websocket.Conn)

func (*PubSubRoom) ReceiveEth

func (r *PubSubRoom) ReceiveEth(c *websocket.Conn)

func (*PubSubRoom) RemoveAllEthConnections

func (r *PubSubRoom) RemoveAllEthConnections()

func (*PubSubRoom) RemoveAllTMConnections

func (r *PubSubRoom) RemoveAllTMConnections(err error)

func (*PubSubRoom) RemoveEthConnection

func (r *PubSubRoom) RemoveEthConnection(c *websocket.Conn, err error)

func (*PubSubRoom) SetBackends

func (r *PubSubRoom) SetBackends(bs []Instance)

func (*PubSubRoom) SetEthConnections

func (r *PubSubRoom) SetEthConnections() (err error)

func (*PubSubRoom) SetTMConnections

func (r *PubSubRoom) SetTMConnections() (err error)

func (*PubSubRoom) Subscribe

func (r *PubSubRoom) Subscribe(topic string)

func (*PubSubRoom) Unsubscribe

func (r *PubSubRoom) Unsubscribe(topic string)

type ReceiveMessage

type ReceiveMessage struct {
	Time    string         `json:"time"`    //time
	Content MessageContent `json:"content"` //content表示消息内容,这里简化别的消息
}

client端消息结构

func (ReceiveMessage) String

func (msg ReceiveMessage) String() string

type RequestParams

type RequestParams struct {
	Proxy string      `json:"proxy"`
	Data  interface{} `json:"data"`
}

type ResultRep

type ResultRep struct {
	Code uint64 `json:"coee"`
	Data string `json:"data"`
}

type SendMessage

type SendMessage struct {
	Time    string      `json:"time"`    //time
	Content interface{} `json:"content"` //content表示消息内容,这里简化别的消息
}

Server端消息结构

type ServerSource

type ServerSource interface {
	FetchSource() []string
}

type TMResponse

type TMResponse struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL