session

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: 18 Imported by: 0

Documentation

Overview

Package session manage db connection

Index

Constants

View Source
const (
	DBName = "kie"

	CollectionLabel         = "label"
	CollectionKV            = "kv"
	CollectionKVRevision    = "kv_revision"
	CollectionPollingDetail = "polling_detail"
	CollectionCounter       = "counter"
	CollectionView          = "view"
	DefaultTimeout          = 5 * time.Second
	DefaultValueType        = "text"
)

const for db name and collection name

View Source
const (
	MsgDBExists  = "already exists"
	MsgDuplicate = "duplicate key error collection"
)

Variables

View Source
var (
	ErrMissingDomain   = errors.New("domain info missing, illegal access")
	ErrMissingProject  = errors.New("project info missing, illegal access")
	ErrLabelNotExists  = errors.New("labels does not exits")
	ErrTooMany         = errors.New("key with labels should be only one")
	ErrKeyMustNotEmpty = errors.New("must supply key if you want to get exact one result")

	ErrIDIsNil         = errors.New("id is empty")
	ErrKeyIsNil        = errors.New("key must not be empty")
	ErrRootCAMissing   = errors.New("rootCAFile is empty in config file")
	ErrKVAlreadyExists = errors.New("kv already exists")

	ErrViewCreation = errors.New("can not create view")
	ErrViewUpdate   = errors.New("can not update view")
	ErrViewDelete   = errors.New("can not delete view")
	ErrViewNotExist = errors.New("view not exists")
	ErrViewFinding  = errors.New("view search error")
	ErrGetPipeline  = errors.New("can not get criteria")
)

db errors

View Source
var Timeout time.Duration

Timeout db operation time out

Functions

func CreateView

func CreateView(ctx context.Context, view, source string, pipeline mongo.Pipeline) error

CreateView run mongo db command to create view

func DropView

func DropView(ctx context.Context, view string) error

DropView deletes view

func EnsureDB

func EnsureDB()

EnsureDB build mongo db schema

func GetDB

func GetDB() *mongo.Database

GetDB get mongo db client

func Init

func Init() error

Init prepare params

func OpenSession

func OpenSession() *mgo.Session

Types

type CollectionInfo

type CollectionInfo struct {
	Options Options `json:"options"`
}

CollectionInfo is struct

func GetColInfo

func GetColInfo(ctx context.Context, name string) (*CollectionInfo, error)

GetColInfo get collection info

type Options

type Options struct {
	Pipeline []map[string]map[string]string `json:"pipeline"`
}

Options is struct

Jump to

Keyboard shortcuts

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