websocket

package
v0.0.0-...-0c70d8f Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BaseUrl               = "%s://%s/websocket?group=from_agent:%s&secret_key=devops_ws&key=%s&clusterId=%s&processor=%s&token=%s&version=%s"
	BaseUrlForDownloadLog = "%s://%s/websocket?group=from_agent:%s&secret_key=devops_ws&key=%s&clusterId=%s&processor=%s&token=%s&version=%s&instanceId=%s"
)
View Source
const (
	// Time allowed to write a message to the peer.
	WriteWait = 10 * time.Second
)

Variables

View Source
var NewPipe = func(c Client, id string, pipeType string, key string, token string) (pipeutil.Pipe, error) {
	return newPipe(pipeutil.NewPipe(pipeType), c, id, key, token)
}

Functions

func DialWS

func DialWS(urlStr string, requestHeader http.Header) (*websocket.Conn, *http.Response, error)

func IsExpectedWSCloseError

func IsExpectedWSCloseError(err error) bool

func NewPipeFromEnds

func NewPipeFromEnds(local, remote io.ReadWriter, c Client, id string, pipeType string, key string, token string) (pipeutil.Pipe, error)

Types

type Client

type Client interface {
	Loop(stopCh <-chan struct{}, done *sync.WaitGroup)
	PipeConnection(pipeID string, key string, token string, pipe pipeutil.Pipe) error
	PipeClose(pipeID string, pipe pipeutil.Pipe) error
	URL() *url.URL
	HandleDownloadLog(key, token, instanceId string, logReadCloser io.ReadCloser)
}

func NewClient

func NewClient(
	t Token,
	endpoint string,
	crChannel *channel.CRChan,
	clusterId string) (Client, error)

Token 参数里面的token endPoint devops的websocket地址

type Token

type Token string

func (Token) Set

func (t Token) Set(req *http.Request)

type WsReceivePacket

type WsReceivePacket struct {
	Type    string `json:"type,omitempty"`
	Key     string `json:"key,omitempty"`
	Message string `json:"message"`
	Group   string `json:"group,omitempty"`
}

Jump to

Keyboard shortcuts

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