storage

package
v0.3.1-sandbox Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Migrations = map[string]*migrate.MemoryMigrationSource{
	dbal.DriverMySQL: {
		Migrations: []*migrate.Migration{
			{
				Id: "1",
				Up: []string{
					`CREATE TABLE IF NOT EXISTS rego_data (
    id 					INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
	collection 			VARCHAR(64) NOT NULL,
	pkey 				VARCHAR(64) NOT NULL,
	document		 	JSON,
	UNIQUE KEY rego_data_uidx_ck (collection, pkey)
)`,
				},
				Down: []string{
					"DROP TABLE rego_data",
				},
			},
		},
	},
	dbal.DriverPostgreSQL: {
		Migrations: []*migrate.Migration{
			{
				Id: "1",
				Up: []string{
					`CREATE TABLE IF NOT EXISTS rego_data (
    id 			SERIAL PRIMARY KEY,
	collection 	VARCHAR(64) NOT NULL,
	pkey 		VARCHAR(64) NOT NULL,
	document	JSON
)`,
					`CREATE UNIQUE INDEX rego_data_uidx_ck ON rego_data (collection, pkey)`,
				},
				Down: []string{
					"DROP TABLE rego_data",
				},
			},
		},
	},
}

Functions

This section is empty.

Types

type DeleteRequest

type DeleteRequest struct {
	Collection string
	Key        string
}

type GetRequest

type GetRequest struct {
	Collection string
	Key        string
	Value      interface{}
}

type Handler

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

func NewHandler

func NewHandler(s Manager, h herodot.Writer) *Handler

func (*Handler) Delete

func (*Handler) Get

func (*Handler) List

func (*Handler) Upsert

type ListRequest

type ListRequest struct {
	Collection string
	Value      interface{}
}

type Manager

type Manager interface {
	Get(ctx context.Context, collection string, key string, value interface{}) error
	List(ctx context.Context, collection string, value interface{}, limit, offset int) error
	Upsert(ctx context.Context, collection string, key string, value interface{}) error
	Delete(ctx context.Context, collection string, key string) error
	Storage(ctx context.Context, schema string, collections []string) (storage.Store, error)
}

type MemoryManager

type MemoryManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewMemoryManager

func NewMemoryManager() *MemoryManager

func (*MemoryManager) Delete

func (m *MemoryManager) Delete(_ context.Context, collection, key string) error

func (*MemoryManager) Get

func (m *MemoryManager) Get(_ context.Context, collection, key string, value interface{}) error

func (*MemoryManager) List

func (m *MemoryManager) List(ctx context.Context, collection string, value interface{}, limit, offset int) error

func (*MemoryManager) Storage

func (m *MemoryManager) Storage(ctx context.Context, schema string, collections []string) (storage.Store, error)

func (*MemoryManager) Upsert

func (m *MemoryManager) Upsert(_ context.Context, collection, key string, value interface{}) error

type Registry

type Registry interface {
	StorageManager() Manager
}

type SQLManager

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

func NewSQLManager

func NewSQLManager(db *sqlx.DB) *SQLManager

func (*SQLManager) CreateSchemas

func (m *SQLManager) CreateSchemas(db *sqlx.DB) (int, error)

func (*SQLManager) Delete

func (m *SQLManager) Delete(ctx context.Context, collection, key string) error

func (*SQLManager) Get

func (m *SQLManager) Get(ctx context.Context, collection, key string, value interface{}) error

func (*SQLManager) List

func (m *SQLManager) List(ctx context.Context, collection string, value interface{}, limit, offset int) error

func (*SQLManager) Storage

func (m *SQLManager) Storage(ctx context.Context, schema string, collections []string) (storage.Store, error)

func (*SQLManager) Upsert

func (m *SQLManager) Upsert(ctx context.Context, collection, key string, value interface{}) error

type UpsertRequest

type UpsertRequest struct {
	Collection string
	Key        string
	Value      interface{}
}

Jump to

Keyboard shortcuts

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