Documentation ¶
Index ¶
- Constants
- Variables
- type Action
- type DGClient
- func (s DGClient) Close() error
- func (s DGClient) CreateEntity(meta string, data map[string]interface{}) (string, error)
- func (s DGClient) CreateOrDeleteEdge(fromType string, fromUID string, toType string, toUID string, rel string, ...) error
- func (s DGClient) CreateSchema(sm Schema) error
- func (s DGClient) DeleteEntity(uuid string) error
- func (s DGClient) DropSchema(name string) error
- func (s DGClient) ExecuteDgraphQuery(query string) (map[string]interface{}, error)
- func (s DGClient) GetAllByClusterAndType(meta string, cluster string) (map[string]interface{}, error)
- func (s DGClient) GetCacheContainsDBSchema() (*lru.Cache, error)
- func (s DGClient) GetEntity(uuid string) (map[string]interface{}, error)
- func (s DGClient) GetQueryResult(query string) (map[string]interface{}, error)
- func (s DGClient) GetSchemaFromCache(cache *lru.Cache) ([]*api.SchemaNode, error)
- func (s DGClient) GetSchemaFromDB() ([]*api.SchemaNode, error)
- func (s DGClient) RemoveDBSchemaFromCache(cache *lru.Cache)
- func (s DGClient) UpdateEntity(uuid string, data map[string]interface{}, option ...util.OptionContext) error
- type IDGClient
- type Schema
Constants ¶
const CacheKey = "dbSchema"
CacheKey - Define key name for LruCache
Variables ¶
var InitLruCacheDBSchema bool
InitLruCacheDBSchema - a flag to indicate if LruCache has initial DBSchema when server starts
var LruCache *lru.Cache
LruCache - Define type LRU Cache
Functions ¶
This section is empty.
Types ¶
type DGClient ¶
type DGClient struct {
// contains filtered or unexported fields
}
DGClient will run query or command on dgraph
func NewDGClient ¶
NewDGClient create client instance TODO: consider to return single client stub without close connection
func (DGClient) CreateEntity ¶
CreateEntity - create entity
func (DGClient) CreateOrDeleteEdge ¶
func (s DGClient) CreateOrDeleteEdge(fromType string, fromUID string, toType string, toUID string, rel string, op Action) error
CreateOrDeleteEdge - create or remove edge
func (DGClient) CreateSchema ¶
CreateSchema - create index
func (DGClient) DeleteEntity ¶
DeleteEntity - delete entity by uuid
func (DGClient) DropSchema ¶
DropSchema remove db schema by name
func (DGClient) ExecuteDgraphQuery ¶
ExecuteDgraphQuery - Takes a dgraph query as a string and executes on a dgraph instance
func (DGClient) GetAllByClusterAndType ¶
func (s DGClient) GetAllByClusterAndType(meta string, cluster string) (map[string]interface{}, error)
GetAllByClusterAndType - query to get result by filter edge
func (DGClient) GetCacheContainsDBSchema ¶
GetCacheContainsDBSchema - Get cache which contains db schema
func (DGClient) GetQueryResult ¶
GetQueryResult - get Query Results
func (DGClient) GetSchemaFromCache ¶
func (s DGClient) GetSchemaFromCache(cache *lru.Cache) ([]*api.SchemaNode, error)
GetSchemaFromCache - Get db schema from cache
func (DGClient) GetSchemaFromDB ¶
func (s DGClient) GetSchemaFromDB() ([]*api.SchemaNode, error)
GetSchemaFromDB - get all predicates
func (DGClient) RemoveDBSchemaFromCache ¶
func (s DGClient) RemoveDBSchemaFromCache(cache *lru.Cache)
RemoveDBSchemaFromCache - remove DBSchema key from the Cache
func (DGClient) UpdateEntity ¶
func (s DGClient) UpdateEntity(uuid string, data map[string]interface{}, option ...util.OptionContext) error
UpdateEntity - update entity
type IDGClient ¶
type IDGClient interface { GetCacheContainsDBSchema() (*lru.Cache, error) GetSchemaFromCache(cache *lru.Cache) ([]*api.SchemaNode, error) RemoveDBSchemaFromCache(cache *lru.Cache) GetSchemaFromDB() ([]*api.SchemaNode, error) CreateSchema(sm Schema) error DropSchema(name string) error GetEntity(uuid string) (map[string]interface{}, error) GetAllByClusterAndType(meta string, cluster string) (map[string]interface{}, error) DeleteEntity(uuid string) error CreateEntity(meta string, data map[string]interface{}) (string, error) CreateOrDeleteEdge(fromType string, fromUID string, toType string, toUID string, rel string, op Action) error UpdateEntity(uuid string, data map[string]interface{}, option ...util.OptionContext) error GetQueryResult(query string) (map[string]interface{}, error) Close() error ExecuteDgraphQuery(query string) (map[string]interface{}, error) }
IDGClient ... define interface to DGClient
type Schema ¶
type Schema struct { Predicate string `json:"predicate"` Type string `json:"type"` List bool `json:"list,omitempty"` Index bool `json:"index,omitempty"` Upsert bool `json:"upsert,omitempty"` Count bool `json:"count,omitempty"` Reverse bool `json:"reverse,omitempty"` Tokenizer []string `json:"tokenizer,omitempty"` }
Schema dgraph database schema