42 lines
693 B
Go
42 lines
693 B
Go
package processor
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net"
|
|
"task-processor/internal/taskAgent"
|
|
)
|
|
|
|
const pkgLogHeader string = "Processor |"
|
|
|
|
type handler struct {
|
|
*service
|
|
}
|
|
|
|
type Addr struct {
|
|
Host string
|
|
Port string
|
|
User string
|
|
Pass string
|
|
Vhost string
|
|
}
|
|
|
|
type Deps struct {
|
|
Ctx context.Context
|
|
TA taskAgent.TaskAgent
|
|
Addr Addr
|
|
ChanLen uint
|
|
}
|
|
|
|
func NewHandler(deps Deps) Processor {
|
|
addr := makeAddr(deps.Addr)
|
|
|
|
return &handler{
|
|
service: newService(deps, addr),
|
|
}
|
|
}
|
|
|
|
func makeAddr(addr Addr) string {
|
|
//"amqp://username:password@host:port/vhost"
|
|
return fmt.Sprintf("amqp://%v:%v@%v/%v", addr.User, addr.Pass, net.JoinHostPort(addr.Host, addr.Port), addr.Vhost)
|
|
}
|