loader

package
v0.0.0-...-74adf86 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(cat *catalog.Catalog, logger *zap.Logger) func(context.Context) context.Context

Middleware creates a middleware that adds loaders to the context

Types

type CategoryLoader

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

CategoryLoader batches category lookups

func NewCategoryLoader

func NewCategoryLoader(cat *catalog.Catalog, logger *zap.Logger) *CategoryLoader

NewCategoryLoader creates a new category data loader

func (*CategoryLoader) Clear

func (l *CategoryLoader) Clear()

Clear clears the loader state (called on catalog reload)

func (*CategoryLoader) Load

func (l *CategoryLoader) Load(ctx context.Context, id string) (*catalog.Category, error)

Load loads a single category by ID (batched)

func (*CategoryLoader) LoadMany

func (l *CategoryLoader) LoadMany(ctx context.Context, ids []string) ([]*catalog.Category, []error)

LoadMany loads multiple categories by IDs (batched)

func (*CategoryLoader) Prime

func (l *CategoryLoader) Prime(id string, category *catalog.Category)

Prime preloads a category into the cache

type CollectionLoader

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

CollectionLoader batches collection lookups

func NewCollectionLoader

func NewCollectionLoader(cat *catalog.Catalog, logger *zap.Logger) *CollectionLoader

NewCollectionLoader creates a new collection data loader

func (*CollectionLoader) Clear

func (l *CollectionLoader) Clear()

Clear clears the loader state (called on catalog reload)

func (*CollectionLoader) Load

Load loads a single collection by ID (batched)

func (*CollectionLoader) LoadMany

func (l *CollectionLoader) LoadMany(ctx context.Context, ids []string) ([]*catalog.Collection, []error)

LoadMany loads multiple collections by IDs (batched)

func (*CollectionLoader) Prime

func (l *CollectionLoader) Prime(id string, collection *catalog.Collection)

Prime preloads a collection into the cache

type Loaders

type Loaders struct {
	Product    *ProductLoader
	Category   *CategoryLoader
	Collection *CollectionLoader
}

Loaders holds all data loaders for a request

func FromContext

func FromContext(ctx context.Context) *Loaders

FromContext retrieves loaders from the context

func NewLoaders

func NewLoaders(cat *catalog.Catalog, logger *zap.Logger) *Loaders

NewLoaders creates a new set of data loaders for a catalog

func (*Loaders) Clear

func (l *Loaders) Clear()

Clear clears all loader state (should be called on catalog reload)

type ProductLoader

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

ProductLoader batches product lookups

func NewProductLoader

func NewProductLoader(cat *catalog.Catalog, logger *zap.Logger) *ProductLoader

NewProductLoader creates a new product data loader

func (*ProductLoader) Clear

func (l *ProductLoader) Clear()

Clear clears the loader state (called on catalog reload)

func (*ProductLoader) Load

func (l *ProductLoader) Load(ctx context.Context, id string) (*catalog.Product, error)

Load loads a single product by ID (batched)

func (*ProductLoader) LoadMany

func (l *ProductLoader) LoadMany(ctx context.Context, ids []string) ([]*catalog.Product, []error)

LoadMany loads multiple products by IDs (batched)

func (*ProductLoader) Prime

func (l *ProductLoader) Prime(id string, product *catalog.Product)

Prime preloads a product into the cache

Jump to

Keyboard shortcuts

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