Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checks for entity support #1047

Merged
merged 1 commit into from
Feb 28, 2024
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