mirror of
https://github.com/microsoft/autogen.git
synced 2026-04-20 03:02:16 -04:00
WriteAsync must be awaited (#4491)
This commit is contained in:
@@ -137,7 +137,7 @@ public sealed class GrpcGateway : BackgroundService, IGateway
|
||||
}
|
||||
_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()
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ internal sealed class SubscriptionsGrain([PersistentState("state", "PubSubStore"
|
||||
}
|
||||
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))
|
||||
{
|
||||
@@ -27,11 +27,9 @@ internal sealed class SubscriptionsGrain([PersistentState("state", "PubSubStore"
|
||||
}
|
||||
_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))
|
||||
{
|
||||
@@ -43,8 +41,7 @@ internal sealed class SubscriptionsGrain([PersistentState("state", "PubSubStore"
|
||||
}
|
||||
_subscriptions[topic] = subscriptions;
|
||||
state.State.Subscriptions = _subscriptions;
|
||||
state.WriteStateAsync();
|
||||
return ValueTask.CompletedTask;
|
||||
await state.WriteStateAsync();
|
||||
}
|
||||
}
|
||||
public sealed class SubscriptionsState
|
||||
|
||||
Reference in New Issue
Block a user