interface rename + method change

This commit is contained in:
nquidox 2026-04-03 20:53:54 +03:00
parent c1c0e46184
commit d19f5f7621
2 changed files with 8 additions and 6 deletions

View file

@ -4,8 +4,8 @@ import (
"context" "context"
"encoding/json" "encoding/json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"parser-mandarake/internal/common"
rabbit "repo.nqws.ru/merch-tracker-v2/mt-rabbit" rabbit "repo.nqws.ru/merch-tracker-v2/mt-rabbit"
"scrapper-mandarake/internal/common"
) )
const pkgLogHeader string = "Tasks client |" const pkgLogHeader string = "Tasks client |"
@ -28,7 +28,7 @@ type Deps struct {
ChanLen uint ChanLen uint
} }
func New(deps Deps) *Handler { func New(deps Deps) TaskTransport {
var h Handler var h Handler
h.chanLen = deps.ChanLen h.chanLen = deps.ChanLen
@ -107,8 +107,9 @@ func (h *Handler) GetTasks(ctx context.Context) <-chan common.Task {
return getTasks return getTasks
} }
func (h *Handler) SendResult(ctx context.Context, resultChan chan common.Result) { func (h *Handler) SendResult(ctx context.Context) chan common.Result {
pub := h.publisher.Start(ctx, h.chanLen) pub := h.publisher.Start(ctx, h.chanLen)
resultChan := make(chan common.Result, h.chanLen)
go func() { go func() {
defer close(resultChan) defer close(resultChan)
@ -129,4 +130,5 @@ func (h *Handler) SendResult(ctx context.Context, resultChan chan common.Result)
} }
} }
}() }()
return resultChan
} }

View file

@ -2,10 +2,10 @@ package tasks
import ( import (
"context" "context"
"parser-mandarake/internal/common" "scrapper-mandarake/internal/common"
) )
type Tasker interface { type TaskTransport interface {
GetTasks(ctx context.Context) <-chan common.Task GetTasks(ctx context.Context) <-chan common.Task
SendResult(ctx context.Context, resultChan chan common.Result) SendResult(ctx context.Context) chan common.Result
} }