Add general queue schema
This commit is contained in:
@@ -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"}}
|
||||||
|
}
|
||||||
@@ -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"},
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user