package manager

import (
	"github.com/streadway/amqp"
	"sparrow/pkg/rule"
)

// TaskLifecycleManager 任务生命周期发布管理器
type TaskLifecycleManager struct {
	ch *amqp.Channel
}

func NewTaskLifecycleManager(ch *amqp.Channel) Producer {
	return &TaskLifecycleManager{ch: ch}
}

func (t *TaskLifecycleManager) Init() error {
	return t.ch.ExchangeDeclare(rule.TaskLifecycleExchange, "fanout", true, false, false, false, nil)
}

func (t *TaskLifecycleManager) Publish(topic string, msg []byte) error {
	return t.ch.Publish(rule.TaskLifecycleExchange, topic, false, false, amqp.Publishing{
		Body:         msg,
		DeliveryMode: amqp.Persistent,
	})
}

func (t *TaskLifecycleManager) CreateTopicIfNotExists(topic string) error {
	//TODO implement me
	panic("implement me")
}
