From 089ecad1aa3594aedb6628f19e3b08ff4b85f1f3 Mon Sep 17 00:00:00 2001 From: Harry Cordewener Date: Wed, 13 Nov 2024 17:45:41 -0600 Subject: [PATCH] Enable Exclusive Transactions. (#79) Without this, the Timeout value does nothing. --- Core.Arango.Tests/TransactionTest.cs | 10 ++++++---- Core.Arango/Core.Arango.xml | 6 ++++++ Core.Arango/Protocol/ArangoTransaction.cs | 1 + Core.Arango/Protocol/ArangoTransactionScope.cs | 9 +++++++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Core.Arango.Tests/TransactionTest.cs b/Core.Arango.Tests/TransactionTest.cs index b986c22811..470fd6fb32 100644 --- a/Core.Arango.Tests/TransactionTest.cs +++ b/Core.Arango.Tests/TransactionTest.cs @@ -22,8 +22,9 @@ public async Task StreamTransaction(string serializer) { Collections = new ArangoTransactionScope { - Write = new List {"test"} - } + Exclusive = ["test"] + }, + AllowImplicit = false }); await Arango.Document.CreateManyAsync(t1, "test", new List @@ -41,8 +42,9 @@ public async Task StreamTransaction(string serializer) { Collections = new ArangoTransactionScope { - Write = new List {"test"} - } + Exclusive = ["test"] + }, + AllowImplicit = false }); await Arango.Document.CreateManyAsync(t2, "test", new List diff --git a/Core.Arango/Core.Arango.xml b/Core.Arango/Core.Arango.xml index aa602c9bfe..4dcebc5bbb 100644 --- a/Core.Arango/Core.Arango.xml +++ b/Core.Arango/Core.Arango.xml @@ -5223,6 +5223,7 @@ An optional numeric value that can be used to set a timeout for waiting on collection locks. If not specified, a default value will be used. Setting lockTimeout to 0 will make ArangoDB not time out waiting for a lock. + This is only meaningful when using exclusive transaction locks. @@ -5250,6 +5251,11 @@ Collections to write to + + + Collections to write to with an exclusive lock + + Arango document update result diff --git a/Core.Arango/Protocol/ArangoTransaction.cs b/Core.Arango/Protocol/ArangoTransaction.cs index 71fbb1536f..d1eaebb137 100644 --- a/Core.Arango/Protocol/ArangoTransaction.cs +++ b/Core.Arango/Protocol/ArangoTransaction.cs @@ -55,6 +55,7 @@ public class ArangoTransaction /// An optional numeric value that can be used to set a timeout for waiting on collection locks. /// If not specified, a default value will be used. /// Setting lockTimeout to 0 will make ArangoDB not time out waiting for a lock. + /// This is only meaningful when using exclusive transaction locks. /// [JsonPropertyName("lockTimeout")] [JsonProperty(PropertyName = "lockTimeout", NullValueHandling = NullValueHandling.Ignore)] diff --git a/Core.Arango/Protocol/ArangoTransactionScope.cs b/Core.Arango/Protocol/ArangoTransactionScope.cs index dcb87cddaf..1b109dd8f6 100644 --- a/Core.Arango/Protocol/ArangoTransactionScope.cs +++ b/Core.Arango/Protocol/ArangoTransactionScope.cs @@ -24,5 +24,14 @@ public class ArangoTransactionScope [JsonProperty(PropertyName = "write", NullValueHandling = NullValueHandling.Ignore)] [System.Text.Json.Serialization.JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public List Write { get; set; } + + + /// + /// Collections to write to with an exclusive lock + /// + [JsonPropertyName("exclusive")] + [JsonProperty(PropertyName = "exclusive", NullValueHandling = NullValueHandling.Ignore)] + [System.Text.Json.Serialization.JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public List Exclusive { get; set; } } } \ No newline at end of file