package created
This commit is contained in:
parent
353dcd6fe6
commit
71e2e1b7b1
5 changed files with 216 additions and 1 deletions
42
internal/processor/handler.go
Normal file
42
internal/processor/handler.go
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue