SoXX
802764092e
As mentioned in Issue #11, the folder structure got an overall as some file names Co-authored-by: Fenpaws <soxx@fenpa.ws> Reviewed-on: anthrove/e621-to-graph#14 Reviewed-by: Lennard Brinkhaus <lennard.brinkhaus@noreply.localhost> Co-authored-by: SoXX <fenpaws@noreply.localhost> Co-committed-by: SoXX <fenpaws@noreply.localhost>
44 lines
1.0 KiB
Go
44 lines
1.0 KiB
Go
package scheduler
|
|
|
|
import (
|
|
"git.dragse.it/anthrove/e621-to-graph/pkg/e621"
|
|
"git.dragse.it/anthrove/e621-to-graph/pkg/util/queue"
|
|
"net/http"
|
|
)
|
|
|
|
type schedulerTaskImpl[T e621.DataType] struct {
|
|
task e621.Task[T]
|
|
channel chan e621.DataResponse[T]
|
|
username string
|
|
apiKey string
|
|
}
|
|
|
|
func (s schedulerTaskImpl[T]) BasicAuth() (string, string) {
|
|
return s.username, s.apiKey
|
|
}
|
|
|
|
func NewSchedulerTaskImpl[T e621.DataType](task e621.Task[T], channel chan e621.DataResponse[T], username string, apiKey string) queue.SchedulerTask {
|
|
return &schedulerTaskImpl[T]{
|
|
task: task,
|
|
channel: channel,
|
|
username: username,
|
|
apiKey: apiKey,
|
|
}
|
|
}
|
|
|
|
func (s schedulerTaskImpl[T]) SendError(err error) {
|
|
s.channel <- s.task.HandleError(err)
|
|
}
|
|
|
|
func (s schedulerTaskImpl[T]) UriPath() string {
|
|
return s.task.UriPath()
|
|
}
|
|
|
|
func (s schedulerTaskImpl[T]) SendStatusCode(statusCode int) {
|
|
s.channel <- s.task.HandleStatusCode(statusCode)
|
|
}
|
|
|
|
func (s schedulerTaskImpl[T]) SendResponse(response *http.Response) {
|
|
s.channel <- s.task.HandleResponse(response)
|
|
}
|