Class TypeSubscription
This subscription matches on topics based on the exact type and maps to agents using the source of the topic as the agent key. This subscription causes each source to have its own agent instance.
public class TypeSubscription : ISubscriptionDefinition
- Inheritance
-
TypeSubscription
- Implements
- Inherited Members
Remarks
Example:
var subscription = new TypeSubscription("t1", "a1");
In this case:
Constructors
TypeSubscription(string, AgentType, string?)
Initializes a new instance of the TypeSubscription class.
public TypeSubscription(string topicType, AgentType agentType, string? id = null)
Parameters
topicType
stringThe exact topic type to match against.
agentType
AgentTypeAgent type to handle this subscription.
id
stringUnique identifier for the subscription. If not provided, a new UUID will be generated.
Properties
AgentType
Gets the agent type that handles this subscription.
public AgentType AgentType { get; }
Property Value
Id
Gets the unique identifier of the subscription.
public string Id { get; }
Property Value
TopicType
Gets the exact topic type used for matching.
public string TopicType { get; }
Property Value
Methods
Equals(object?)
Determines whether the specified object is equal to the current subscription.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
true
if the specified object is equal to this instance; otherwise,false
.
GetHashCode()
Returns a hash code for this instance.
public override int GetHashCode()
Returns
- int
A hash code for this instance, suitable for use in hashing algorithms and data structures.
MapToAgent(TopicId)
Maps a TopicId to an AgentId. Should only be called if Matches(TopicId) returns true.
public AgentId MapToAgent(TopicId topic)
Parameters
topic
TopicIdThe topic to map.
Returns
Exceptions
- InvalidOperationException
Thrown if the topic does not match the subscription.
Matches(TopicId)
Checks if a given TopicId matches the subscription based on an exact type match.
public bool Matches(TopicId topic)
Parameters
topic
TopicIdThe topic to check.
Returns
- bool
true
if the topic's type matches exactly,false
otherwise.