subclient

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: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ClientType is the client type to be specified in the "pubsub" HTTP header.
	ClientType = "subscriber"
)

Variables

View Source
var (

	// ErrUnhandledMessageType indicates that an unhandled websocket message type was received.
	ErrUnhandledMessageType = errors.New("an unhandled websocket message type was received")
)

Functions

This section is empty.

Types

type Subscriber

type Subscriber struct {
	// contains filtered or unexported fields
}

Subscriber represents a pubsub subscriber.

func New

func New(ctx context.Context, messages chan []byte, u *url.URL, options ...clients.Options) (subscriber *Subscriber, resp *http.Response, err error)

New creates a new pubsub.Subscriber. The given ctx is used to close the goroutines launched from this function call.

func (*Subscriber) Close

func (s *Subscriber) Close() (err error)

Close cancels the subscriber's context, ends its goroutines, and websocket.

func (*Subscriber) Done

func (s *Subscriber) Done() (done <-chan struct{})

Done mimics context.Context's Done method.

func (*Subscriber) Error

func (s *Subscriber) Error() (err error)

Error returns the error of why the subscriber closed. It should only be called after the Done method's channel has been closed.

func (*Subscriber) Messages

func (s *Subscriber) Messages() (messages <-chan []byte)

Messages returns the channel to read messages from.

Jump to

Keyboard shortcuts

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