stream

package
v0.1.22 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStreamDisconnect error = errors.New("stream disconnect")

ErrStreamDisconnect is a stream disconnect error

Functions

This section is empty.

Types

type Connection

type Connection interface {
	Connect(environment string) error
	OnDisconnect(func() error) error
}

Connection is simple interface for streams

type Event added in v0.0.24

type Event struct {
	// APIKey is the SDKs API Key
	APIKey string
	// Environment is the ID of the environment that the event occured for
	Environment string
	// SSEEvent is the SSEEvent that was sent from the FeatureFlags server to the SDK
	SSEEvent *sse.Event

	// Err holds any errors encountered by the sdk while listening on the stream and this
	// field should be used to pass those errors on to the EventStreamListener to let it
	// know something has gone wrong on the stream it's listening on
	Err error
}

Event defines the structure of an event that gets sent to a EventStreamListener

type EventStreamListener added in v0.0.24

type EventStreamListener interface {
	// Pub publishes an event from the SDK to your Listener. Pub should implement
	// any backoff/retry logic as this is not handled in the SDK.
	Pub(ctx context.Context, event Event) error
}

EventStreamListener provides a way to hook in to the SSE Events that the SDK recieves from the FeatureFlags server and forward them on to another type.

type Message

type Message struct {
	Event      string `json:"event"`
	Domain     string `json:"domain"`
	Identifier string `json:"identifier"`
	Version    int    `json:"version"`
}

Message is basic object for marshalling data from ff stream

type SSEClient

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

SSEClient is Server Send Event object

func NewSSEClient

func NewSSEClient(
	apiKey string,
	token string,
	client *sse.Client,
	repository repository.Repository,
	api rest.ClientWithResponsesInterface,
	logger logger.Logger,
	eventStreamListener EventStreamListener,
	proxyMode bool,
	streamConnected chan struct{},
	streamDisconnected chan error,

) *SSEClient

NewSSEClient creates an object for stream interactions

func (*SSEClient) Connect

func (c *SSEClient) Connect(ctx context.Context, environment string, apiKey string)

Connect will subscribe to SSE stream

Jump to

Keyboard shortcuts

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