websocket

package
v0.0.0-...-e653fdf Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: AGPL-3.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// PongDelay is how long the server will wait for a pong to be sent
	// before the websocket is considered broken.
	PongDelay = 90 * time.Second

	// PingPeriod is how often ping messages are sent. This should be shorter
	// than the pongDelay, but not by too much. The difference here allows
	// the remote endpoint 30 seconds to respond to the ping as a ping is sent
	// every 60s, and when a pong is received the read deadline is advanced
	// another 90s.
	PingPeriod = 60 * time.Second

	// WriteWait is how long the write call can take before it errors out.
	WriteWait = 10 * time.Second
)

Variables

This section is empty.

Functions

func Serve

func Serve(w http.ResponseWriter, req *http.Request, handler func(ws *Conn))

Serve upgrades an HTTP connection to a websocket, and serves the given handler.

Types

type Conn

type Conn struct {
	*websocket.Conn
}

Conn wraps a gorilla/websocket.Conn, providing additional Juju-specific functionality.

func (*Conn) SendInitialErrorV0

func (conn *Conn) SendInitialErrorV0(err error) error

SendInitialErrorV0 writes out the error as a params.ErrorResult serialized with JSON with a new line character at the end.

This is a hangover from the initial debug-log streaming endpoint where the client read the first line, and then just got a stream of data. We should look to version the streaming endpoints to get rid of the trailing newline character for message based connections, which is all of them now.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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