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

Updated DurableClient ThrowIfFunctionDoesNotExist calls to work with correctly when calling a function in another app #1306

Merged
merged 6 commits into from
Apr 10, 2020
Merged
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ Task IDurableEntityClient.SignalEntityAsync(EntityId entityId, string operationN
{
if (string.IsNullOrEmpty(taskHubName))
{
return this.SignalEntityAsyncInternal(this.client, this.TaskHubName, entityId, null, operationName, operationInput);
return this.SignalEntityAsyncInternal(this, this.TaskHubName, entityId, null, operationName, operationInput);
}
else
{
Expand All @@ -225,7 +225,7 @@ Task IDurableEntityClient.SignalEntityAsync(EntityId entityId, string operationN
ConnectionName = connectionName,
};

TaskHubClient taskHubClient = ((DurableClient)this.config.GetClient(attribute)).client;
var taskHubClient = (DurableClient)this.config.GetClient(attribute);
amdeel marked this conversation as resolved.
Show resolved Hide resolved
return this.SignalEntityAsyncInternal(taskHubClient, taskHubName, entityId, null, operationName, operationInput);
}
}
Expand All @@ -235,7 +235,7 @@ Task IDurableEntityClient.SignalEntityAsync(EntityId entityId, DateTime schedule
{
if (string.IsNullOrEmpty(taskHubName))
{
return this.SignalEntityAsyncInternal(this.client, this.TaskHubName, entityId, scheduledTimeUtc, operationName, operationInput);
return this.SignalEntityAsyncInternal(this, this.TaskHubName, entityId, scheduledTimeUtc, operationName, operationInput);
}
else
{
Expand All @@ -250,19 +250,19 @@ Task IDurableEntityClient.SignalEntityAsync(EntityId entityId, DateTime schedule
ConnectionName = connectionName,
};

TaskHubClient taskHubClient = ((DurableClient)this.config.GetClient(attribute)).client;
return this.SignalEntityAsyncInternal(taskHubClient, taskHubName, entityId, scheduledTimeUtc, operationName, operationInput);
var durableClient = (DurableClient)this.config.GetClient(attribute);
return this.SignalEntityAsyncInternal(durableClient, taskHubName, entityId, scheduledTimeUtc, operationName, operationInput);
}
}

private async Task SignalEntityAsyncInternal(TaskHubClient client, string hubName, EntityId entityId, DateTime? scheduledTimeUtc, string operationName, object operationInput)
private async Task SignalEntityAsyncInternal(DurableClient clientAttribute, string hubName, EntityId entityId, DateTime? scheduledTimeUtc, string operationName, object operationInput)
amdeel marked this conversation as resolved.
Show resolved Hide resolved
{
if (operationName == null)
{
throw new ArgumentNullException(nameof(operationName));
}

if (this.client.Equals(client))
if (this.ConnectionNameMatchesCurrentApp(clientAttribute))
{
this.config.ThrowIfFunctionDoesNotExist(entityId.EntityName, FunctionType.Entity);
}
Expand All @@ -286,7 +286,7 @@ private async Task SignalEntityAsyncInternal(TaskHubClient client, string hubNam

var jrequest = JToken.FromObject(request, this.messageDataConverter.JsonSerializer);
var eventName = scheduledTimeUtc.HasValue ? EntityMessageEventNames.ScheduledRequestMessageEventName(scheduledTimeUtc.Value) : EntityMessageEventNames.RequestMessageEventName;
await client.RaiseEventAsync(instance, eventName, jrequest);
await clientAttribute.client.RaiseEventAsync(instance, eventName, jrequest);

this.traceHelper.FunctionScheduled(
hubName,
Expand All @@ -297,6 +297,18 @@ private async Task SignalEntityAsyncInternal(TaskHubClient client, string hubNam
isReplay: false);
}

private bool ConnectionNameMatchesCurrentApp(DurableClient client)
amdeel marked this conversation as resolved.
Show resolved Hide resolved
{
var storageProvider = this.config.Options.StorageProvider;
if (storageProvider.TryGetValue("ConnectionStringName", out object connectionName))
{
var newConnectionName = client.DurabilityProvider.ConnectionName;
return newConnectionName.Equals(connectionName);
}

return false;
}

/// <inheritdoc />
async Task IDurableOrchestrationClient.TerminateAsync(string instanceId, string reason)
{
Expand Down