clients

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ClientTypeHeader is the HTTP header where the client type resides.
	ClientTypeHeader = "pubsub"

	// ClientNameHeader is the HTTP header where the client's program name is stored.
	ClientNameHeader = "pubsub-client-name"

	// CloseDeadline is the time to wait to gracefully closing something. After that, it's closed regardless.
	CloseDeadline = time.Second * 5

	// PongDeadline is the number of seconds to wait before the next pong.
	PongDeadline = time.Second * 5
)

Variables

View Source
var (

	// ErrClosedByServer indicates that the client was closed by the server.
	ErrClosedByServer = errors.New("the client was closed by the server")
)

Functions

func CloseWebSocket

func CloseWebSocket(conn *websocket.Conn, pongDeadline time.Duration) (err error)

CloseWebSocket closes the client's websocket. It return the first error in the chain.

func ShortWriteDeadline

func ShortWriteDeadline(conn *websocket.Conn, pongDeadline time.Duration) (err error)

ShortWriteDeadline sets a short write deadline relative to the PongDeadline.

Types

type Options

type Options struct {

	// ClientName is the name of the client's program. It is used in the ClientNameHeader HTTP header.
	ClientName string

	// CloseDeadline is the time to wait to gracefully closing something. After that, it's closed regardless.
	CloseDeadline *time.Duration

	// InitialHeaders are the headers send during the first request to create a websocket.
	InitialHeaders http.Header

	// PongDeadline is the websocket write deadline to set when expecting a response.
	PongDeadline *time.Duration

	// WebsocketDialer is the *websocket.Dialer to use, if the default isn't sufficient.
	WebsocketDialer *websocket.Dialer
}

Options represents information used to connect a publisher or subscriber to a subscription that already has default values.

func FlattenClientOptions

func FlattenClientOptions(options []Options) (option Options)

FlattenClientOptions takes in a slice of Options, uses the highest index of their fields' values to create one Options.

Jump to

Keyboard shortcuts

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