Struct MessageEnvelopeStruct
High-performance struct for message envelope with minimal allocations.
[StructLayout(LayoutKind.Auto)]
public readonly struct MessageEnvelopeStruct : IEquatable<MessageEnvelopeStruct>
- Implements
- Inherited Members
- Extension Methods
Remarks
Initializes a new instance of the MessageEnvelopeStruct struct.
Constructors
MessageEnvelopeStruct(string, ReadOnlyMemory<byte>, long, IReadOnlyDictionary<string, string>?, string?, string?, byte, int)
High-performance struct for message envelope with minimal allocations.
public MessageEnvelopeStruct(string messageId, ReadOnlyMemory<byte> body, long timestampTicks, IReadOnlyDictionary<string, string>? headers = null, string? correlationId = null, string? messageType = null, byte priority = 0, int timeToLiveSeconds = 0)
Parameters
messageIdstringbodyReadOnlyMemory<byte>timestampTickslongheadersIReadOnlyDictionary<string, string>correlationIdstringmessageTypestringprioritybytetimeToLiveSecondsint
Remarks
Initializes a new instance of the MessageEnvelopeStruct struct.
Properties
Body
Gets the message body as bytes.
public ReadOnlyMemory<byte> Body { get; }
Property Value
- ReadOnlyMemory<byte>
The current Body value.
CorrelationId
Gets the correlation identifier.
public string? CorrelationId { get; }
Property Value
- string
The current CorrelationId value.
Headers
Gets the message headers.
public IReadOnlyDictionary<string, string>? Headers { get; }
Property Value
- IReadOnlyDictionary<string, string>
The current Headers value.
MessageId
Gets the message identifier.
public string MessageId { get; }
Property Value
- string
The message identifier.
MessageType
Gets the message type.
public string? MessageType { get; }
Property Value
- string
The current MessageType value.
Priority
Gets the message priority.
public byte Priority { get; }
Property Value
TimeToLive
Gets the time to live as a TimeSpan.
public TimeSpan TimeToLive { get; }
Property Value
- TimeSpan
The time to live as a TimeSpan.
TimeToLiveSeconds
Gets the time to live in seconds.
public int TimeToLiveSeconds { get; }
Property Value
- int
The current TimeToLiveSeconds value.
Timestamp
Gets the timestamp as a DateTime.
public DateTime Timestamp { get; }
Property Value
- DateTime
The timestamp as a DateTime.
TimestampTicks
Gets the timestamp in ticks.
public long TimestampTicks { get; }
Property Value
- long
The current TimestampTicks value.
Methods
Equals(MessageEnvelopeStruct)
Determines whether the specified envelope is equal to the current envelope.
public bool Equals(MessageEnvelopeStruct other)
Parameters
otherMessageEnvelopeStruct
Returns
Equals(object?)
Determines whether the specified object is equal to the current envelope.
public override bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
Returns the hash code for this envelope.
public override int GetHashCode()
Returns
ToString()
Returns a string representation of this envelope.
public override string ToString()
Returns
WithBody(ReadOnlyMemory<byte>)
Creates a new envelope with the specified body.
public MessageEnvelopeStruct WithBody(ReadOnlyMemory<byte> body)
Parameters
bodyReadOnlyMemory<byte>
Returns
WithCorrelationId(string)
Creates a new envelope with the specified correlation ID.
public MessageEnvelopeStruct WithCorrelationId(string correlationId)
Parameters
correlationIdstring
Returns
WithMessageId(string)
Creates a new envelope with the specified message ID.
public MessageEnvelopeStruct WithMessageId(string messageId)
Parameters
messageIdstring
Returns
WithMessageType(string)
Creates a new envelope with the specified message type.
public MessageEnvelopeStruct WithMessageType(string messageType)
Parameters
messageTypestring
Returns
WithPriority(byte)
Creates a new envelope with the specified priority.
public MessageEnvelopeStruct WithPriority(byte priority)
Parameters
prioritybyte
Returns
WithTimeToLive(TimeSpan)
Creates a new envelope with the specified time to live.
public MessageEnvelopeStruct WithTimeToLive(TimeSpan timeToLive)
Parameters
timeToLiveTimeSpan
Returns
Operators
operator ==(MessageEnvelopeStruct, MessageEnvelopeStruct)
Determines whether two envelopes are equal.
public static bool operator ==(MessageEnvelopeStruct left, MessageEnvelopeStruct right)
Parameters
leftMessageEnvelopeStructrightMessageEnvelopeStruct
Returns
operator !=(MessageEnvelopeStruct, MessageEnvelopeStruct)
Determines whether two envelopes are not equal.
public static bool operator !=(MessageEnvelopeStruct left, MessageEnvelopeStruct right)
Parameters
leftMessageEnvelopeStructrightMessageEnvelopeStruct