Documentation
¶
Index ¶
- Constants
- Variables
- func GetContextValueDatabase(ctx context.Context, key interface{}) database.Database
- func GetMsgFromDB(db database.Database, key []byte, msg proto.Message) error
- func GetMsgFromIterator(it iterator.Iterator, msg proto.Message) error
- func GetMsgFromParam(params graphql.ResolveParams, paramName string, msg proto.Message) error
- func GetResultError(result *graphql.Result) error
- func GraphQLFormattedErrorArr2Error(errs []gqlerrors.FormattedError) error
- func MakeGraphQLErrorResult(err error) *graphql.Result
- func MakeMsgFromResult(result *graphql.Result, msg proto.Message) error
- func MakeMsgFromResultEx(result *graphql.Result, name string, msg proto.Message) error
- func MakeObjFromResult(result *graphql.Result, obj interface{}) error
- func MakeParamsFromMsg(params map[string]interface{}, paramName string, msg proto.Message) error
- func Msg2Map(msg proto.Message) map[string]interface{}
- func ParseQuery(schema *graphql.Schema, query string, name string) (*ast.Document, []gqlerrors.FormattedError)
- func PutMsg2DB(db database.Database, key []byte, msg proto.Message) error
- type AnkaDB
- type BaseDBLogic
- func (logic *BaseDBLogic) GetScheme() *graphql.Schema
- func (logic *BaseDBLogic) Query(ctx context.Context, request string, values map[string]interface{}) (*graphql.Result, error)
- func (logic *BaseDBLogic) QueryTemplate(ctx context.Context, templateName string, values map[string]interface{}) (*graphql.Result, error)
- func (logic *BaseDBLogic) SetQueryTemplate(templateName string, request string) error
- type Config
- type DBConfig
- type DBLogic
- type DBMgr
- type FuncAnkaDBEvent
- type FuncAnkaDBForEach
- type FuncOnQueryStream
- type SnapshotMgr
Constants ¶
const AnkaDBCoreVersion = "v0.3.35"
AnkaDBCoreVersion - ankadb core version
const RequestIDKey = requestID("ankadb")
Variables ¶
var ( // ErrGRPCListen - grpc service listen err ErrGRPCListen = errors.New("grpc service listen err") // ErrHTTPListen - http service listen err ErrHTTPListen = errors.New("http service listen err") // ErrLoadFileReadSize - loadfile invalid file read size ErrLoadFileReadSize = errors.New("loadfile invalid file read size") // ErrHTTPNoQuery - HTTP no query ErrHTTPNoQuery = errors.New("HTTP no query") // ErrCtxAnkaDB - context has not ankadb ErrCtxAnkaDB = errors.New("context has not ankadb") // ErrCtxCurDB - context has not currentdb ErrCtxCurDB = errors.New("context has not currentdb") // ErrQuertParams - query params err ErrQuertParams = errors.New("query params err") // ErrQuertResultDecode - query result decode err ErrQuertResultDecode = errors.New("query result decode err") // ErrCtxSnapshotMgr - query get snapshotMgr from err ErrCtxSnapshotMgr = errors.New("query get snapshotMgr from err") // ErrNotFoundDB - not found db ErrNotFoundDB = errors.New("not found db") // ErrNotFoundKey - not found key ErrNotFoundKey = errors.New("not found key") // ErrInvalidEvent - invalid event ErrInvalidEvent = errors.New("invalid event") // ErrNotFoundTemplate - not found template ErrNotFoundTemplate = errors.New("not found template") // ErrNotInit - not initialization ErrNotInit = errors.New("not initialization") // ErrParamIsNotMap - param is not a map ErrParamIsNotMap = errors.New("param is not a map") // ErrResultIsNotMap - result is not a map ErrResultIsNotMap = errors.New("result is not a map") // ErrDuplicateDB - duplicate name for database ErrDuplicateDB = errors.New("duplicate name for database") )
var (
// EventOnStarted - onStarted
EventOnStarted = "onstarted"
)
Functions ¶
func GetContextValueDatabase ¶
GetContextValueDatabase -
func GetMsgFromDB ¶
GetMsgFromDB - get protobuf message from database
func GetMsgFromIterator ¶ added in v0.3.29
GetMsgFromIterator - get protobuf message from iterator.Iterator
func GetMsgFromParam ¶
GetMsgFromParam - get protobuf message from param
func GetResultError ¶ added in v0.2.8
GetResultError - get result error
func GraphQLFormattedErrorArr2Error ¶ added in v0.3.26
func GraphQLFormattedErrorArr2Error(errs []gqlerrors.FormattedError) error
GraphQLFormattedErrorArr2Error - []gqlerrors.FormattedError to error
func MakeGraphQLErrorResult ¶
MakeGraphQLErrorResult -
func MakeMsgFromResult ¶
MakeMsgFromResult - make protobuf object from graphql.Result
func MakeMsgFromResultEx ¶ added in v0.3.26
MakeMsgFromResultEx - make protobuf object from graphql.Result
func MakeObjFromResult ¶
MakeObjFromResult - make object from graphql.Result
func MakeParamsFromMsg ¶
MakeParamsFromMsg - change protobuf message to param
func ParseQuery ¶ added in v0.3.26
func ParseQuery(schema *graphql.Schema, query string, name string) (*ast.Document, []gqlerrors.FormattedError)
ParseQuery - parse graphql query
Types ¶
type AnkaDB ¶
type AnkaDB interface {
// Start - start service
Start(ctx context.Context) error
// Query - query
Query(ctx context.Context, request string, values map[string]interface{}) (*graphql.Result, error)
// SetQueryTemplate - set query template
SetQueryTemplate(templateName string, request string) error
// Get - get value
Get(ctx context.Context, dbname string, key string) ([]byte, error)
// Set - set value
Set(ctx context.Context, dbname string, key string, value []byte) error
// Delete - deletes the key from database
Delete(ctx context.Context, dbname string, key string) error
// GetEx - get value
GetEx(ctx context.Context, dbname string, key []byte) ([]byte, error)
// SetEx - set value
SetEx(ctx context.Context, dbname string, key []byte, value []byte) error
// Delete - deletes the key from database
DeleteEx(ctx context.Context, dbname string, key []byte) error
// ForEachWithPrefix - for each with prefix
ForEachWithPrefix(ctx context.Context, dbname string, prefix string, foreach FuncAnkaDBForEach) error
// RegEventFunc - register a function for event
RegEventFunc(event string, eventfunc FuncAnkaDBEvent) error
// GetConfig - get config
GetConfig() *Config
// GetLogic - get DBLogic
GetLogic() DBLogic
// GetDBMgr - get DBMgr
GetDBMgr() DBMgr
// GetDatabase - get databse with dbname
GetDatabase(dbname string) database.Database
// AddDatabase - add database
AddDatabase(dbcfg DBConfig) error
}
AnkaDB - AnkaDB interface
func GetContextValueAnkaDB ¶
GetContextValueAnkaDB -
type BaseDBLogic ¶ added in v0.3.26
type BaseDBLogic struct {
// contains filtered or unexported fields
}
BaseDBLogic - base DBLogic
func NewBaseDBLogic ¶ added in v0.3.26
func NewBaseDBLogic(cfg graphql.SchemaConfig) (*BaseDBLogic, error)
NewBaseDBLogic - new BaseDBLogic
func (*BaseDBLogic) GetScheme ¶ added in v0.3.26
func (logic *BaseDBLogic) GetScheme() *graphql.Schema
GetScheme - get GraphQL scheme
func (*BaseDBLogic) Query ¶ added in v0.3.26
func (logic *BaseDBLogic) Query(ctx context.Context, request string, values map[string]interface{}) (*graphql.Result, error)
Query - query graphql request string
func (*BaseDBLogic) QueryTemplate ¶ added in v0.3.26
func (logic *BaseDBLogic) QueryTemplate(ctx context.Context, templateName string, values map[string]interface{}) (*graphql.Result, error)
QueryTemplate - query graphql with template
func (*BaseDBLogic) SetQueryTemplate ¶ added in v0.3.26
func (logic *BaseDBLogic) SetQueryTemplate(templateName string, request string) error
SetQueryTemplate - set query template
type Config ¶
type Config struct {
AddrGRPC string `yaml:"addrgrpc"`
PathDBRoot string `yaml:"pathdbroot"`
AddrHTTP string `yaml:"addrhttp"`
ListDB []DBConfig `yaml:"listdb"`
}
Config -
type DBConfig ¶
type DBConfig struct {
Name string `yaml:"name"`
Engine string `yaml:"engine"`
PathDB string `yaml:"pathdb"`
}
DBConfig -
type DBLogic ¶
type DBLogic interface {
// GetScheme - get GraphQL scheme
GetScheme() *graphql.Schema
// Query - query graphql request string
Query(ctx context.Context, request string, values map[string]interface{}) (*graphql.Result, error)
// QueryTemplate - query graphql with template
QueryTemplate(ctx context.Context, templateName string, values map[string]interface{}) (*graphql.Result, error)
// SetQueryTemplate - set query template
SetQueryTemplate(templateName string, request string) error
}
DBLogic -
type DBMgr ¶
type DBMgr interface {
AddDB(cfg DBConfig) error
GetDB(name string) database.Database
GetMgrSnapshot(name string) *SnapshotMgr
}
DBMgr -
type FuncAnkaDBEvent ¶ added in v0.3.13
FuncAnkaDBEvent - func event
type FuncAnkaDBForEach ¶ added in v0.3.30
FuncAnkaDBForEach - func event
type FuncOnQueryStream ¶
type FuncOnQueryStream func(*pb.ReplyQuery)
FuncOnQueryStream - use in DBLogic.OnQueryStream
type SnapshotMgr ¶
type SnapshotMgr struct {
// contains filtered or unexported fields
}
SnapshotMgr - key list snapshot
func (*SnapshotMgr) Add ¶
func (mgr *SnapshotMgr) Add(pSnapshot *pb.Snapshot) (int64, error)
Add - add snapshot
func (*SnapshotMgr) Get ¶
func (mgr *SnapshotMgr) Get(snapshotid int64) *pb.Snapshot
Get - get snapshot
func (*SnapshotMgr) NewSnapshot ¶
func (mgr *SnapshotMgr) NewSnapshot(prefix []byte) (*pb.Snapshot, error)
NewSnapshot - new snapshot