listen

package
v1.186.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Listener

type Listener struct {
	// URL is the url for the websocket. The schema should be "wss" or "ws"
	URL *url.URL
	// Token is used for authenticating with the websocket. It will be passed
	// using the "token" query parameter.
	Token string
	// SchemaFunc is a function allowing you to customize the output. For example,
	// this can be useful for unmarshal a JSON message and formatting the output.
	// It should return an io.Reader. If set to nil, the raw message will be outputted.
	SchemaFunc SchemaFunc
	// Out is an io.Writer to output to.
	// doctl hint: this should usually be commands.CmdConfig.Out
	Out io.Writer
	// InputCh is a channel to send input to the websocket
	InCh <-chan []byte
}

Listener implements a ListenerService

func (*Listener) Listen added in v1.118.0

func (l *Listener) Listen(ctx context.Context) error

Listen makes the websocket connection and writes messages to the io.Writer

type ListenerService

type ListenerService interface {
	Listen(ctx context.Context) error
}

ListenerService listens to a websocket connection and outputs to the provided io.Writer

func NewListener

func NewListener(url *url.URL, token string, schemaFunc SchemaFunc, out io.Writer, inCh <-chan []byte) ListenerService

NewListener returns a configured Listener

type SchemaFunc

type SchemaFunc func([]byte) (io.Reader, error)

SchemaFunc takes a slice of bytes and returns an io.Reader (See Listener.SchemaFunc)

Jump to

Keyboard shortcuts

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