feat(kol): AI assist service + worker
This commit is contained in:
@@ -81,6 +81,12 @@ type RabbitMQConfig struct {
|
||||
TemplateAssistDLX string `mapstructure:"template_assist_dlx"`
|
||||
TemplateAssistDLQ string `mapstructure:"template_assist_dlq"`
|
||||
TemplateAssistDLQRouteKey string `mapstructure:"template_assist_dlq_routing_key"`
|
||||
KolAssistExchange string `mapstructure:"kol_assist_exchange"`
|
||||
KolAssistRoutingKey string `mapstructure:"kol_assist_routing_key"`
|
||||
KolAssistQueue string `mapstructure:"kol_assist_queue"`
|
||||
KolAssistDLX string `mapstructure:"kol_assist_dlx"`
|
||||
KolAssistDLQ string `mapstructure:"kol_assist_dlq"`
|
||||
KolAssistDLQRouteKey string `mapstructure:"kol_assist_dlq_routing_key"`
|
||||
ImageAssetExchange string `mapstructure:"image_asset_exchange"`
|
||||
ImageAssetRoutingKey string `mapstructure:"image_asset_routing_key"`
|
||||
ImageAssetQueue string `mapstructure:"image_asset_queue"`
|
||||
@@ -359,6 +365,24 @@ func normalizeRabbitMQConfig(cfg *RabbitMQConfig) {
|
||||
if strings.TrimSpace(cfg.TemplateAssistDLQRouteKey) == "" {
|
||||
cfg.TemplateAssistDLQRouteKey = "template.assist.run.dlq"
|
||||
}
|
||||
if strings.TrimSpace(cfg.KolAssistExchange) == "" {
|
||||
cfg.KolAssistExchange = "kol.assist"
|
||||
}
|
||||
if strings.TrimSpace(cfg.KolAssistRoutingKey) == "" {
|
||||
cfg.KolAssistRoutingKey = "kol.assist.run"
|
||||
}
|
||||
if strings.TrimSpace(cfg.KolAssistQueue) == "" {
|
||||
cfg.KolAssistQueue = "kol.assist.run"
|
||||
}
|
||||
if strings.TrimSpace(cfg.KolAssistDLX) == "" {
|
||||
cfg.KolAssistDLX = "kol.assist.dlx"
|
||||
}
|
||||
if strings.TrimSpace(cfg.KolAssistDLQ) == "" {
|
||||
cfg.KolAssistDLQ = "kol.assist.run.dlq"
|
||||
}
|
||||
if strings.TrimSpace(cfg.KolAssistDLQRouteKey) == "" {
|
||||
cfg.KolAssistDLQRouteKey = "kol.assist.run.dlq"
|
||||
}
|
||||
if strings.TrimSpace(cfg.ImageAssetExchange) == "" {
|
||||
cfg.ImageAssetExchange = "image.asset"
|
||||
}
|
||||
|
||||
@@ -102,6 +102,10 @@ func (c *Client) PublishTemplateAssistTask(ctx context.Context, body []byte) err
|
||||
return c.publish(ctx, c.cfg.TemplateAssistExchange, c.cfg.TemplateAssistRoutingKey, body)
|
||||
}
|
||||
|
||||
func (c *Client) PublishKolAssistTask(ctx context.Context, body []byte) error {
|
||||
return c.publish(ctx, c.cfg.KolAssistExchange, c.cfg.KolAssistRoutingKey, body)
|
||||
}
|
||||
|
||||
func (c *Client) PublishImageAssetTask(ctx context.Context, body []byte) error {
|
||||
return c.publish(ctx, c.cfg.ImageAssetExchange, c.cfg.ImageAssetRoutingKey, body)
|
||||
}
|
||||
@@ -180,6 +184,10 @@ func (c *Client) ConsumeTemplateAssistTask(consumerName string) (<-chan amqp.Del
|
||||
return c.consume(consumerName, c.cfg.TemplateAssistQueue)
|
||||
}
|
||||
|
||||
func (c *Client) ConsumeKolAssistTask(consumerName string) (<-chan amqp.Delivery, *amqp.Channel, error) {
|
||||
return c.consume(consumerName, c.cfg.KolAssistQueue)
|
||||
}
|
||||
|
||||
func (c *Client) ConsumeImageAssetTask(consumerName string) (<-chan amqp.Delivery, *amqp.Channel, error) {
|
||||
return c.consume(consumerName, c.cfg.ImageAssetQueue)
|
||||
}
|
||||
@@ -562,6 +570,18 @@ func (c *Client) ensureTopology(conn *amqp.Connection) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.ensureWorkQueue(
|
||||
ch,
|
||||
c.cfg.KolAssistExchange,
|
||||
c.cfg.KolAssistRoutingKey,
|
||||
c.cfg.KolAssistQueue,
|
||||
c.cfg.KolAssistDLX,
|
||||
c.cfg.KolAssistDLQ,
|
||||
c.cfg.KolAssistDLQRouteKey,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.ensureWorkQueue(
|
||||
ch,
|
||||
c.cfg.ImageAssetExchange,
|
||||
|
||||
Reference in New Issue
Block a user