loader

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Extract

func Extract(ctx context.Context, k string) (*dataloader.Loader, error)

Extract will extract the loader from the context

Types

type BatchFunc

type BatchFunc func(ctx context.Context, ids []string) (DataBatch, error)

BatchFunc is the function clients provide for creating loaders

type Collection

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

Collection holds an internal lookup of initialized batch data load functions.

func NewCollection

func NewCollection() *Collection

NewCollection creates an empty loader collection

func (Collection) Attach

func (c Collection) Attach(ctx context.Context, opts ...dataloader.Option) context.Context

Attach creates new instances of dataloader.Loader and attaches the instances on the request context.

func (Collection) Register

func (c Collection) Register(key string, callback BatchFunc)

Register will register a new loader batch function

type DataBatch

type DataBatch map[string]interface{}

DataBatch type contains the results from the batch loader callback

Jump to

Keyboard shortcuts

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