listen

package
v1.105.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

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
	// contains filtered or unexported fields
}

Listener implements a ListenerService

func (*Listener) Start

func (l *Listener) Start() error

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

func (*Listener) Stop

func (l *Listener) Stop()

Stop signals the Listener to close the websocket connection

type ListenerService

type ListenerService interface {
	Start() error
	Stop()
}

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) 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