Documentation
¶
Index ¶
- func BuildAndOrExpressionFromLinks(links AndOrLinks) (string, error)
- func MeasureDuration(Func func()) time.Duration
- func StringSliceElementsEqual(s1 []string, s2 []string) bool
- type AndOrLinks
- type Asset
- type AssetKey
- type AssetWithID
- type Cursor
- type ExpressionBuilder
- type ExpressionType
- type Graph
- func (g *Graph) AddAsset(assetType schema.AssetType, assetKey string) AssetKey
- func (g *Graph) AddRelation(from AssetKey, relationType schema.RelationKeyType, to AssetKey) Relation
- func (g *Graph) Assets() []Asset
- func (g *Graph) Copy() *Graph
- func (g *Graph) Equal(other *Graph) bool
- func (g *Graph) ExtractSchema() schema.SchemaGraph
- func (g *Graph) HasAsset(asset Asset) bool
- func (g *Graph) HasRelation(relation Relation) bool
- func (sg *Graph) MarshalJSON() ([]byte, error)
- func (g *Graph) Merge(other *Graph)
- func (g *Graph) Relations() []Relation
- func (sg *Graph) UnmarshalJSON(b []byte) error
- type GraphAPI
- type GraphBinder
- type GraphDB
- type GraphImporter
- type GraphJSON
- type GraphQueryResult
- type GraphUpdateRequestBody
- type GraphUpdater
- type GraphUpdatesBulk
- func (gub *GraphUpdatesBulk) Clear()
- func (gub *GraphUpdatesBulk) GetAssetRemovals() []Asset
- func (gub *GraphUpdatesBulk) GetAssetUpserts() []Asset
- func (gub *GraphUpdatesBulk) GetRelationRemovals() []Relation
- func (gub *GraphUpdatesBulk) GetRelationUpserts() []Relation
- func (gub *GraphUpdatesBulk) HasAssetRemoval(asset Asset) bool
- func (gub *GraphUpdatesBulk) HasAssetUpsert(asset Asset) bool
- func (gub *GraphUpdatesBulk) HasRelationRemoval(relation Relation) bool
- func (gub *GraphUpdatesBulk) HasRelationUpsert(relation Relation) bool
- func (gub *GraphUpdatesBulk) MarshalJSON() ([]byte, error)
- func (gub *GraphUpdatesBulk) RemoveAsset(asset Asset)
- func (gub *GraphUpdatesBulk) RemoveAssets(assets ...Asset)
- func (gub *GraphUpdatesBulk) RemoveRelation(relation Relation)
- func (gub *GraphUpdatesBulk) RemoveRelations(relations ...Relation)
- func (gub *GraphUpdatesBulk) UnmarshalJSON(bytes []byte) error
- func (gub *GraphUpdatesBulk) UpsertAsset(asset Asset)
- func (gub *GraphUpdatesBulk) UpsertAssets(assets ...Asset)
- func (gub *GraphUpdatesBulk) UpsertRelation(relation Relation)
- func (gub *GraphUpdatesBulk) UpsertRelations(relations ...Relation)
- type GraphUpdatesBulkJSON
- type Projection
- type Querier
- type QuerierResult
- type QueryLink
- type QueryNode
- type QueryNodeRepository
- type QueryRelation
- type QueryRelationRepository
- type Relation
- type RelationKey
- type RelationWithID
- type SQLQueryTranslator
- type SQLTranslation
- type SourceSubGraphUpdates
- type Statistics
- type Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildAndOrExpressionFromLinks ¶
func BuildAndOrExpressionFromLinks(links AndOrLinks) (string, error)
func MeasureDuration ¶
Types ¶
type AndOrLinks ¶
type AndOrLinks struct { And []AndOrLinks Or []AndOrLinks Link *QueryLink }
type AssetWithID ¶
func (AssetWithID) String ¶
func (a AssetWithID) String() string
type Cursor ¶
type Cursor interface { HasMore() bool Read(ctx context.Context, doc interface{}) error Close() error }
Cursor is a cursor over the results
type ExpressionBuilder ¶
type ExpressionBuilder struct { NodeRepository *QueryNodeRepository RelationRepository *QueryRelationRepository Aggregation bool ExpressionType ExpressionType }
func NewExpressionBuilder ¶
func NewExpressionBuilder(nodeRepo *QueryNodeRepository, relationRepo *QueryRelationRepository) *ExpressionBuilder
type ExpressionType ¶
type ExpressionType int
const ( NodeExprType ExpressionType = iota EdgeExprType ExpressionType = iota PropertyExprType ExpressionType = iota )
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph represent a Graph
func (*Graph) AddRelation ¶
func (g *Graph) AddRelation(from AssetKey, relationType schema.RelationKeyType, to AssetKey) Relation
AddRelation add a relation to the graph
func (*Graph) ExtractSchema ¶
func (g *Graph) ExtractSchema() schema.SchemaGraph
func (*Graph) HasRelation ¶
HasRelation return true if the relation is in the graph, false otherwise.
func (*Graph) MarshalJSON ¶
func (*Graph) UnmarshalJSON ¶
type GraphAPI ¶
type GraphAPI struct {
// contains filtered or unexported fields
}
GraphEmitter an emitter of full source graph
func NewGraphAPI ¶
NewGraphEmitter create an emitter of graph
func (*GraphAPI) ReadCurrentGraph ¶
ReadCurrentGraph read the current graph stored in graph kb
func (*GraphAPI) UpdateGraph ¶
func (gapi *GraphAPI) UpdateGraph(sg schema.SchemaGraph, updates GraphUpdatesBulk) error
type GraphBinder ¶
type GraphBinder struct {
// contains filtered or unexported fields
}
GraphBinder represent a graph builder which bind assets and relations to graph schema provided by the source
func NewGraphBinder ¶
func NewGraphBinder(graph *Graph) *GraphBinder
NewGraphBinder create an instance of graph binder
func (*GraphBinder) Bind ¶
func (gb *GraphBinder) Bind(asset string, assetType schema.AssetType)
Bind bind one asset to a type
func (*GraphBinder) Relate ¶
func (gb *GraphBinder) Relate(from string, relationType schema.RelationType, to string)
Relate relate one asset to another
type GraphDB ¶
type GraphDB interface { Close() error InitializeSchema() error UpdateGraph(source string, bulk *GraphUpdatesBulk) error ReadGraph(source string, graph *Graph) error FlushAll() error CountAssets() (int64, error) CountRelations() (int64, error) Query(ctx context.Context, query *query.QueryIL) (*GraphQueryResult, error) }
GraphDB an interface to a graph DB such as Arango or neo4j
type GraphImporter ¶
type GraphImporter struct {
// contains filtered or unexported fields
}
GraphImporter an interface for importers allowing to read current graph and push graph updates
func NewGraphImporter ¶
func NewGraphImporter(api *GraphAPI) *GraphImporter
NewGraphEmitter create an emitter of graph
func (*GraphImporter) CreateTransaction ¶
func (gi *GraphImporter) CreateTransaction(currentGraph *Graph) *Transaction
CreateTransaction create a full graph transaction. This kind of transaction will diff the new graph with previous version of it.
func (*GraphImporter) ReadCurrentGraph ¶
func (gi *GraphImporter) ReadCurrentGraph() (*Graph, error)
type GraphQueryResult ¶
type GraphQueryResult struct { Cursor Cursor Projections []Projection }
type GraphUpdateRequestBody ¶
type GraphUpdateRequestBody struct { Updates *GraphUpdatesBulk `json:"updates"` Schema schema.SchemaGraph `json:"schema"` }
type GraphUpdater ¶
type GraphUpdater struct {
// contains filtered or unexported fields
}
SourceListener represents the source listener waiting for source events
func NewGraphUpdater ¶
func NewGraphUpdater(graphDB GraphDB, schemaPersistor schema.Persistor) *GraphUpdater
NewGraphUpdater create a new instance of graph updater
func (*GraphUpdater) Listen ¶
func (sl *GraphUpdater) Listen(updatesC chan SourceSubGraphUpdates) chan struct{}
Listen events coming from the event bus
type GraphUpdatesBulk ¶
type GraphUpdatesBulk struct {
// contains filtered or unexported fields
}
GraphUpdatesBulk represent a bulk of asset and relation updates to perform on the graph
func GenerateGraphUpdatesBulk ¶
func GenerateGraphUpdatesBulk(previousGraph *Graph, newGraph *Graph) *GraphUpdatesBulk
GenerateGraphUpdatesBulk generate a graph update bulk by taking the difference between new graph and previous graph. It means the updates would transform previous graph into new graph.
func NewGraphUpdatesBulk ¶
func NewGraphUpdatesBulk() *GraphUpdatesBulk
NewGraphUpdatesBulk create an instance of graph updates
func (*GraphUpdatesBulk) Clear ¶
func (gub *GraphUpdatesBulk) Clear()
func (*GraphUpdatesBulk) GetAssetRemovals ¶
func (gub *GraphUpdatesBulk) GetAssetRemovals() []Asset
func (*GraphUpdatesBulk) GetAssetUpserts ¶
func (gub *GraphUpdatesBulk) GetAssetUpserts() []Asset
func (*GraphUpdatesBulk) GetRelationRemovals ¶
func (gub *GraphUpdatesBulk) GetRelationRemovals() []Relation
func (*GraphUpdatesBulk) GetRelationUpserts ¶
func (gub *GraphUpdatesBulk) GetRelationUpserts() []Relation
func (*GraphUpdatesBulk) HasAssetRemoval ¶
func (gub *GraphUpdatesBulk) HasAssetRemoval(asset Asset) bool
func (*GraphUpdatesBulk) HasAssetUpsert ¶
func (gub *GraphUpdatesBulk) HasAssetUpsert(asset Asset) bool
func (*GraphUpdatesBulk) HasRelationRemoval ¶
func (gub *GraphUpdatesBulk) HasRelationRemoval(relation Relation) bool
func (*GraphUpdatesBulk) HasRelationUpsert ¶
func (gub *GraphUpdatesBulk) HasRelationUpsert(relation Relation) bool
func (*GraphUpdatesBulk) MarshalJSON ¶
func (gub *GraphUpdatesBulk) MarshalJSON() ([]byte, error)
func (*GraphUpdatesBulk) RemoveAsset ¶
func (gub *GraphUpdatesBulk) RemoveAsset(asset Asset)
RemoveAsset create an operation to remove an asset
func (*GraphUpdatesBulk) RemoveAssets ¶
func (gub *GraphUpdatesBulk) RemoveAssets(assets ...Asset)
RemoveAssets create multiple asset removal operations
func (*GraphUpdatesBulk) RemoveRelation ¶
func (gub *GraphUpdatesBulk) RemoveRelation(relation Relation)
RemoveRelation create an operation to remove a relation
func (*GraphUpdatesBulk) RemoveRelations ¶
func (gub *GraphUpdatesBulk) RemoveRelations(relations ...Relation)
RemoveRelations create multiple relation removal operations
func (*GraphUpdatesBulk) UnmarshalJSON ¶
func (gub *GraphUpdatesBulk) UnmarshalJSON(bytes []byte) error
func (*GraphUpdatesBulk) UpsertAsset ¶
func (gub *GraphUpdatesBulk) UpsertAsset(asset Asset)
UpsertAsset create an operation to upsert an asset
func (*GraphUpdatesBulk) UpsertAssets ¶
func (gub *GraphUpdatesBulk) UpsertAssets(assets ...Asset)
UpsertAssets append multiple assets to upsert
func (*GraphUpdatesBulk) UpsertRelation ¶
func (gub *GraphUpdatesBulk) UpsertRelation(relation Relation)
UpsertRelation create an operation to upsert an relation
func (*GraphUpdatesBulk) UpsertRelations ¶
func (gub *GraphUpdatesBulk) UpsertRelations(relations ...Relation)
UpsertRelations create multiple relation upsert operations
type GraphUpdatesBulkJSON ¶
type GraphUpdatesBulkJSON struct { AssetUpserts []Asset `json:"asset_upserts"` AssetRemovals []Asset `json:"asset_removals"` RelationUpserts []Relation `json:"relation_upserts"` RelationRemovals []Relation `json:"relation_removals"` }
GraphUpdatesBulkJSON represent a bulk in JSON form
type Projection ¶
type Projection struct { Alias string ExpressionType ExpressionType }
type QuerierResult ¶
type QuerierResult struct { Cursor Cursor Projections []Projection Statistics Statistics }
type QueryNodeRepository ¶
type QueryNodeRepository struct { All []QueryNode Anonymous []QueryNode Named map[string]QueryNode NamedPosition map[string]int }
QueryNodeRepository represent a node repository
func NewQueryNodeRepository ¶
func NewQueryNodeRepository() *QueryNodeRepository
NewQueryNodeRepository create a node repository
func (*QueryNodeRepository) ByName ¶
func (qnr *QueryNodeRepository) ByName(name string) (*QueryNode, int)
ByName return the query node attached to given variable name
func (*QueryNodeRepository) Nodes ¶
func (qnr *QueryNodeRepository) Nodes() []QueryNode
Nodes return the list of nodes contained in repository
func (*QueryNodeRepository) PushNode ¶
func (qnr *QueryNodeRepository) PushNode(q *query.QueryNodePattern) (int, error)
PushNode push a node in the repository
type QueryRelation ¶
type QueryRelation struct {
Labels []string
}
QueryRelation represent a relation
type QueryRelationRepository ¶
type QueryRelationRepository struct { All []QueryRelation Anonymous []QueryRelation Named map[string]QueryRelation NamedPosition map[string]int }
QueryRelationRepository is a repository of relations
func NewQueryRelationRepository ¶
func NewQueryRelationRepository() *QueryRelationRepository
NewQueryRelationRepository create a relation repository
func (*QueryRelationRepository) ByName ¶
func (qnr *QueryRelationRepository) ByName(name string) (*QueryRelation, int)
ByName return the relation attached to given variable name
func (*QueryRelationRepository) PushRelation ¶
func (qnr *QueryRelationRepository) PushRelation(q *query.QueryRelationshipDetail) (int, error)
PushRelation push a relation into the repository
func (*QueryRelationRepository) Relations ¶
func (qnr *QueryRelationRepository) Relations() []QueryRelation
Relations return the list of relations contained in the repository
type RelationKey ¶
type RelationKey struct { Type schema.RelationKeyType `json:"type"` From AssetKey `json:"from"` To AssetKey `json:"to"` }
RelationKey a relation key of the KB
type RelationWithID ¶
type RelationWithID struct { ID string `json:"_id"` From string `json:"from_id"` To string `json:"to_id"` Type schema.RelationKeyType `json:"type"` }
func (RelationWithID) String ¶
func (r RelationWithID) String() string
type SQLQueryTranslator ¶
type SQLQueryTranslator struct { NodeRepository *QueryNodeRepository RelationRepository *QueryRelationRepository }
func NewSQLQueryTranslator ¶
func NewSQLQueryTranslator() *SQLQueryTranslator
func (*SQLQueryTranslator) Translate ¶
func (sqt *SQLQueryTranslator) Translate(queryIL *query.QueryIL) (*SQLTranslation, error)
type SQLTranslation ¶
type SQLTranslation struct { Query string ProjectionTypes []Projection }
type SourceSubGraphUpdates ¶
type SourceSubGraphUpdates struct { Updates GraphUpdatesBulk Schema schema.SchemaGraph Source string }
SourceSubGraphUpdates represents the updates to perform on a source subgraph
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction represent a transaction generating updates by diffing the provided graph against the previous version.
func (*Transaction) Bind ¶
func (cgt *Transaction) Bind(asset string, assetType schema.AssetType)
Bind bind one asset to an asset type from the schema
func (*Transaction) Commit ¶
func (cgt *Transaction) Commit() (*Graph, error)
Commit commit the transaction and gives ownership to the source for caching.
func (*Transaction) Relate ¶
func (cgt *Transaction) Relate(from string, relationType schema.RelationType, to string)
Relate create a relation between two assets