bulkgetter

package
v0.0.0-...-ada256f Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHTTP = errors.New("HTTP Error")

ErrHTTP represents non-404 errors in HTTP requests.

Functions

This section is empty.

Types

type AsyncGetter

type AsyncGetter interface {
	Get(context.Context, *GetRequest, interface{}) <-chan GetResponse
	Work(context.Context) error
}

AsyncGetter is an interface to allow for asynchronous getting.

type BulkGetter

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

BulkGetter allows batching/bulk gets.

func New

func New(cfg Config) *BulkGetter

New returns a new BulkGetter, setting sensible defaults for the configuration.

func (*BulkGetter) Get

func (bg *BulkGetter) Get(ctx context.Context, req *GetRequest, dst interface{}) <-chan GetResponse

Get queues a single Get() for a batching get.

func (*BulkGetter) Work

func (bg *BulkGetter) Work(ctx context.Context) error

Work starts a single worker processing batched Get() requests. It will terminate on errors.

type Config

type Config struct {
	Client       *opensearch.Client
	BatchSize    int
	BatchTimeout time.Duration
}

Config provides configuration for a BatchingGetter.

type GetRequest

type GetRequest struct {
	Index      string
	DocumentID string
	Fields     []string
}

GetRequest represents an item to GET.

func (*GetRequest) String

func (r *GetRequest) String() string

type GetResponse

type GetResponse struct {
	Found bool
	Error error
}

GetResponse represents the response from a GetRequest.

type Mock

type Mock struct {
	mock.Mock
}

Mock mocks the AsyncGetter interface.

func (*Mock) Get

func (m *Mock) Get(ctx context.Context, req *GetRequest, dst interface{}) <-chan GetResponse

Get mocks a get of an AsyncGetter.

func (*Mock) Work

func (m *Mock) Work(ctx context.Context) error

Work mocks the start of an AsyncGetter worker.

Jump to

Keyboard shortcuts

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