Documentation
¶
Index ¶
- Variables
- type DeleteGraphAssetRequestBody
- type DeleteGraphRelationRequestBody
- type GraphAPI
- type GraphAPIOptions
- type GraphClient
- func (gc *GraphClient) DeleteAssets(assets []knowledge.Asset) error
- func (gc *GraphClient) DeleteRelations(relations []knowledge.Relation) error
- func (gc *GraphClient) InsertAssets(assets []knowledge.Asset) error
- func (gc *GraphClient) InsertRelations(relations []knowledge.Relation) error
- func (gc *GraphClient) ReadCurrentGraph() (*knowledge.Graph, error)
- func (gc *GraphClient) UpdateSchema(sg schema.SchemaGraph) error
- type GraphUpdateRequestBody
- type PutGraphAssetRequestBody
- type PutGraphRelationRequestBody
- type PutGraphSchemaRequestBody
- type Transaction
Constants ¶
This section is empty.
Variables ¶
var ErrTooManyRequests = fmt.Errorf("Too Many Requests")
ErrTooManyRequests error representing too many requests to the API
Functions ¶
This section is empty.
Types ¶
type DeleteGraphAssetRequestBody ¶
DeleteGraphAssetRequestBody a request body for the asset removal
type DeleteGraphRelationRequestBody ¶
DeleteGraphRelationRequestBody a request body for the relation removal
type GraphAPI ¶
type GraphAPI struct {
// contains filtered or unexported fields
}
GraphAPI represent the graph API from a data source point of view
func NewGraphAPI ¶
func NewGraphAPI(options GraphAPIOptions) *GraphAPI
NewGraphAPI create an emitter of graph
func (*GraphAPI) CreateTransaction ¶
func (gapi *GraphAPI) CreateTransaction() (*Transaction, error)
CreateTransaction create a full graph transaction. This kind of transaction will diff the new graph with previous version of it.
type GraphAPIOptions ¶
type GraphAPIOptions struct { // URL to GraphKB URL string // Auth token for this data source. AuthToken string // Skip verifying the certificate when using https SkipVerify bool // The level of parallelization for streaming updates, i.e., number of HTTP requests sent in parallel. Parallelization int // The size of a chunk of updates, i.e., number of assets or relations sent in one HTTP request to the streaming API. ChunkSize int // Max number of retries before giving up (default is 10) MaxRetries int // The base delay between retries (default is 5 seconds). This delay is multiplied by the backoff factor. RetryDelay time.Duration // The backoff factor (default is 1.01) RetryBackoffFactor float64 // The API stores the lastly pushed graph in memory to avoid fetching the entire data at every run which can be heavy on // DB if importers run very incrementally. The anti entropy duration is a duration before forcing a synchronization against // the server even though the graph is still stored in memory. AntiEntropyDuration time.Duration }
GraphAPIOptions options to pass to build graph API
type GraphClient ¶
type GraphClient struct {
// contains filtered or unexported fields
}
GraphClient is a client of the GraphKB API
func NewGraphClient ¶
func NewGraphClient(URL, authToken string, skipVerify bool) *GraphClient
NewGraphClient create a client of the GraphKB API
func (*GraphClient) DeleteAssets ¶ added in v0.0.25
func (gc *GraphClient) DeleteAssets(assets []knowledge.Asset) error
DeleteAssets send asset removal operations to the API
func (*GraphClient) DeleteRelations ¶ added in v0.0.25
func (gc *GraphClient) DeleteRelations(relations []knowledge.Relation) error
DeleteRelations send relation removal operations to the API
func (*GraphClient) InsertAssets ¶ added in v0.0.25
func (gc *GraphClient) InsertAssets(assets []knowledge.Asset) error
InsertAssets send asset insert operations to the API
func (*GraphClient) InsertRelations ¶ added in v0.0.25
func (gc *GraphClient) InsertRelations(relations []knowledge.Relation) error
InsertRelations send relation insert operations to the API
func (*GraphClient) ReadCurrentGraph ¶
func (gc *GraphClient) ReadCurrentGraph() (*knowledge.Graph, error)
ReadCurrentGraph read the current graph stored in graph kb
func (*GraphClient) UpdateSchema ¶
func (gc *GraphClient) UpdateSchema(sg schema.SchemaGraph) error
UpdateSchema send a graph schema update to the API
type GraphUpdateRequestBody ¶
type GraphUpdateRequestBody struct { Updates *knowledge.GraphUpdatesBulk `json:"updates"` Schema schema.SchemaGraph `json:"schema"` }
GraphUpdateRequestBody a request body for the graph update API
type PutGraphAssetRequestBody ¶
PutGraphAssetRequestBody a request body for the asset upsert
type PutGraphRelationRequestBody ¶
PutGraphRelationRequestBody a request body for the relation upsert
type PutGraphSchemaRequestBody ¶
type PutGraphSchemaRequestBody struct {
Schema schema.SchemaGraph `json:"schema"`
}
PutGraphSchemaRequestBody a request body for the schema update
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() 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