Typed Thrift calls for the NebulaGraph GraphService.
This module wraps NebulaGraphEx.Thrift.Client with the exact method
signatures defined in priv/thrift/graph.thrift. All encoding and
decoding is done manually against the Thrift binary protocol so that the
raw socket stays under DBConnection's control.
Methods
authenticate/3— open a session with username + passwordexecute/4— run a nGQL statement (binary DataSet response)execute_with_parameter/5— parameterised nGQLexecute_json/4— run a nGQL statement (JSON response)signout/2— close a session (one-way, no reply)verify_client_version/2— version handshake
Summary
Functions
Authenticates against the NebulaGraph server.
Executes a nGQL statement and returns an ExecutionResponse map with keys
Executes a nGQL statement and returns a raw JSON binary.
Executes a parameterised nGQL statement.
Signs out and closes the session. One-way — the server sends no reply.
Performs the client version handshake. Call immediately after opening
the socket, before authenticate/3.
Functions
@spec authenticate(NebulaGraphEx.Transport.socket(), binary(), binary(), keyword()) :: {:ok, map()} | {:error, term()}
Authenticates against the NebulaGraph server.
Returns {:ok, auth_response} on success, where auth_response is a map:
:error_code— raw integer error code (0 = success):session_id— integer session ID to use in subsequent calls:time_zone_offset_seconds— server timezone offset ornil:time_zone_name— server timezone binary ornil:error_msg— error message binary ornil
@spec execute(NebulaGraphEx.Transport.socket(), integer(), binary(), keyword()) :: {:ok, map()} | {:error, term()}
Executes a nGQL statement and returns an ExecutionResponse map with keys:
:error_code— integer:latency_in_us— server-side latency in microseconds:data—nilor a map with:column_namesand:rows:space_name— binary ornil:error_msg— binary ornil:comment— binary ornil
@spec execute_json(NebulaGraphEx.Transport.socket(), integer(), binary(), keyword()) :: {:ok, binary()} | {:error, term()}
Executes a nGQL statement and returns a raw JSON binary.
Useful for debugging. The caller is responsible for JSON decoding.
@spec execute_with_parameter( NebulaGraphEx.Transport.socket(), integer(), binary(), map(), keyword() ) :: {:ok, map()} | {:error, term()}
Executes a parameterised nGQL statement.
params is a map with binary keys and Elixir values that are encodable
by NebulaGraphEx.Thrift.Types.encode_value/1.
Example
GraphService.execute_with_parameter(
socket,
session_id,
"MATCH (v:Player{name: $name}) RETURN v",
%{"name" => "Tim Duncan"}
)
@spec signout(NebulaGraphEx.Transport.socket(), integer()) :: :ok | {:error, term()}
Signs out and closes the session. One-way — the server sends no reply.
@spec verify_client_version( NebulaGraphEx.Transport.socket(), keyword() ) :: {:ok, :ok} | {:error, term()}
Performs the client version handshake. Call immediately after opening
the socket, before authenticate/3.
Returns {:ok, :ok} on success or {:error, message}.