Struct TopicId
Represents a topic identifier that defines the scope of a broadcast message. The agent runtime implements a publish-subscribe model through its broadcast API, where messages must be published with a specific topic.
See the Python equivalent: CloudEvents Type Specification.
public struct TopicId
- Inherited Members
Constructors
TopicId(string, string)
Initializes a new instance of the TopicId struct.
public TopicId(string type, string source = "default")
Parameters
type
stringThe type of the topic.
source
stringThe source of the event. Defaults to DefaultSource if not specified.
TopicId((string Type, string Source))
Initializes a new instance of the TopicId struct from a tuple.
public TopicId((string Type, string Source) kvPair)
Parameters
Fields
DefaultSource
The default source value used when no source is explicitly provided.
public const string DefaultSource = "default"
Field Value
Properties
Source
Gets the source that identifies the context in which an event happened. This adheres to the CloudEvents specification.
Learn more here: CloudEvents Source.
public readonly string Source { get; }
Property Value
Type
Gets the type of the event that this TopicId represents. This adheres to the CloudEvents specification.
Must match the pattern: ^[\w-.:=]+$
.
Learn more here: CloudEvents Type.
public readonly string Type { get; }
Property Value
Methods
Equals(object?)
Determines whether the specified object is equal to the current TopicId.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
FromStr(string)
Converts a string in the format "type/source" into a TopicId.
public static TopicId FromStr(string maybeTopicId)
Parameters
maybeTopicId
stringThe topic ID string.
Returns
Exceptions
- FormatException
Thrown when the string is not in the valid "type/source" format.
GetHashCode()
Returns a hash code for this TopicId.
public override int GetHashCode()
Returns
- int
A hash code for the current instance.
IsWildcardMatch(TopicId)
Determines whether the given TopicId matches another topic.
public bool IsWildcardMatch(TopicId other)
Parameters
other
TopicIdThe topic ID to compare against.
Returns
- bool
true
if the topic types are equal; otherwise,false
.
ToString()
Returns the string representation of the TopicId.
public override string ToString()
Returns
- string
A string in the format "type/source".
Operators
explicit operator TopicId(string)
Explicitly converts a string to a TopicId.
public static explicit operator TopicId(string id)
Parameters
id
stringThe string representation of a topic ID.