(ctx context.Context, key string)
| 92 | } |
| 93 | |
| 94 | func (s *Chain) LookupMulti(ctx context.Context, key string) ([]string, error) { |
| 95 | result := []string{key} |
| 96 | STEP: |
| 97 | for i, step := range s.chain { |
| 98 | newResult := []string{} |
| 99 | for _, key = range result { |
| 100 | if step_multi, ok := step.(module.MultiTable); ok { |
| 101 | val, err := step_multi.LookupMulti(ctx, key) |
| 102 | if err != nil { |
| 103 | return []string{}, err |
| 104 | } |
| 105 | if len(val) == 0 { |
| 106 | if s.optional[i] { |
| 107 | continue STEP |
| 108 | } |
| 109 | return []string{}, nil |
| 110 | } |
| 111 | newResult = append(newResult, val...) |
| 112 | } else { |
| 113 | val, ok, err := step.Lookup(ctx, key) |
| 114 | if err != nil { |
| 115 | return []string{}, err |
| 116 | } |
| 117 | if !ok { |
| 118 | if s.optional[i] { |
| 119 | continue STEP |
| 120 | } |
| 121 | return []string{}, nil |
| 122 | } |
| 123 | newResult = append(newResult, val) |
| 124 | } |
| 125 | } |
| 126 | result = newResult |
| 127 | } |
| 128 | return result, nil |
| 129 | } |
| 130 | |
| 131 | func init() { |
| 132 | modules.Register("table.chain", NewChain) |
no test coverage detected