service

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	KVService       KV
	HistoryService  History
	TrackService    Track
	RevisionService Revision
	DBInit          Init
)

services

View Source
var (
	ErrKeyNotExists     = errors.New("can not find any key value")
	ErrRecordNotExists  = errors.New("can not find any polling data")
	ErrRevisionNotExist = errors.New("revision does not exist")
	ErrAliasNotGiven    = errors.New("label alias not given")
)

db errors

Functions

This section is empty.

Types

type FindOption

type FindOption func(*FindOptions)

FindOption is functional option to find key value

func WithDepth

func WithDepth(d int) FindOption

WithDepth if you use greedy match this can specify the match depth

func WithExactLabels

func WithExactLabels() FindOption

WithExactLabels tell model service to return only one kv matches the labels

func WithID

func WithID(id string) FindOption

WithID find by kvID

func WithKey

func WithKey(key string) FindOption

WithKey find by key

func WithLabelFormat

func WithLabelFormat(label string) FindOption

WithLabelFormat find kv by label string

func WithLabels

func WithLabels(labels map[string]string) FindOption

WithLabels find kv by labels

func WithLimit

func WithLimit(l int64) FindOption

WithLimit tells service paging limit

func WithOffset

func WithOffset(os int64) FindOption

WithOffset tells service paging offset

func WithOutLabelField

func WithOutLabelField() FindOption

WithOutLabelField will clear all labels attributes in kv doc

func WithStatus

func WithStatus(status string) FindOption

WithStatus enabled/disabled

func WithTimeout

func WithTimeout(d time.Duration) FindOption

WithTimeout will return err if execution take too long

type FindOptions

type FindOptions struct {
	ExactLabels bool
	Status      string
	Depth       int
	ID          string
	Key         string
	Labels      map[string]string
	LabelFormat string
	ClearLabel  bool
	Timeout     time.Duration
	Offset      int64
	Limit       int64
}

FindOptions is option to find key value

func NewDefaultFindOpts

func NewDefaultFindOpts() FindOptions

NewDefaultFindOpts return default options

type History

type History interface {
	GetHistory(ctx context.Context, keyID string, options ...FindOption) (*model.KVResponse, error)
}

History provide api of History entity

type Init

type Init func() error

Init init db session

type KV

type KV interface {
	//below 3 methods is usually for admin console
	Create(ctx context.Context, kv *model.KVDoc) (*model.KVDoc, error)
	Update(ctx context.Context, kv *model.UpdateKVRequest) (*model.KVDoc, error)
	List(ctx context.Context, domain, project string, options ...FindOption) (*model.KVResponse, error)
	//FindOneAndDelete deletes one kv by id and return the deleted kv as these appeared before deletion
	FindOneAndDelete(ctx context.Context, kvID string, domain, project string) (*model.KVDoc, error)
	//FindManyAndDelete deletes multiple kvs and return the deleted kv list as these appeared before deletion
	FindManyAndDelete(ctx context.Context, kvIDs []string, domain, project string) ([]*model.KVDoc, error)
	//Get return kv by id
	Get(ctx context.Context, request *model.GetKVRequest) (*model.KVDoc, error)
	//KV is a resource of kie, this api should return kv resource number by domain id
	Total(ctx context.Context, domain string) (int64, error)
}

KV provide api of KV entity

type Revision

type Revision interface {
	GetRevision(ctx context.Context, domain string) (int64, error)
}

Revision is global revision number management

type Track

type Track interface {
	CreateOrUpdate(ctx context.Context, detail *model.PollingDetail) (*model.PollingDetail, error)
	GetPollingDetail(ctx context.Context, detail *model.PollingDetail) ([]*model.PollingDetail, error)
}

History provide api of History entity

type View

type View interface {
	Create(ctx context.Context, viewDoc *model.ViewDoc, options ...FindOption) error
	Update(ctx context.Context, viewDoc *model.ViewDoc) error
	//TODO
	List(ctx context.Context, domain, project string, options ...FindOption) ([]*model.ViewDoc, error)
	GetCriteria(ctx context.Context, viewName, domain, project string) (map[string]map[string]string, error)
	GetContent(ctx context.Context, id, domain, project string, options ...FindOption) ([]*model.KVResponse, error)
}

View create update and get view data

Directories

Path Synopsis
kv
session
Package session manage db connection
Package session manage db connection

Jump to

Keyboard shortcuts

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