Skip to content
Merged
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
14 changes: 14 additions & 0 deletions src/DurableTask.Core/Entities/OrchestrationEntityContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ public OrchestrationEntityContext(
/// </summary>
public Guid? CurrentCriticalSectionId => this.criticalSectionId;

void CheckEntitySupport()
{
if (!this.EntitiesAreSupported)
{
throw new NotSupportedException("Durable entities are not supported by the current backend configuration.");
}
}

/// <summary>
/// Enumerate all the entities that are available for calling from within a critical section.
/// This set contains all the entities that were locked prior to entering the critical section,
Expand All @@ -81,6 +89,8 @@ public OrchestrationEntityContext(
/// <returns>An enumeration of all the currently available entities.</returns>
public IEnumerable<EntityId> GetAvailableEntities()
{
this.CheckEntitySupport();

if (this.IsInsideCriticalSection)
{
foreach (var e in this.availableLocks!)
Expand Down Expand Up @@ -227,6 +237,8 @@ public EntityMessageEvent EmitRequestMessage(
(DateTime Original, DateTime Capped)? scheduledTimeUtc,
string? input)
{
this.CheckEntitySupport();

var request = new RequestMessage()
{
ParentInstanceId = this.instanceId,
Expand All @@ -251,6 +263,8 @@ public EntityMessageEvent EmitRequestMessage(
/// <returns>The event to send.</returns>
public EntityMessageEvent EmitAcquireMessage(Guid lockRequestId, EntityId[] entities)
{
this.CheckEntitySupport();

// All the entities in entity[] need to be locked, but to avoid deadlock, the locks have to be acquired
// sequentially, in order. So, we send the lock request to the first entity; when the first lock
// is granted by the first entity, the first entity will forward the lock request to the second entity,
Expand Down