Service Package Methods and Functions
NewService
NewService initializes a new Service with worker pools for both Neo4j and PostgreSQL.
Parameters:
graphClient: A neo4j database client.
relationalClient: A SQL database client.
Returns:
*Service: A new instance of service.
Ping
Ping checks the connectivity to the Neo4j database.
Parameters:
ctx: Context for the method.
Returns:
error: Any errors from the method.
Stop
Stop gracefully shuts down the worker pools.
Parameters:
s: A Service instance.
WaitForGraphCUDJobs
WaitForGraphCUDJobs waits for all Create/Update/Delete jobs to complete.
Parameters:
s: A Service instance.
WaitForGraphReadJobs
WaitForGraphReadJobs waits for all Read jobs to complete.
Parameters:
s: A Service instance.
WaitForRelationalJobs
WaitForRelationalJobs waits for all PostgreSQL jobs to complete.
Parameters:
s: A Service instance.
convertToSource
convertToSource determines which domain object a GraphNode represents and returns it as DatabaseInterface.
CreateNode
CreateNode creates a node in the database and returns a promise of success. The first promise resolves when the node is created in the relational database. The second promise resolves when the node is created in the graph database.
Parameters:
data: An instance of a database.
Returns:
promise.Promise[bool]: Promise that will Reject/Resolve SQL database command.
promise.Promise[bool]: Promise that will Reject/Resolve Neo4j database command.
UpdateNode
UpdateNode updates a node in the database and returns a promise of success.
Parameters:
data: An instance of a database.
Returns:
promise.Promise[bool]: Promise that will Reject/Resolve SQL database command.
promise.Promise[bool]: Promise that will Reject/Resolve Neo4j database command.
DeleteNode
DeleteNode deletes a node by ID and returns a promise of success.
Parameters:
typeString: Used in SQL query to determine table to delete from.
id: ID to match.
Returns:
promise.Promise[bool]: Promise that will Reject/Resolve SQL database command.
promise.Promise[bool]: Promise that will Reject/Resolve Neo4j database command.
CreateEdge
CreateEdge creates an edge in the database and returns a promise of success.
Parameters:
edge: The GraphEdge to create.
Returns:
promise.Promise[bool]: Promise that will Reject/Resolve Neo4j database command.
UpdateEdge
UpdateEdge updates an existing edge and returns a promise of success.
Parameters:
edge: The GraphEdge to update.
Returns:
promise.Promise[bool]: Promise that will Reject/Resolve Neo4j database command.
DeleteEdge
DeleteEdge deletes an edge from the database and returns a promise of success.
Parameters:
edge: The GraphEdge to delete.
Returns:
promise.Promise[bool]: Promise for that will Resolve/Reject Neo4j database command.
Read
Read executes a database query based on the request passed in.
Parameters:
request: Provides information about the request, including if it is a Neo4j or SQL request.
Returns:
promise.Promise[[]graph.DatabaseInterface]: A Promise that will or Reject/Resolve.
ReadGraph
ReadGraph executes a graph query on Neo4j.
Parameters:
request: Provides information about the request.
Returns:
promise.Promise[[]graph.DatabaseInterface]: A Promise that will or Reject/Resolve.
ReadRelational
ReadRelational executes a relational query on PostgreSQL.
Parameters:
request: Provides information about the request.
Returns:
promise.Promise[[]graph.DatabaseInterface]: A Promise that will or Reject/Resolve.
ExecuteCustomUpdatePromise
ExecuteCustomUpdatePromise executes a custom Cypher update and returns updated GraphData.
Parameters:
cypher: The cyper to execute.
Returns:
promise.Promise[*graph.GraphData]: A Promise that will or Reject/Resolve.
EnqueueCUDJob
EnqueueCUDJob enqueues a write job (Create/Update/Delete) to the worker pool.
Parameters:
commands: A slice of CypherCommands.
EnqueueReadJob
EnqueueReadJob enqueues a read job to the worker pool.
Parameters:
commands: A slice of CypherCommands.
EnqueueRelationalJob
EnqueueRelationalJob enqueues a job to the relational worker pool.
Parameters:
commands: A slice of SQLCommands.
NewRAGReadService
NewRAGReadService initializes a new RAGReadService with a read-only worker pool.
Stop
Stop gracefully shuts down the read pool.
WaitForReadJobs
WaitForReadJobs waits for all outstanding read jobs to complete.
Read
Read executes a read operation and returns a promise of GraphData. This is intended to be called by a RAG pipeline to retrieve graph context.
Parameters:
request: Provides information about the request.
Returns:
promise.Promise[*graph.GraphData]: A Promise that will or Reject/Resolve.
enqueueReadJob
enqueueReadJob enqueues a read-only job to the worker pool.
Parameters:
commands: A slice of CypherCommands.