Skip to content

Commit

Permalink
Merge branch 'main' into LittleLittleCloud-patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleLittleCloud authored Dec 3, 2024
2 parents 615ce8c + 79c5aaa commit 68e4443
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private async ValueTask AddSubscriptionAsync(GrpcWorkerConnection connection, Ad
}
_subscriptionsByAgentType[agentType] = request.Subscription;
_subscriptionsByTopic.GetOrAdd(topic, _ => []).Add(agentType);
await _subscriptions.Subscribe(topic, agentType);
await _subscriptions.SubscribeAsync(topic, agentType);
//var response = new AddSubscriptionResponse { RequestId = request.RequestId, Error = "", Success = true };
Message response = new()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Microsoft.AutoGen.Agents;
public interface ISubscriptionsGrain : IGrainWithIntegerKey
{
ValueTask Subscribe(string agentType, string topic);
ValueTask Unsubscribe(string agentType, string topic);
ValueTask SubscribeAsync(string agentType, string topic);
ValueTask UnsubscribeAsync(string agentType, string topic);
ValueTask<Dictionary<string, List<string>>> GetSubscriptions(string agentType);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public ValueTask<Dictionary<string, List<string>>> GetSubscriptions(string? agen
}
return new ValueTask<Dictionary<string, List<string>>>(_subscriptions);
}
public ValueTask Subscribe(string agentType, string topic)
public async ValueTask SubscribeAsync(string agentType, string topic)
{
if (!_subscriptions.TryGetValue(topic, out var subscriptions))
{
Expand All @@ -27,11 +27,9 @@ public ValueTask Subscribe(string agentType, string topic)
}
_subscriptions[topic] = subscriptions;
state.State.Subscriptions = _subscriptions;
state.WriteStateAsync();

return ValueTask.CompletedTask;
await state.WriteStateAsync().ConfigureAwait(false);
}
public ValueTask Unsubscribe(string agentType, string topic)
public async ValueTask UnsubscribeAsync(string agentType, string topic)
{
if (!_subscriptions.TryGetValue(topic, out var subscriptions))
{
Expand All @@ -43,8 +41,7 @@ public ValueTask Unsubscribe(string agentType, string topic)
}
_subscriptions[topic] = subscriptions;
state.State.Subscriptions = _subscriptions;
state.WriteStateAsync();
return ValueTask.CompletedTask;
await state.WriteStateAsync();
}
}
public sealed class SubscriptionsState
Expand Down

0 comments on commit 68e4443

Please sign in to comment.