opensearch

package
v1.4.0 Latest Latest
Warning

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

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

Documentation

Overview

Package opensearch is the minimal REST client for the OpenSearch projection target (ADR-013). Only the operations the projector needs are implemented: index management, document get/upsert/delete. No external SDK dependency: the projector talks to the OpenSearch HTTP API directly.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound reports a missing document or index.
	ErrNotFound = errors.New("opensearch document not found")
	// ErrUnavailable reports the cluster being unreachable or rejecting the
	// operation; callers retry with backoff.
	ErrUnavailable = errors.New("opensearch unavailable")
)

Functions

This section is empty.

Types

type Client

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

Client is a minimal OpenSearch REST client.

func New

func New(addr, index string, options ...Option) (*Client, error)

New connects to the OpenSearch cluster address, e.g. http://127.0.0.1:39200.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, id string) error

Delete removes the document; a missing document is idempotent success.

func (*Client) EnsureIndex

func (c *Client) EnsureIndex(ctx context.Context, mapping []byte) error

EnsureIndex creates the index with the given mapping if it does not exist (idempotent: an existing index is left untouched).

func (*Client) Get

func (c *Client) Get(ctx context.Context, id string) ([]byte, error)

Get returns the stored document for the id.

func (*Client) Index

func (c *Client) Index(ctx context.Context, id string, document any) error

Index upserts the document under the id.

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

Ping checks the cluster health endpoint.

type Option

type Option func(*Client)

Option configures the client.

func WithCredentials

func WithCredentials(user, password string) Option

WithCredentials sets basic authentication (required when the security plugin is enabled).

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient injects the HTTP client (tests and custom transports).

Jump to

Keyboard shortcuts

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