storage

package
v0.0.0-...-add61a3 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

* Copyright (c) 2019 Uroš Hercog <uros@orcus.network> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrItemNotFound         = errors.New("item not found")
	ErrItemNotUpdated       = errors.New("item not updated")
	ErrItemRevisionConflict = errors.New("item revision conflict")
	ErrItemExists           = errors.New("item exists")
	ErrInternal             = errors.New("internal error")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Type string `yaml:"type"`
	Host string `yaml:"host"`
	Port int    `yaml:"port"`
	User string `yaml:"user"`
	Pass string `yaml:"pass"`
	DB   string `yaml:"db"`
}

type Storer

type Storer interface {
	// Find searches for items which match the provided query. If it does not find any items
	// it should not return an error, but rather an empty slice. It should not return the
	// deleted items.
	Find(ctx context.Context, namespace, key string, item interface{}) error
	// Upsert stores a new item in the storage backend. If an id for an item is already set,
	// the function replaces the item.
	// The inserting of the list of items should happen atomically.
	Upsert(ctx context.Context, namespace, key string, item interface{}) error
	// Remove should remove the item from the store. This can be implemented
	// with a flag or actually removing the item.
	// If an item with the given id does not exist, it should return an error.
	Remove(ctx context.Context, namespace, key string) error
	// name returns the identifier of the storer
	Name() string
}

Storer interface provides a way to easily implement any backend storage. It's heavily inspired by the rest-layer framework's storer implementation (https://github.com/rs/rest-layer).

type StorerFactory

type StorerFactory func(*zap.Logger, *Config) (Storer, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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