1- package octopus
1+ package adapter
22
33import (
44 "fmt"
55 "io"
66 "log"
77 "os"
8- )
98
10- // OutputAdapter is the interface for the Adapter that is used to handle
11- // output from the Octopus Crawler.
12- // The contract stipulates that the crawler provides the channel
13- // to listen for a quit command.
14- // The crawler pumps its output onto the returned channel of the Consume method.
15- // Implementers of the interface should listen on this channel for output from
16- // the crawler.
17- type OutputAdapter interface {
18- Consume (quitCh <- chan bool ) chan <- CrawlOutput
19- }
9+ oct "github.com/rapidclock/web-octopus/octopus"
10+ )
2011
2112// StdOpAdapter is an output adapter that just prints the output onto the screen.
2213type StdOpAdapter struct {}
2314
24- func (s * StdOpAdapter ) Consume (quitCh <- chan bool ) chan <- CrawlOutput {
25- listenCh := make (chan CrawlOutput )
15+ func (s * StdOpAdapter ) Consume (quitCh <- chan bool ) chan <- oct. CrawlOutput {
16+ listenCh := make (chan oct. CrawlOutput )
2617 go func () {
2718 for {
2819 select {
@@ -41,13 +32,13 @@ type FileWriterAdapter struct {
4132 FilePath string
4233}
4334
44- func (fw * FileWriterAdapter ) Consume (quitCh <- chan bool ) chan <- CrawlOutput {
45- listenCh := make (chan CrawlOutput )
35+ func (fw * FileWriterAdapter ) Consume (quitCh <- chan bool ) chan <- oct. CrawlOutput {
36+ listenCh := make (chan oct. CrawlOutput )
4637 fw .writeToFile (quitCh , listenCh )
4738 return listenCh
4839}
4940
50- func (fw * FileWriterAdapter ) writeToFile (quitCh <- chan bool , ch <- chan CrawlOutput ) {
41+ func (fw * FileWriterAdapter ) writeToFile (quitCh <- chan bool , ch <- chan oct. CrawlOutput ) {
5142 fp , err := fw .getFilePointer ()
5243 if err != nil {
5344 fp .Close ()
0 commit comments