persistence

package
v5.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCreateRevisionNotAllowed = errors.New("a local query cannot be updated with a new revision : remove it from the local configuration or migrate it to the database")

ErrCreateRevisionNotAllowed is returned when trying to write a query revision on a query stored on local or env.

View Source
var ErrSetResourceMappingNotAllowed = errors.New("a resource mapping must have a source of type database in order to provide writing operations")

ErrSetResourceMappingNotAllowed is returned when trying to write a resource mapping on a resource stored on local or env.

Functions

This section is empty.

Types

type Database

type Database restql.DatabasePlugin

Database defines the operations exposed by an external store.

func NewDatabase

func NewDatabase(log restql.Logger, disabled bool) (Database, error)

NewDatabase constructs a Database compliant value from the database plugin registered. In case of no plugin, a noop implementation is returned.

type MappingsReader

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

MappingsReader fetch indexed mappings from database, configuration file and environment variable.

func NewMappingReader

func NewMappingReader(log restql.Logger, env domain.EnvSource, local map[string]map[string]string, db Database) MappingsReader

NewMappingReader constructs a MappingsReader instance.

func (MappingsReader) FromTenant

func (mr MappingsReader) FromTenant(ctx context.Context, tenant string) (map[string]restql.Mapping, error)

FromTenant fetch the mappings for the given tenant.

func (MappingsReader) ListTenants

func (mr MappingsReader) ListTenants(ctx context.Context) ([]string, error)

ListTenants fetch all tenants under which mappings are organized

type MappingsWriter

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

MappingsWriter is the entity that maps resource name to URL.

func NewMappingWriter

func NewMappingWriter(log restql.Logger, env domain.EnvSource, local map[string]map[string]string, db Database) MappingsWriter

NewMappingWriter creates an instance of MappingsWriter

func (*MappingsWriter) Write

func (mw *MappingsWriter) Write(ctx context.Context, tenant string, resource string, url string) error

Write sets a URL to a resource name under the given tenant

type QueryReader

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

A QueryReader get a query from local configuration file or a database instance.

func NewQueryReader

func NewQueryReader(log restql.Logger, local map[string]map[string][]string, db Database) QueryReader

NewQueryReader constructs a QueryReader from the given configuration and database.

func (QueryReader) Get

func (qr QueryReader) Get(ctx context.Context, namespace, id string, revision int) (restql.SavedQuery, error)

Get retrieves a query by its identity (namespace, id and revision), it first search the database and, if not found, in the configuration file.

func (QueryReader) ListNamespaces

func (qr QueryReader) ListNamespaces(ctx context.Context) ([]string, error)

ListNamespaces fetches all namespace on config, env and database

func (QueryReader) ListQueriesForNamespace

func (qr QueryReader) ListQueriesForNamespace(ctx context.Context, namespace string) (map[string][]restql.SavedQuery, error)

ListQueriesForNamespace fetches the queries under the given namespace, stored on config file, env or database.

func (QueryReader) ListQueryRevisions

func (qr QueryReader) ListQueryRevisions(ctx context.Context, namespace string, queryName string) ([]restql.SavedQuery, error)

ListQueryRevisions fetch revisions for a query on the given namespace, stored on the config file, env or database.

type QueryWriter

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

QueryWriter is the entity that create a new query revision when it is stored on the database.

func NewQueryWriter

func NewQueryWriter(log restql.Logger, local map[string]map[string][]string, db Database) QueryWriter

NewQueryWriter creates a QueryWriter instance

func (QueryWriter) Write

func (qw QueryWriter) Write(ctx context.Context, namespace, name, content string) error

Write creates a new query revision

Jump to

Keyboard shortcuts

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