package taskmq

type TaskMQ struct {
	config *Config
	broker IBroker
}

func New(broker IBroker, config *Config) *TaskMQ {
	return &TaskMQ{config: config}
}

func (r *TaskMQ) Connect() error {

	return r.broker.Connect()
}

func (r *TaskMQ) Publish(queueName string, body []byte) {
	err := r.broker.Push(queueName, body)

	if err != nil {
		panic(err)
	}
}

func (r *TaskMQ) Consume(queueName string, fn callbackFunction) {
	broker := r.createBroker()
	c := newConsumer(broker, queueName)
	c.Listen(fn)
}

func (r *TaskMQ) createBroker() IBroker {
	return &BrokerRedis{client: r.redis}
}

package taskmq

type TaskMQ struct {
	config *Config
	broker IBroker
}

func New(broker IBroker, config *Config) *TaskMQ {
	return &TaskMQ{config: config}
}

func (r *TaskMQ) Connect() error {

	return r.broker.Connect()
}

func (r *TaskMQ) Publish(queueName string, body []byte) {
	err := r.broker.Push(queueName, body)

	if err != nil {
		panic(err)
	}
}

func (r *TaskMQ) Consume(queueName string, fn callbackFunction) {
	broker := r.broker.Clone()
	c := newConsumer(broker, queueName)
	c.Listen(fn)
}


Remove concrete redis broker from base package
Remove concrete redis broker from base package
