events

package
v8.4.2 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package events contains the internal implementation of event forwarding.

Index

Constants

View Source
const (
	// SummaryEventsSchemaVersion is the minimum event schema that supports summary events.
	SummaryEventsSchemaVersion = 3

	// CurrentEventsSchemaVersion is the latest event schema version.
	CurrentEventsSchemaVersion = 4

	// EventSchemaHeader is an HTTP header that describes the schema version for event requests.
	EventSchemaHeader = "X-LaunchDarkly-Event-Schema"

	// EventUnsummarizedHeader is an HTTP header that denotes events being received have not gone
	// through the standard event summarization process.
	EventUnsummarizedHeader = "X-LaunchDarkly-Unsummarized"

	// TagsHeader is an HTTP header that may be sent by SDKs that support application metadata.
	// We copy the value of this header when proxying events.
	TagsHeader = "X-LaunchDarkly-Tags"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EventDispatcher

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

EventDispatcher relays events to LaunchDarkly for an environment

func NewEventDispatcher

func NewEventDispatcher(
	sdkKey c.SDKKey,
	mobileKey c.MobileKey,
	envID c.EnvironmentID,
	loggers ldlog.Loggers,
	config c.EventsConfig,
	httpConfig httpconfig.HTTPConfig,
	storeAdapter *store.SSERelayDataStoreAdapter,
	eventQueueCleanupInterval time.Duration,
) *EventDispatcher

NewEventDispatcher creates a handler for relaying events to LaunchDarkly for an environment

func (*EventDispatcher) Close

func (r *EventDispatcher) Close()

Close shuts down any goroutines/channels being used by the EventDispatcher.

func (*EventDispatcher) GetHandler

func (r *EventDispatcher) GetHandler(sdkKind basictypes.SDKKind, eventsKind ldevents.EventDataKind) func(w http.ResponseWriter, req *http.Request)

GetHandler returns the HTTP handler for an endpoint, or nil if none is defined

func (*EventDispatcher) ReplaceCredential

func (r *EventDispatcher) ReplaceCredential(newCredential credential.SDKCredential)

ReplaceCredential changes the authorization credentail that is used when forwarding events to any endpoints that use that type of credential. For instance, if newCredential is a MobileKey, this affects only endpoints that use a mobile key.

type EventPayloadMetadata

type EventPayloadMetadata struct {
	// SchemaVersion is the numeric value of the X-LaunchDarkly-Event-Schema header, or 1 if unknown
	// (in version 1, this header was not used).
	SchemaVersion int
	// Tags is the value of the X-LaunchDarkly-Tags header, or "" if none.
	Tags string
}

EventPayloadMetadata represents HTTP header metadata that may be included in an event post from an SDK, which Relay should copy when it forwards the events to LaunchDarkly.

func GetEventPayloadMetadata

func GetEventPayloadMetadata(req *http.Request) EventPayloadMetadata

GetEventPayloadMetadata parses EventPayloadMetadata values from an HTTP request.

type EventPublisher

type EventPublisher interface {
	// Publish adds any number of JSON elements to the queue.
	//
	// The EventPayloadMetadata value provides a way to distinguish between batches of events that have
	// different header metadata. If no such distinction is needed, it can simply be an empty
	// EventPayloadMetadata{}. Otherwise, each distinct value of EventPayloadMetadata gets its own event
	// queue, all of which will be flushed at the same time but delivered in separate HTTP posts.
	Publish(EventPayloadMetadata, ...json.RawMessage)

	// Flush attempts to deliver all queued events.
	Flush()

	// ReplaceCredential changes the authorization credential used when sending events, if the previous
	// credential was of the same type.
	ReplaceCredential(credential.SDKCredential)

	// Close releases all resources used by this object.
	Close()
}

EventPublisher is the interface for the component that buffers events and delivers them to LaunchDarkly. Events are treated as raw JSON data; the component does not do any parsing or transformation of them.

A single instance of the component exists for each environment, associated with a single credential (such as an SDK key). However, it can maintain multiple buffers if it is necessary to deliver events in separate batches due to SDKs providing different header metadata, as represented by EventPublisherContext.

The only implementation of this in Relay is HTTPEventPublisher. It is an interface only so that it can be mocked in test code.

type HTTPEventPublisher

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

HTTPEventPublisher is the standard implementation of EventPublisher.

func NewHTTPEventPublisher

func NewHTTPEventPublisher(authKey credential.SDKCredential, httpConfig httpconfig.HTTPConfig, loggers ldlog.Loggers, options ...OptionType) (*HTTPEventPublisher, error)

NewHTTPEventPublisher creates a new HTTPEventPublisher.

func (*HTTPEventPublisher) Close

func (p *HTTPEventPublisher) Close()

func (*HTTPEventPublisher) Flush

func (p *HTTPEventPublisher) Flush()

func (*HTTPEventPublisher) Publish

func (p *HTTPEventPublisher) Publish(metadata EventPayloadMetadata, events ...json.RawMessage)

func (*HTTPEventPublisher) ReplaceCredential

func (p *HTTPEventPublisher) ReplaceCredential(newCredential credential.SDKCredential)

type OptionBaseURI

type OptionBaseURI string

OptionBaseURI specifies a custom base URI for the events service.

type OptionCapacity

type OptionCapacity int

OptionCapacity specifies the event queue capacity.

type OptionFlushInterval

type OptionFlushInterval time.Duration

OptionFlushInterval specifies the interval for automatic flushes.

type OptionType

type OptionType interface {
	// contains filtered or unexported methods
}

OptionType defines optional parameters for NewHTTPEventPublisher.

type OptionURIPath

type OptionURIPath string

OptionURIPath specifies a custom endpoint URI path for the events service.

Directories

Path Synopsis
Package oldevents contains types and logic for processing event data from older SDKs that use obsolete event schemas.
Package oldevents contains types and logic for processing event data from older SDKs that use obsolete event schemas.

Jump to

Keyboard shortcuts

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