persistence

package
v4.0.0-rc103 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	FindMappingsForTenant(ctx context.Context, tenantID string) ([]restql.Mapping, error)
	FindQuery(ctx context.Context, namespace string, name string, revision int) (restql.SavedQuery, error)
}

Database defines the operations needed to fetch mappings and query from an external store.

func NewDatabase

func NewDatabase(log restql.Logger) (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]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.

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.

Jump to

Keyboard shortcuts

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