persistedoperations

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoHashFound = errors.New("no hash found")
View Source
var ErrNoLoaderSupplied = errors.New("no remoteLoader supplied")
View Source
var ErrPersistedOperationNotFound = errors.New("PersistedOperationNotFound")
View Source
var ErrPersistedQueryNotFound = errors.New("PersistedQueryNotFound")
View Source
var ErrReloadIntervalTooShort = errors.New("load interval cannot be less than 10 seconds")

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled         bool         `yaml:"enabled"`
	RejectOnFailure bool         `yaml:"reject_on_failure"`
	Loader          LoaderConfig `yaml:"loader"`
}

func DefaultConfig added in v0.17.0

func DefaultConfig() Config

type ErrorMessage

type ErrorMessage struct {
	Message string `json:"message"`
}

type ErrorPayload

type ErrorPayload struct {
	Errors gqlerror.List `json:"errors"`
}

type GcpLoader added in v0.16.0

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

GcpStorageLoader loads persisted operations from a GCP Storage bucket. It matches files based on a `*.json` glob pattern and attempts to unmarshall them into a persisted operations map structure

func NewGcpLoader added in v0.16.0

func NewGcpLoader(cfg LoaderConfig, log *slog.Logger) (*GcpLoader, error)

func (*GcpLoader) Load added in v0.16.0

func (*GcpLoader) Type added in v0.16.0

func (g *GcpLoader) Type() string

type Handler

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

func NewPersistedOperations

func NewPersistedOperations(log *slog.Logger, cfg Config, loader Loader) (*Handler, error)

func (*Handler) Shutdown

func (p *Handler) Shutdown()

func (*Handler) SwapHashForQuery

func (p *Handler) SwapHashForQuery(next http.Handler) http.Handler

SwapHashForQuery runs of the persisted operations handler it uses the configuration supplied to decide its behavior

func (*Handler) Validate

func (p *Handler) Validate(validate func(operation string) gqlerror.List) []validation.Error

type Loader added in v0.16.0

type Loader interface {
	Load(ctx context.Context) (map[string]PersistedOperation, error)
	Type() string
}

func NewLoaderFromConfig added in v0.16.0

func NewLoaderFromConfig(cfg Config, log *slog.Logger) (Loader, error)

type LoaderConfig added in v0.16.0

type LoaderConfig struct {
	Type     string `yaml:"type"`
	Location string `yaml:"location"`
	// Configuration for auto-reloading persisted operations
	Reload struct {
		Enabled  bool          `yaml:"enabled"`
		Interval time.Duration `yaml:"interval"`
		Timeout  time.Duration `yaml:"timeout"`
	}
}

type LocalLoader

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

LocalLoader loads persisted operations from a filesystem directory It looks at all files in the directory, but doesn't traverse subdirectories If it finds a file with a `.json` extension it attempts to unmarshall it and use it as a source for persisted operations/ If it fails to load a file it moves on to the next file in the directory

func NewLocalDirLoader

func NewLocalDirLoader(cfg Config, log *slog.Logger) *LocalLoader

func (*LocalLoader) Load

func (*LocalLoader) Type added in v0.16.0

func (d *LocalLoader) Type() string

type MemoryLoader

type MemoryLoader struct {
	Store map[string]PersistedOperation
}

MemoryLoader is a loader for testing purposes It allows the user to specify operations in memory

func (*MemoryLoader) Load

func (*MemoryLoader) Type added in v0.16.0

func (d *MemoryLoader) Type() string

type NoOpLoader added in v0.16.0

type NoOpLoader struct {
}

func NewNoOpLoader added in v0.16.0

func NewNoOpLoader() (*NoOpLoader, error)

func (*NoOpLoader) Load added in v0.16.0

func (*NoOpLoader) Type added in v0.16.0

func (n *NoOpLoader) Type() string

type PersistedOperation

type PersistedOperation struct {
	Operation string
	Name      string `json:"name,omitempty"`
}

Jump to

Keyboard shortcuts

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