mirror of
https://github.com/microsoft/autogen.git
synced 2025-09-02 12:57:21 +00:00
improve subscriptions (#4304)
This commit is contained in:
parent
eb67e4ac93
commit
97fd6cc1e0
@ -6,8 +6,13 @@ namespace Microsoft.AutoGen.Agents;
|
|||||||
internal sealed class SubscriptionsGrain([PersistentState("state", "PubSubStore")] IPersistentState<SubscriptionsState> state) : Grain, ISubscriptionsGrain
|
internal sealed class SubscriptionsGrain([PersistentState("state", "PubSubStore")] IPersistentState<SubscriptionsState> state) : Grain, ISubscriptionsGrain
|
||||||
{
|
{
|
||||||
private readonly Dictionary<string, List<string>> _subscriptions = new();
|
private readonly Dictionary<string, List<string>> _subscriptions = new();
|
||||||
public ValueTask<Dictionary<string, List<string>>> GetSubscriptions(string agentType)
|
public ValueTask<Dictionary<string, List<string>>> GetSubscriptions(string? agentType = null)
|
||||||
{
|
{
|
||||||
|
//if agentType is null, return all subscriptions else filter on agentType
|
||||||
|
if (agentType != null)
|
||||||
|
{
|
||||||
|
return new ValueTask<Dictionary<string, List<string>>>(_subscriptions.Where(x => x.Value.Contains(agentType)).ToDictionary(x => x.Key, x => x.Value));
|
||||||
|
}
|
||||||
return new ValueTask<Dictionary<string, List<string>>>(_subscriptions);
|
return new ValueTask<Dictionary<string, List<string>>>(_subscriptions);
|
||||||
}
|
}
|
||||||
public ValueTask Subscribe(string agentType, string topic)
|
public ValueTask Subscribe(string agentType, string topic)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user