Skip to content

Commit

Permalink
Enable Exclusive Transactions. (#79)
Browse files Browse the repository at this point in the history
Without this, the Timeout value does nothing.
  • Loading branch information
HarryCordewener authored Nov 13, 2024
1 parent f2cd9bd commit 089ecad
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Core.Arango.Tests/TransactionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ public async Task StreamTransaction(string serializer)
{
Collections = new ArangoTransactionScope
{
Write = new List<string> {"test"}
}
Exclusive = ["test"]
},
AllowImplicit = false
});

await Arango.Document.CreateManyAsync(t1, "test", new List<Entity>
Expand All @@ -41,8 +42,9 @@ public async Task StreamTransaction(string serializer)
{
Collections = new ArangoTransactionScope
{
Write = new List<string> {"test"}
}
Exclusive = ["test"]
},
AllowImplicit = false
});

await Arango.Document.CreateManyAsync(t2, "test", new List<Entity>
Expand Down
6 changes: 6 additions & 0 deletions Core.Arango/Core.Arango.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
</summary>
</member>
<member name="P:Core.Arango.Protocol.ArangoTransaction.Params">
Expand Down Expand Up @@ -5250,6 +5251,11 @@
Collections to write to
</summary>
</member>
<member name="P:Core.Arango.Protocol.ArangoTransactionScope.Exclusive">
<summary>
Collections to write to with an exclusive lock
</summary>
</member>
<member name="T:Core.Arango.Protocol.ArangoUpdateResult`1">
<summary>
Arango document update result
Expand Down
1 change: 1 addition & 0 deletions Core.Arango/Protocol/ArangoTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </summary>
[JsonPropertyName("lockTimeout")]
[JsonProperty(PropertyName = "lockTimeout", NullValueHandling = NullValueHandling.Ignore)]
Expand Down
9 changes: 9 additions & 0 deletions Core.Arango/Protocol/ArangoTransactionScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,14 @@ public class ArangoTransactionScope
[JsonProperty(PropertyName = "write", NullValueHandling = NullValueHandling.Ignore)]
[System.Text.Json.Serialization.JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string> Write { get; set; }


/// <summary>
/// Collections to write to with an exclusive lock
/// </summary>
[JsonPropertyName("exclusive")]
[JsonProperty(PropertyName = "exclusive", NullValueHandling = NullValueHandling.Ignore)]
[System.Text.Json.Serialization.JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string> Exclusive { get; set; }
}
}

0 comments on commit 089ecad

Please sign in to comment.