Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoHashFound = errors.New("no hash found")
var ErrNoLoaderSupplied = errors.New("no remoteLoader supplied")
var ErrNoRemoteLoaderSpecified = errors.New("no remote loader specified")
var ErrPersistedOperationNotFound = errors.New("PersistedOperationNotFound")
var ErrPersistedQueryNotFound = errors.New("PersistedQueryNotFound")
var ErrReloadIntervalTooShort = errors.New("reload interval cannot be less than 10 seconds")
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Enabled bool `conf:"default:false" yaml:"enabled"` // The location on which persisted operations are stored Store string `conf:"default:./store" yaml:"store"` // Configuration for auto-reloading persisted operations Reload struct { Enabled bool `conf:"default:true" yaml:"enabled"` Interval time.Duration `conf:"default:5m" yaml:"interval"` Timeout time.Duration `conf:"default:10s" yaml:"timeout"` } // Remote strategies for fetching persisted operations Remote struct { GcpBucket string `yaml:"gcp_bucket"` } RejectOnFailure bool `conf:"default:true" yaml:"reject_on_failure"` }
type DirLoader ¶
type DirLoader struct {
// contains filtered or unexported fields
}
DirLoader 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
type ErrorMessage ¶
type ErrorMessage struct {
Message string `json:"message"`
}
type ErrorPayload ¶
type GcpStorageLoader ¶
type GcpStorageLoader 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 NewGcpStorageLoader ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewPersistedOperations ¶
func NewPersistedOperations(log *slog.Logger, cfg Config, loader LocalLoader, remoteLoader RemoteLoader) (*Handler, error)
func (*Handler) SwapHashForQuery ¶
SwapHashForQuery runs of the persisted operations handler it uses the configuration supplied to decide its behavior
type LocalLoader ¶
type LocalLoader interface {
Load(ctx context.Context) (map[string]PersistedOperation, error)
}
type MemoryLoader ¶
type MemoryLoader struct {
// contains filtered or unexported fields
}
MemoryLoader is a loader for testing purposes It allows the user to specify operations in memory
func (*MemoryLoader) Load ¶
func (d *MemoryLoader) Load(_ context.Context) (map[string]PersistedOperation, error)
type PersistedOperation ¶
func NewPersistedOperation ¶
func NewPersistedOperation(operation string) PersistedOperation
type RemoteLoader ¶
func RemoteLoaderFromConfig ¶
func RemoteLoaderFromConfig(cfg Config, log *slog.Logger) (RemoteLoader, error)
RemoteLoaderFromConfig looks at the configuration applied and figures out which remoteLoader to initialize and return If no remoteLoader is configured an error is returned