Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gremlin-dotnet/src/Gremlin.Net/Driver/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal static partial class Log
"A connection was closed. Removing it from the pool so it can be replaced.")]
public static partial void RemovingClosedConnectionFromPool(this ILogger logger);

[LoggerMessage(20003, LogLevel.Debug, "Submitting Bytecode {bytecode} for request: {requestId}")]
public static partial void SubmittingBytecode(this ILogger logger, Bytecode bytecode, Guid requestId);
[LoggerMessage(20003, LogLevel.Debug, "Submitting GremlinLang {gremlinLang} for request: {requestId}")]
public static partial void SubmittingGremlinLang(this ILogger logger, GremlinLang gremlinLang, Guid requestId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,41 +105,26 @@ private DriverRemoteConnection(IGremlinClient client, string traversalSource, st
}

/// <summary>
/// Submits <see cref="Bytecode" /> for evaluation to a remote Gremlin Server.
/// Submits <see cref="GremlinLang" /> for evaluation to a remote Gremlin Server.
/// </summary>
/// <param name="bytecode">The <see cref="Bytecode" /> to submit.</param>
/// <param name="gremlinLang">The <see cref="GremlinLang" /> to submit.</param>
/// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
/// <returns>A <see cref="ITraversal" /> allowing to access the results and side-effects.</returns>
public async Task<ITraversal<TStart, TEnd>> SubmitAsync<TStart, TEnd>(Bytecode bytecode,
public async Task<ITraversal<TStart, TEnd>> SubmitAsync<TStart, TEnd>(GremlinLang gremlinLang,
CancellationToken cancellationToken = default)
{
var requestId = Guid.NewGuid();
var resultSet = await SubmitBytecodeAsync(requestId, bytecode, cancellationToken).ConfigureAwait(false);
return new DriverRemoteTraversal<TStart, TEnd>(resultSet);
}
gremlinLang.AddG(_traversalSource);

private async Task<IEnumerable<Traverser>> SubmitBytecodeAsync(Guid requestid, Bytecode bytecode,
CancellationToken cancellationToken)
{
_logger.SubmittingBytecode(bytecode, requestid);

var requestId = Guid.NewGuid();
var requestMsg =
RequestMessage.Build(Tokens.OpsBytecode)
RequestMessage.Build(Tokens.OpsEval)
.Processor(Processor)
.OverrideRequestId(requestid)
.AddArgument(Tokens.ArgsGremlin, bytecode)
.AddArgument(Tokens.ArgsAliases, new Dictionary<string, string> {{"g", _traversalSource}});

if (IsSessionBound)
{
requestMsg.AddArgument(Tokens.ArgsSession, _sessionId!);
}
.OverrideRequestId(requestId)
.AddArgument(Tokens.ArgsGremlin, gremlinLang.GetGremlin())
.AddArgument(Tokens.ArgsBindings, gremlinLang.Parameters);

var optionsStrategyInst = bytecode.SourceInstructions.Find(
s => s.OperatorName == "withStrategies" && s.Arguments[0] is OptionsStrategy);
if (optionsStrategyInst != null)
foreach (var optionsStrategy in gremlinLang.OptionsStrategies)
{
OptionsStrategy optionsStrategy = optionsStrategyInst.Arguments[0]!;
foreach (var pair in optionsStrategy.Configuration)
{
if (_allowedKeys.Contains(pair.Key))
Expand All @@ -149,7 +134,14 @@ private async Task<IEnumerable<Traverser>> SubmitBytecodeAsync(Guid requestid, B
}
}

return await _client.SubmitAsync<Traverser>(requestMsg.Create(), cancellationToken).ConfigureAwait(false);
if (IsSessionBound)
{
requestMsg.AddArgument(Tokens.ArgsSession, _sessionId!);
}

var resultSet = await _client.SubmitAsync<Traverser>(requestMsg.Create(), cancellationToken)
.ConfigureAwait(false);
return new DriverRemoteTraversal<TStart, TEnd>(resultSet);
}

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ public DriverRemoteTraversal(IEnumerable<Traverser> traversers)
Traversers = traversers;
}

public override Bytecode Bytecode => throw new NotSupportedException("Remote traversals do not have Bytecode");
public override GremlinLang GremlinLang => throw new NotSupportedException("Remote traversals do not have GremlinLang");
}
}
5 changes: 0 additions & 5 deletions gremlin-dotnet/src/Gremlin.Net/Driver/Tokens.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ public class Tokens
/// </summary>
public const string OpsAuthentication = "authentication";

/// <summary>
/// Operation used for a request that contains the Bytecode representation of a Traversal.
/// </summary>
public const string OpsBytecode = "bytecode";

/// <summary>
/// Operation used to evaluate a Gremlin script provided as a string.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ namespace Gremlin.Net.Process.Remote
public interface IRemoteConnection
{
/// <summary>
/// Submits <see cref="ITraversal" /> <see cref="Bytecode" /> to a server and returns a
/// Submits <see cref="ITraversal" /> <see cref="Traversal.GremlinLang" /> to a server and returns a
/// <see cref="ITraversal" />.
/// </summary>
/// <param name="bytecode">The <see cref="Bytecode" /> to send.</param>
/// <param name="gremlinLang">The <see cref="Traversal.GremlinLang" /> to send.</param>
/// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
/// <returns>The <see cref="ITraversal" /> with the results and optional side-effects.</returns>
Task<ITraversal<TStart, TEnd>> SubmitAsync<TStart, TEnd>(Bytecode bytecode, CancellationToken cancellationToken = default);
Task<ITraversal<TStart, TEnd>> SubmitAsync<TStart, TEnd>(GremlinLang gremlinLang, CancellationToken cancellationToken = default);

/// <summary>
/// Creates a <see cref="RemoteTransaction" /> in the context of a <see cref="GraphTraversalSource" /> designed to work with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void Apply<TStart, TEnd>(ITraversal<TStart, TEnd> traversal)
public async Task ApplyAsync<TStart, TEnd>(ITraversal<TStart, TEnd> traversal, CancellationToken cancellationToken = default)
{
if (traversal.Traversers != null) return;
var remoteTraversal = await _remoteConnection.SubmitAsync<TStart, TEnd>(traversal.Bytecode, cancellationToken)
var remoteTraversal = await _remoteConnection.SubmitAsync<TStart, TEnd>(traversal.GremlinLang, cancellationToken)
.ConfigureAwait(false);
traversal.Traversers = remoteTraversal.Traversers;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public GraphTraversalSource Begin()
{
throw new InvalidOperationException("Transaction already started on this object");
}
_g = new GraphTraversalSource(_g.TraversalStrategies, _g.Bytecode, _sessionBasedConnection);
_g = new GraphTraversalSource(_g.TraversalStrategies, _g.GremlinLang, _sessionBasedConnection);
return _g;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static AnonymousTraversalSource Traversal()
/// <returns>A <see cref="GraphTraversalSource" /> configured to use the provided <see cref="IRemoteConnection" />.</returns>
public GraphTraversalSource With(IRemoteConnection remoteConnection) =>
new GraphTraversalSource(new List<ITraversalStrategy>(),
new Bytecode(), remoteConnection);
new GremlinLang(), remoteConnection);
}

}
80 changes: 0 additions & 80 deletions gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Binding.cs

This file was deleted.

73 changes: 0 additions & 73 deletions gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bindings.cs

This file was deleted.

Loading
Loading