Product Help

Service Package Methods and Functions

NewService

func NewService(graphClient *client.Neo4jClient, relationalClient *client.RelationalClient, logger *logrus.Logger) *Service

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

func (s *Service) Ping(ctx context.Context) error

Ping checks the connectivity to the Neo4j database.

Parameters:

  • ctx: Context for the method.

Returns:

  • error: Any errors from the method.

Stop

func (s *Service) Stop()

Stop gracefully shuts down the worker pools.

Parameters:

  • s: A Service instance.

WaitForGraphCUDJobs

func (s *Service) WaitForGraphCUDJobs()

WaitForGraphCUDJobs waits for all Create/Update/Delete jobs to complete.

Parameters:

  • s: A Service instance.

WaitForGraphReadJobs

func (s *Service) WaitForGraphReadJobs()

WaitForGraphReadJobs waits for all Read jobs to complete.

Parameters:

  • s: A Service instance.

WaitForRelationalJobs

func (s *Service) WaitForRelationalJobs()

WaitForRelationalJobs waits for all PostgreSQL jobs to complete.

Parameters:

  • s: A Service instance.

convertToSource

func convertToSource(node *graph.GraphNode, row map[string]interface{}) (graph.DatabaseInterface, error)

convertToSource determines which domain object a GraphNode represents and returns it as DatabaseInterface.

CreateNode

func (s *Service) CreateNode(data graph.DatabaseInterface) (promise.Promise[bool], promise.Promise[bool])

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

func (s *Service) UpdateNode(data graph.DatabaseInterface) (promise.Promise[bool], promise.Promise[bool])

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

func (s *Service) DeleteNode(typeString, id string) (promise.Promise[bool], promise.Promise[bool])

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

func (s *Service) CreateEdge(edge *graph.GraphEdge) promise.Promise[bool]

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

func (s *Service) UpdateEdge(edge *graph.GraphEdge) promise.Promise[bool]

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

func (s *Service) DeleteEdge(edge *graph.GraphEdge) promise.Promise[bool]

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

func (s *Service) Read(request ReadRequest) promise.Promise[[]graph.DatabaseInterface]

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

func (s *Service) ReadGraph(request ReadGraphRequest) promise.Promise[[]graph.DatabaseInterface]

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

func (s *Service) ReadRelational( query string, params map[string]interface{}, translator func(map[string]interface{}) (graph.DatabaseInterface, error), ) promise.Promise[[]graph.DatabaseInterface] {

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

func (s *Service) ExecuteCustomUpdatePromise(cypher string, params map[string]interface{}) promise.Promise[*graph.GraphData]

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

func (s *Service) EnqueueCUDJob(commands []command.CypherCommand)

EnqueueCUDJob enqueues a write job (Create/Update/Delete) to the worker pool.

Parameters:

  • commands: A slice of CypherCommands.

EnqueueReadJob

func (s *Service) EnqueueReadJob(commands []command.CypherCommand)

EnqueueReadJob enqueues a read job to the worker pool.

Parameters:

  • commands: A slice of CypherCommands.

EnqueueRelationalJob

func (s *Service) EnqueueRelationalJob(commands []command.SQLCommand)

EnqueueRelationalJob enqueues a job to the relational worker pool.

Parameters:

  • commands: A slice of SQLCommands.

NewRAGReadService

func NewRAGReadService(nc *client.Neo4jClient, logger *logrus.Logger) *RAGReadService

NewRAGReadService initializes a new RAGReadService with a read-only worker pool.

Stop

func (r *RAGReadService) Stop()

Stop gracefully shuts down the read pool.

WaitForReadJobs

func (r *RAGReadService) WaitForReadJobs()

WaitForReadJobs waits for all outstanding read jobs to complete.

Read

func (r *RAGReadService) Read(request ReadGraphRequest) promise.Promise[*graph.GraphData]

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

func (r *RAGReadService) enqueueReadJob(commands []command.CypherCommand)

enqueueReadJob enqueues a read-only job to the worker pool.

Parameters:

  • commands: A slice of CypherCommands.

Last modified: 28 January 2025