This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
e621-sdk-go/e621/schedulertask.go
Lennard Brinkhaus 31bd0cf639 api-call-system-#10 (#13)
Co-authored-by: Fenpaws <soxx@fenpa.ws>
Reviewed-on: anthrove/e621-to-graph#13
Reviewed-by: SoXX <fenpaws@noreply.localhost>
Co-authored-by: Lennard Brinkhaus <lennard.brinkhaus@noreply.localhost>
Co-committed-by: Lennard Brinkhaus <lennard.brinkhaus@noreply.localhost>
2023-07-17 08:10:13 +00:00

43 lines
979 B
Go

package e621
import (
"e621_to_neo4j/utils"
"net/http"
)
type schedulerTaskImpl[T utils.DataType] struct {
task utils.Task[T]
channel chan utils.DataResponse[T]
username string
apiKey string
}
func (s schedulerTaskImpl[T]) BasicAuth() (string, string) {
return s.username, s.apiKey
}
func NewSchedulerTaskImpl[T utils.DataType](task utils.Task[T], channel chan utils.DataResponse[T], username string, apiKey string) utils.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)
}