Rework jobs
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Musify.Domain.Entities
|
||||
{
|
||||
[Table("Job")]
|
||||
public class Job
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
[Required]
|
||||
public required JobType JobType { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(512)]
|
||||
public required string Payload { get; set; }
|
||||
|
||||
[Required]
|
||||
public DateTime CreateAt { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Musify.Domain.Entities
|
||||
{
|
||||
#pragma warning disable CS8618
|
||||
[Table("JobExecution")]
|
||||
public class JobOperation
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
[Required]
|
||||
public required Guid JobId { get; set; }
|
||||
|
||||
[Required]
|
||||
public JobState JobState { get; set; } = JobState.Pending;
|
||||
|
||||
[NotMapped]
|
||||
public bool IsCompleted => JobState == JobState.Completed;
|
||||
|
||||
[NotMapped]
|
||||
public bool IsFailed => JobState == JobState.Failed;
|
||||
|
||||
[NotMapped]
|
||||
public bool IsPending => JobState == JobState.Pending;
|
||||
|
||||
[Required]
|
||||
[MaxLength(512)]
|
||||
public string ErrorMessage { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
[Required]
|
||||
public DateTime FinishedAt { get; set; }
|
||||
|
||||
[ForeignKey(nameof(JobId)) ]
|
||||
public Job Job { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
namespace Musify.Domain.Entities
|
||||
{
|
||||
public enum JobState
|
||||
{
|
||||
Pending,
|
||||
Failed,
|
||||
InProgress,
|
||||
Completed
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace Musify.Domain.Entities
|
||||
{
|
||||
public enum JobType
|
||||
{
|
||||
ResizePicture,
|
||||
RemoveFile,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Musify.Domain.Entities
|
||||
{
|
||||
#pragma warning disable CS8618
|
||||
[Table("ProcessExecution")]
|
||||
public class ProcessExecution
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
public Guid? CorrelationId { get; set; }
|
||||
|
||||
public Guid? ConversationId { get; set; }
|
||||
|
||||
public Guid? MessageId { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(256)]
|
||||
public required string ProcessName { get; set; }
|
||||
|
||||
[Required]
|
||||
public ProcessExecutionStatus Status { get; set; } = ProcessExecutionStatus.Running;
|
||||
|
||||
[Required]
|
||||
public DateTime StartedDateTime { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public DateTime FinishedDateTime { get; set; }
|
||||
|
||||
[MaxLength(2048)]
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
public ICollection<ProcessStepExecution> Steps { get; set; } = new List<ProcessStepExecution>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Musify.Domain.Entities
|
||||
{
|
||||
public enum ProcessExecutionStatus
|
||||
{
|
||||
Running,
|
||||
Succeeded,
|
||||
Failed,
|
||||
Compensated
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Musify.Domain.Entities
|
||||
{
|
||||
public enum ProcessStepComponentType
|
||||
{
|
||||
Consumer,
|
||||
Activity
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Musify.Domain.Entities
|
||||
{
|
||||
#pragma warning disable CS8618
|
||||
[Table("ProcessStepExecution")]
|
||||
public class ProcessStepExecution
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
[Required]
|
||||
public Guid ProcessExecutionId { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(256)]
|
||||
public required string StepName { get; set; }
|
||||
|
||||
[Required]
|
||||
public ProcessStepComponentType ComponentType { get; set; }
|
||||
|
||||
[Required]
|
||||
public ProcessExecutionStatus Status { get; set; } = ProcessExecutionStatus.Running;
|
||||
|
||||
[Required]
|
||||
public int Attempt { get; set; }
|
||||
|
||||
[Required]
|
||||
public DateTime StartedDateTime { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public DateTime FinishedDateTime { get; set; }
|
||||
|
||||
[MaxLength(2048)]
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
[ForeignKey(nameof(ProcessExecutionId)) ]
|
||||
public ProcessExecution ProcessExecution { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user