opensearch

package
v0.0.0-...-ac61c48 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorEventIDEmpty        = errors.New("event IDs are not supposed to be empty")
	ErrorEventPayloadEmpty   = errors.New("event payload is nil")
	ErrorEventPayloadInvalid = errors.New("payload is not valid")
	ErrorNegativeStatusCode  = errors.New("opensearch replied with a negative status code")
)
View Source
var ErrOptNoAddress = errors.New("no address was specified")

Functions

func EnsureIndexTemplate

func EnsureIndexTemplate(ctx context.Context, client Client, config DataStream) error

EnsureIndexTemplate makes sure that an Index Template is present and is configured in a given way.

Note: If the configuration of an exisiting index template doesn't match the given configuration an error will be returned. Currently there is no save way for us to update the index template.

func IndexEvent

func IndexEvent(ctx context.Context, client Client, stream DataStream, event Event) error

IndexEvent takes a given Event and tries to appned it to the current stream

Types

type Bulk

type Bulk []Document

func (Bulk) MarshalJSONToBuffer

func (b Bulk) MarshalJSONToBuffer() (*bytes.Buffer, error)

type Client

type Client struct {
	*opensearch.Client
}

Client is the way to communicate with a configured opensearch.

func NewWithDefaultClient

func NewWithDefaultClient() (Client, error)

NewWithDefaultClient creates a Client based on the given http.Client.

func (Client) BulkIndex

func (client Client) BulkIndex(ctx context.Context, docs []Document) error

BulkIndex send multiple docuemnts to opensearch

type DataStream

type DataStream interface {
	Name() string
}

type Document

type Document interface {
	// ID should return a unique ID for this document.
	ID() string

	// Index should return the target index
	Index() string

	// Data should return the docuemnt that should be indexed.
	Data() interface{}
}

Document describes an indexable set of data.

type Event

type Event struct {
	ID string

	Payload EventPayload
}

type EventPayload

type EventPayload interface{}

Jump to

Keyboard shortcuts

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