using Connected.Annotations;
using Connected.Collections.Queues;
using Connected.Data;
using Connected.Entities.Annotations;
using Connected.Entities.Concurrency;
namespace Common.Collections;
///
[Table(Schema = SchemaAttribute.SysSchema)]
internal sealed record QueueMessage : ConcurrentEntity, IQueueMessage
{
public const string CacheKey = $"{SchemaAttribute.SysSchema}.{nameof(QueueMessage)}";
///
[Ordinal(0), Date(Kind = DateKind.DateTime)]
public DateTime Created { get; init; }
///
[Ordinal(2)]
public int DequeueCount { get; init; }
///
[Ordinal(3), Date(Kind = DateKind.DateTime)]
public DateTime? DequeueTimestamp { get; init; }
///
[Ordinal(4), Length(32)]
public string Queue { get; init; } = default!;
///
/// The serialized value of the arguments if specified.
///
///
/// If the queue message must be persisted the arguments get serialized
/// and stored in this property. When selected from the storage, the
/// Arguments object is recreated from this property.
/// Note that queue serialized Arguments must be less that 1024 characters long.
///
[Ordinal(7), Length(1024)]
public string? SerializedArguments { get; init; }
///
[Ordinal(8), Date(Kind = DateKind.DateTime)]
public DateTime NextVisible { get; init; }
///
[Ordinal(9)]
public Guid? PopReceipt { get; init; }
///
///
/// This property is persisted through the
/// property.
///
[Persistence(Persistence = ColumnPersistence.InMemory)]
public QueueArgs Arguments { get; init; }
}