From 64eb5fb23f64f209e3d813e017097044a111151f Mon Sep 17 00:00:00 2001 From: ale Date: Sun, 20 Jan 2019 08:15:22 +0000 Subject: Refactor Handlers in terms of a Publisher interface Introduce an interface to decouple the Enqueue functionality from the Crawler implementation. --- crawler_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crawler_test.go') diff --git a/crawler_test.go b/crawler_test.go index 7b5c92c..0ad469b 100644 --- a/crawler_test.go +++ b/crawler_test.go @@ -33,11 +33,11 @@ func TestCrawler(t *testing.T) { ) var crawledPages int - h := HandlerFunc(func(c *Crawler, u string, depth int, resp *http.Response, err error) error { + h := HandlerFunc(func(p Publisher, u string, depth int, resp *http.Response, err error) error { crawledPages++ next := fmt.Sprintf(srv.URL+"/page/%d", crawledPages) log.Printf("%s -> %s", u, next) - c.Enqueue(Outlink{ + p.Enqueue(Outlink{ URL: mustParseURL(next), Tag: TagPrimary, }, depth+1) -- cgit v1.2.3-54-g00ecf