forked from gosom/scrapemate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservices.go
46 lines (40 loc) · 1.37 KB
/
services.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package scrapemate
import (
"context"
)
// JobProvider is an interface for job providers
// a job provider is a service that provides jobs to scrapemate
// scrapemate will call the job provider to get jobs
//
//go:generate mockgen -destination=mock/mock_provider.go -package=mock . JobProvider
type JobProvider interface {
Jobs(ctx context.Context) (<-chan IJob, <-chan error)
// Push pushes a job to the job provider
Push(ctx context.Context, job IJob) error
}
// HTTPFetcher is an interface for http fetchers
//
//go:generate mockgen -destination=mock/mock_http_fetcher.go -package=mock . HTTPFetcher
type HTTPFetcher interface {
Fetch(ctx context.Context, job IJob) Response
}
// HTMLParser is an interface for html parsers
//
//go:generate mockgen -destination=mock/mock_parser.go -package=mock . HTMLParser
type HTMLParser interface {
Parse(ctx context.Context, body []byte) (any, error)
}
// Cacher is an interface for cache
//
//go:generate mockgen -destination=mock/mock_cacher.go -package=mock . Cacher
type Cacher interface {
Close() error
Get(ctx context.Context, key string) (Response, error)
Set(ctx context.Context, key string, value *Response) error
}
// ResultWriter is an interface for result writers
//
//go:generate mockgen -destination=mock/mock_writer.go -package=mock . ResultWriter
type ResultWriter interface {
Run(ctx context.Context, in <-chan Result) error
}