store

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: Apache-2.0 Imports: 20 Imported by: 1

README

store

DB

Yugabyte

CREATE KEYSPACE IF NOT EXISTS argus;
CREATE TABLE argus.gifnoc (
    bucket VARCHAR,
    id VARCHAR,
    data blob,
    PRIMARY KEY (bucket, id))
    WITH default_time_to_live = 300
    AND transactions = {'enabled': 'false'};

Documentation

Index

Constants

View Source
const (
	BucketFormatRegexSource = "^[0-9a-z][0-9a-z-]{1,61}[0-9a-z]$"
	OwnerFormatRegexSource  = "^.{10,60}$"
)

default input field validation regular expressions. Note: these values are configurable so please check the argus.yaml file if you're interested.

View Source
const (
	// TypeLabel is for labeling metrics; if there is a single metric for
	// successful queries, the typeLabel and corresponding type can be used
	// when incrementing the metric.
	TypeLabel  = "type"
	InsertType = "insert"
	DeleteType = "delete"
	ReadType   = "read"
	PingType   = "ping"
)
View Source
const (
	ItemOwnerHeaderKey  = "X-Midt-Owner"
	XmidtErrorHeaderKey = "X-Midt-Error"
)

Request and Response Headers.

View Source
const ElevatedAccessLevel = 1

ElevatedAccessLevel is the bascule attribute value found in requests that should be granted priviledged access to operations.

View Source
const IDFormatRegexSource = "^[0-9a-f]{64}$"

IDFormatRegexSource helps validate the ID on incoming requests.

Variables

View Source
var (
	ErrItemNotFound   = errors.New("Item at resource path not found")
	ErrJSONDecode     = errors.New("Error decoding JSON data from DB")
	ErrJSONEncode     = errors.New("Error encoding JSON data to send to DB")
	ErrQueryExecution = errors.New("Error occurred during DB query execution")
)

Sentinel internal errors.

View Source
var (
	ErrHTTPItemNotFound = &erraux.Error{Err: errors.New("Item not found"), Code: http.StatusNotFound}
	ErrHTTPOpFailed     = &erraux.Error{Err: errors.New("DB operation failed"), Code: http.StatusInternalServerError}
)

Sentinel errors to be used by the HTTP response error encoder.

View Source
var ErrCasting = errors.New("casting error due to middleware wiring mistake")

ErrCasting indicates there was (most likely) a middleware wiring mistake with the go-kit style encoders/decoders.

Functions

func FilterOwner added in v0.2.0

func FilterOwner(value map[string]OwnableItem, owner string) map[string]OwnableItem

func ProvideHandlers added in v0.3.10

func ProvideHandlers() fx.Option

ProvideHandlers fetches all dependencies and builds the four main handlers for this store.

func SanitizeError added in v0.3.13

func SanitizeError(err error) error

SanitizeError should be used by DB implementations to prevent exposing internal error data in HTTP responses. This method maps an internal error to their sanitized version which contains HTTP response information like code and debug header values. DB implementations should implement their own versions of this function when they need to look at implementation-specific errors to perform the mapping.

func Sha256HexDigest added in v0.3.10

func Sha256HexDigest(message string) string

Sha256HexDigest returns the SHA-256 hex digest of the given input.

Types

type BadRequestErr added in v0.3.6

type BadRequestErr struct {
	Message string
}

func (BadRequestErr) Error added in v0.3.6

func (bre BadRequestErr) Error() string

func (BadRequestErr) SanitizedError added in v0.6.0

func (bre BadRequestErr) SanitizedError() string

func (BadRequestErr) StatusCode added in v0.3.6

func (bre BadRequestErr) StatusCode() int

type ForbiddenRequestErr added in v0.3.8

type ForbiddenRequestErr struct {
	Message string
}

func (ForbiddenRequestErr) Error added in v0.3.8

func (f ForbiddenRequestErr) Error() string

func (ForbiddenRequestErr) StatusCode added in v0.3.8

func (f ForbiddenRequestErr) StatusCode() int

type GetAllItemsOperationErr added in v0.3.13

type GetAllItemsOperationErr struct {
	Err    error
	Bucket string
}

GetAllItemsOperationError is the ItemOperation counterpart for the getAllItems operation which applies to a group of items.

func (GetAllItemsOperationErr) Error added in v0.3.13

func (e GetAllItemsOperationErr) Error() string

func (GetAllItemsOperationErr) Unwrap added in v0.3.13

func (e GetAllItemsOperationErr) Unwrap() error

type GetLoggerFunc added in v0.6.0

type GetLoggerFunc func(context.Context) *zap.Logger

GetLoggerFunc is the function used to get a request-specific logger from its context.

type Handler

type Handler http.Handler

type InternalError added in v0.2.1

type InternalError struct {
	Reason    interface{}
	Retryable bool
}

func (InternalError) Error added in v0.2.1

func (ie InternalError) Error() string

func (InternalError) StatusCode added in v0.2.1

func (ie InternalError) StatusCode() int

type ItemOperationError added in v0.3.13

type ItemOperationError struct {
	Err       error
	Key       model.Key
	Operation string
}

ItemOperationError is a simple error wrapper for DB operations that apply to specific items. It provides a formatted message with context around the error.

func (ItemOperationError) Error added in v0.3.13

func (e ItemOperationError) Error() string

func (ItemOperationError) Unwrap added in v0.3.13

func (e ItemOperationError) Unwrap() error

type KeyItemPairRequest added in v0.2.0

type KeyItemPairRequest struct {
	model.Key
	OwnableItem
	Method string
}

type KeyNotFoundError

type KeyNotFoundError struct {
	Key model.Key
}

func (KeyNotFoundError) Error

func (knfe KeyNotFoundError) Error() string

func (KeyNotFoundError) StatusCode

func (knfe KeyNotFoundError) StatusCode() int

type OwnableItem added in v0.2.0

type OwnableItem struct {
	model.Item
	Owner string `json:"owner"`
}

type S

type S interface {
	Push(key model.Key, item OwnableItem) error
	Get(key model.Key) (OwnableItem, error)
	Delete(key model.Key) (OwnableItem, error)
	GetAll(bucket string) (map[string]OwnableItem, error)
}

type SanitizedError added in v0.3.13

type SanitizedError struct {
	// Err contains the raw error explaining the cause of the
	// failure event.
	Err error

	// ErrHTTP should contain some filtered version
	// of Err that can be safely used across API boundaries.
	// Two use cases include: hiding sensitive error data and
	// translating errors to better explain error events to API consumers.
	ErrHTTP *erraux.Error
}

func (SanitizedError) Error added in v0.3.13

func (s SanitizedError) Error() string

func (SanitizedError) Headers added in v0.3.13

func (s SanitizedError) Headers() http.Header

func (SanitizedError) SanitizedError added in v0.3.13

func (s SanitizedError) SanitizedError() string

func (SanitizedError) StatusCode added in v0.3.13

func (s SanitizedError) StatusCode() int

func (SanitizedError) Unwrap added in v0.3.13

func (s SanitizedError) Unwrap() error

type UserInputValidationConfig added in v0.5.0

type UserInputValidationConfig struct {
	ItemMaxTTL        time.Duration
	BucketFormatRegex string
	OwnerFormatRegex  string
	ItemDataMaxDepth  uint
}

Directories

Path Synopsis
db
Package inmem implements the store DAO interface.
Package inmem implements the store DAO interface.

Jump to

Keyboard shortcuts

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