@@ -20,21 +20,23 @@ func (o *octopus) setupValidProtocolMap() {
2020
2121func (o * octopus ) setupTimeToQuit () {
2222 if o .TimeToQuit > 0 {
23- o .timeToQuit = time .Duration (o .TimeToQuit )
23+ o .timeToQuit = time .Duration (o .TimeToQuit ) * time . Second
2424 } else {
2525 log .Fatalln ("TimeToQuit is not greater than 0" )
2626 }
2727}
2828
2929func (o * octopus ) SetupSystem () {
30+ o .isReady = false
3031 o .setupOctopus ()
3132
32- ingestCh := make (chan * Node )
33+ ingestNodeCh := make (chan * Node )
3334 ingestQuitCh := make (chan int , 1 )
34- ingestChSet := MakeNodeChSet (ingestCh , ingestQuitCh )
3535 ingestStrCh := make (chan string )
36+
37+ ingestChSet := MakeNodeChSet (ingestNodeCh , ingestQuitCh )
3638 inPipeChSet := & ingestPipeChSet {
37- ingestCh ,
39+ ingestNodeCh ,
3840 ingestStrCh ,
3941 ingestQuitCh ,
4042 }
@@ -43,17 +45,22 @@ func (o *octopus) SetupSystem() {
4345
4446 pageParseChSet := o .makeParseNodeFromHtmlPipe (ingestChSet )
4547 depthLimitChSet := o .makeCrawlDepthFilterPipe (pageParseChSet )
48+ // maxDelayChSet := o.makeMaxDelayPipe(depthLimitChSet)
49+ // distributorChSet := o.makeDistributorPipe(maxDelayChSet, outAdapterChSet)
4650 distributorChSet := o .makeDistributorPipe (depthLimitChSet , outAdapterChSet )
4751 pageReqChSet := o .makePageRequisitionPipe (distributorChSet )
4852 invUrlFilterChSet := o .makeInvalidUrlFilterPipe (pageReqChSet )
4953 dupFilterChSet := o .makeDuplicateUrlFilterPipe (invUrlFilterChSet )
5054 protoFilterChSet := o .makeUrlProtocolFilterPipe (dupFilterChSet )
5155 linkAbsChSet := o .makeLinkAbsolutionPipe (protoFilterChSet )
5256
57+
5358 o .makeIngestPipe (inPipeChSet , linkAbsChSet )
5459
55- o .inpUrlStrChan = ingestStrCh
60+ o .inputUrlStrChan = ingestStrCh
5661 o .masterQuitCh = make (chan int , 1 )
62+
63+ <- time .After (500 * time .Millisecond )
5764 o .isReady = true
5865}
5966
@@ -62,19 +69,37 @@ func (o *octopus) BeginCrawling(baseUrlStr string) {
6269 log .Fatal ("Call BuildSystem first to setup Octopus" )
6370 }
6471 go func () {
65- o .inpUrlStrChan <- baseUrlStr
72+ o .inputUrlStrChan <- baseUrlStr
6673 }()
67- for {
68- select {
69- case urlStr := <- o .inpUrlStrChan :
70- {
71- o .inpUrlStrChan <- urlStr
72- }
73- case <- o .masterQuitCh :
74- {
75- fmt .Println ("Master Kill Switch Activated" )
76- return
77- }
78- }
74+ // for {
75+ // select {
76+ // // case urlStr := <-o.inputUrlStrChan:
77+ // // {
78+ // // o.inputUrlStrChan <- urlStr
79+ // // }
80+ // case <-o.masterQuitCh:
81+ // {
82+ // fmt.Println("Master Kill Switch Activated")
83+ // return
84+ // }
85+ // }
86+ // }
87+ <- o .masterQuitCh
88+ fmt .Println ("Master Kill Switch Activated" )
89+ }
90+
91+ func (o * octopus ) GetInputUrlStrChan () chan <- string {
92+ if o .isReady {
93+ return o .inputUrlStrChan
94+ } else {
95+ return nil
96+ }
97+ }
98+
99+ func (o * octopus ) GetMasterQuitChan () chan <- int {
100+ if o .isReady {
101+ return o .masterQuitCh
102+ } else {
103+ return nil
79104 }
80105}
0 commit comments