Add general queue schema

This commit is contained in:
Achim Rohn
2025-11-16 12:15:23 +01:00
parent d049baeecc
commit ed7ee7e95c
2 changed files with 68 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
package schema
import (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
)
type GeneralQueue struct {
ent.Schema
}
func (GeneralQueue) Fields() []ent.Field {
return []ent.Field{
field.String("name"),
field.JSON("payload", map[string]interface{}{}),
field.Enum("status").Values("pending", "in_progress", "completed", "failed"),
field.Int("number_of_tries").Default(0),
field.Int("max_retries").Default(3),
field.String("error_message").Optional(),
field.JSON("failure_payload", map[string]interface{}{}).Optional(),
field.JSON("result_payload", map[string]interface{}{}).Optional(),
field.Time("created_at"),
field.Time("updated_at"),
field.Time("processed_at").Optional(),
}
}
func (GeneralQueue) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "generalQueue"}}
}
+36
View File
@@ -0,0 +1,36 @@
package schema
import (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
)
type GeneralQueueState struct {
ent.Schema
}
func (GeneralQueueState) Fields() []ent.Field {
return []ent.Field{
field.String("name").
Unique().
Immutable().
Comment("Name of the queue (e.g., 'email', 'notifications')"),
field.Bool("running").
Default(false).
Comment("Whether the queue is currently running"),
field.Time("updated_at").
Comment("Last time the state was updated"),
}
}
func (GeneralQueueState) Edges() []ent.Edge {
return nil
}
func (GeneralQueueState) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{Table: "generalQueueState"},
}
}