|
1 | 1 | package experimental |
2 | 2 |
|
| 3 | +func NewMonsterWithOptions(options *Options) *Monster { |
| 4 | + listenChan := make(chan string) |
| 5 | + var opt *Options |
| 6 | + if options != nil { |
| 7 | + opt = options |
| 8 | + } else { |
| 9 | + opt = &Options{ |
| 10 | + -1, |
| 11 | + } |
| 12 | + } |
| 13 | + return &Monster{ |
| 14 | + Options: opt, |
| 15 | + listenPipe: listenChan, |
| 16 | + compPipe: nil, |
| 17 | + } |
| 18 | +} |
| 19 | + |
3 | 20 | func NewMonster() *Monster { |
4 | 21 | listenChan := make(chan string) |
5 | 22 | return &Monster{ |
6 | | - listenChan, |
7 | | - nil, |
| 23 | + Options: nil, |
| 24 | + listenPipe: listenChan, |
| 25 | + compPipe: nil, |
8 | 26 | } |
9 | 27 | } |
10 | 28 |
|
11 | 29 | func (m *Monster) BuildSystem(opAdapterPipe chan<- *Node) { |
12 | | - parsePipe, compPipeChan := MakeParsingPipe() |
| 30 | + parsePipe, compPipeChan := m.MakeParsingPipe() |
13 | 31 | var reqPipe chan<- *Node |
14 | 32 | if opAdapterPipe == nil { |
15 | | - reqPipe = MakeRequisitionPipe(parsePipe, nil) |
| 33 | + reqPipe = m.MakeRequisitionPipe(parsePipe, nil) |
16 | 34 | } else { |
17 | | - reqPipe = MakeRequisitionPipe(parsePipe, opAdapterPipe) |
| 35 | + reqPipe = m.MakeRequisitionPipe(parsePipe, opAdapterPipe) |
18 | 36 | } |
19 | | - validationPipe := MakeUrlValidationPipe(reqPipe) |
20 | | - unduplPipe := MakeUnduplicationPipe(validationPipe) |
21 | | - cleanPipe := MakeLinkCleaningPipe(unduplPipe) |
22 | | - compPipe := MakeCompositionPipe(cleanPipe) |
| 37 | + validationPipe := m.MakeUrlValidationPipe(reqPipe) |
| 38 | + unduplPipe := m.MakeUnduplicationPipe(validationPipe) |
| 39 | + cleanPipe := m.MakeLinkCleaningPipe(unduplPipe) |
| 40 | + compPipe := m.MakeCompositionPipe(cleanPipe) |
23 | 41 | compPipeChan <- compPipe |
24 | 42 | m.compPipe = compPipe |
25 | 43 | } |
|
0 commit comments