Gremlex.Client (gremlex v0.4.3)

View Source

A Mint-based WebSocket client for Gremlin Server.

This module is a GenServer that connects to a Gremlin Server using the WebSocket protocol. It sends queries to the server and receives responses. It also handles pings and pongs to keep the connection alive.

Example

iex> Gremlex.Client.start_link({host: "localhost", port: 8182, path: "/gremlin", secure: false})
{:ok, #PID<0.123.0>}
iex> Gremlex.Client.query(%Gremlex.Graph{vertices: [%Gremlex.Vertex{id: "1", label: "person"}]})
{:ok, [%Gremlex.Vertex{id: "1", label: "person"}]}

Summary

Functions

Returns a specification to start this module under a supervisor.

Accepts a graph which it converts into a query and queries the database.

Types

error_code()

@type error_code() ::
  :UNAUTHORIZED
  | :MALFORMED_REQUEST
  | :INVALID_REQUEST_ARGUMENTS
  | :SERVER_ERROR
  | :SCRIPT_EVALUATION_ERROR
  | :SERVER_TIMEOUT
  | :SERVER_SERIALIZATION_ERROR

response()

@type response() :: {:ok, list()} | {:error, error_code(), reason :: String.t()}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

query(query, timeout \\ 30000)

@spec query(Gremlex.Graph.t() | String.t(), number() | :infinity) :: response()

Accepts a graph which it converts into a query and queries the database.

Params:

  • query - A Gremlex.Graph.t or raw String query
  • timeout (Default: 30000ms) - Timeout in milliseconds to pass to GenServer and Task.await call

start_link(opts)

@spec start_link(term()) :: GenServer.on_start()