pubclient

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 = "publisher"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Publisher

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

Publisher represents a pubsub publisher.

func New

func New(ctx context.Context, u *url.URL, options ...clients.Options) (publisher *Publisher, resp *http.Response, err error)

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

func (*Publisher) Close

func (p *Publisher) Close() (err error)

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

func (*Publisher) Done

func (p *Publisher) Done() (done <-chan struct{})

Done mimics context.Context's Done method.

func (*Publisher) Error

func (p *Publisher) 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 (*Publisher) Publish

func (p *Publisher) Publish(message []byte) (err error)

Publish publishes the message to the subscription. This method is not safe to call asynchronously. A pumping goroutine is recommended.

Jump to

Keyboard shortcuts

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