sse

package
v4.2.1-0...-85e7c47 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2021 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotIdle = errors.New("sse client already running")

ErrNotIdle is the error tor eturn when Do() gets called on an already running client.

View Source
var ErrReadingStream = errors.New("sse channel closed")

ErrReadingStream is the error to return when channel event channel is closed because of an error reading the stream

View Source
var ErrTimeout = errors.New("timeout exceeeded")

ErrTimeout is the error to return when keepalive timeout is exceeded

Functions

This section is empty.

Types

type Client

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

Client struct

func NewClient

func NewClient(url string, timeout int, logger logging.LoggerInterface) (*Client, error)

NewClient creates new SSEClient

func (*Client) Do

func (l *Client) Do(params map[string]string, headers map[string]string, callback func(e RawEvent)) error

Do starts streaming

func (*Client) Shutdown

func (l *Client) Shutdown(blocking bool)

Shutdown stops SSE

type ErrConnectionFailed

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

ErrConnectionFailed contains a nested error

func (*ErrConnectionFailed) Error

func (e *ErrConnectionFailed) Error() string

Error returns the error as a string

func (*ErrConnectionFailed) Unwrap

func (e *ErrConnectionFailed) Unwrap() error

Unwrap returns the wrapped error

type EventBuilder

type EventBuilder interface {
	AddLine(string)
	Build() *RawEventImpl
}

EventBuilder interface

type EventBuilderImpl

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

EventBuilderImpl implenets the EventBuilder interface. Used to parse incoming event lines

func NewEventBuilder

func NewEventBuilder() *EventBuilderImpl

NewEventBuilder constructs a new event builder

func (*EventBuilderImpl) AddLine

func (b *EventBuilderImpl) AddLine(line string)

AddLine adds a new line belonging to the currently being processed event

func (*EventBuilderImpl) Build

func (b *EventBuilderImpl) Build() *RawEventImpl

Build processes all the added lines and builds the event

func (*EventBuilderImpl) Reset

func (b *EventBuilderImpl) Reset()

Reset clears the lines accepted

type RawEvent

type RawEvent interface {
	ID() string
	Event() string
	Data() string
	Retry() int64
	IsError() bool
	IsEmpty() bool
}

RawEvent interface contains the methods that expose the incoming SSE properties

type RawEventImpl

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

RawEventImpl represents an incoming SSE event

func (*RawEventImpl) Data

func (r *RawEventImpl) Data() string

Data returns the event associated data

func (*RawEventImpl) Event

func (r *RawEventImpl) Event() string

Event returns the event type

func (*RawEventImpl) ID

func (r *RawEventImpl) ID() string

ID returns the event id

func (*RawEventImpl) IsEmpty

func (r *RawEventImpl) IsEmpty() bool

IsEmpty returns true if the event contains no id, event type and data

func (*RawEventImpl) IsError

func (r *RawEventImpl) IsError() bool

IsError returns true if the message is an error

func (*RawEventImpl) Retry

func (r *RawEventImpl) Retry() int64

Retry returns the expected retry time

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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