MCPcopy Index your code
hub / github.com/foxcpp/maddy / LookupMulti

Method LookupMulti

internal/table/chain.go:94–129  ·  view source on GitHub ↗
(ctx context.Context, key string)

Source from the content-addressed store, hash-verified

92}
93
94func (s *Chain) LookupMulti(ctx context.Context, key string) ([]string, error) {
95 result := []string{key}
96STEP:
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
131func init() {
132 modules.Register("table.chain", NewChain)

Callers 1

LookupMethod · 0.95

Calls 2

LookupMultiMethod · 0.65
LookupMethod · 0.65

Tested by

no test coverage detected