kvsvc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateOrUpdate

func CreateOrUpdate(ctx context.Context, domain string, kv *model.KVDoc, project string) (*model.KVDoc, error)

CreateOrUpdate will create or update a key value record it first check label exists or not, and create labels if labels is first posted. if label exists, then get its latest revision, and update current revision, save the current label and its all key values to history collection then check key exists or not, then create or update it

func Delete

func Delete(kvID string, labelID string, domain string, project string) error

Delete delete kv,If the labelID is "", query the collection kv to get it domain=tenant 1.delete kv;2.add history

func DeleteKV

func DeleteKV(ctx context.Context, hexID primitive.ObjectID, project string) error

DeleteKV by kvID

func FindKV

func FindKV(ctx context.Context, domain string, project string, options ...FindOption) ([]*model.KVResponse, error)

FindKV get kvs by key, labels because labels has a a lot of combination, you can use WithDepth(0) to return only one kv which's labels exactly match the criteria

func FindKVByLabelID

func FindKVByLabelID(ctx context.Context, domain, labelID, key string, project string) ([]*model.KVDoc, error)

FindKVByLabelID get kvs by key and label id key can be empty, then it will return all key values if key is given, will return 0-1 key value

func KVExist

func KVExist(ctx context.Context, domain, key string, project string, options ...FindOption) (primitive.ObjectID, error)

KVExist supports you query by label map or labels id

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 WithKey

func WithKey(key string) FindOption

WithKey find by key

func WithLabelID

func WithLabelID(label string) FindOption

WithLabelID find kv by labelID

func WithLabels

func WithLabels(labels map[string]string) FindOption

WithLabels find kv by labels

func WithOutLabelField

func WithOutLabelField() FindOption

WithOutLabelField will clear all labels attributes in kv doc

func WithTimeout

func WithTimeout(d time.Duration) FindOption

WithTimeout will return err if execution take too long

type FindOptions

type FindOptions struct {
	ExactLabels bool
	Depth       int
	Key         string
	Labels      map[string]string
	LabelID     string
	ClearLabel  bool
	Timeout     time.Duration
}

FindOptions is option to find key value

type MongodbService

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

MongodbService operate data in mongodb

Jump to

Keyboard shortcuts

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