43 lines
979 B
Go
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)
|
||
|
}
|