SetValueFunc set the metadata label to the value function. If no metadata can be found this is a noop and false is returned. Any existing value is overwritten.
(ctx context.Context, label string, f Func)
| 100 | // SetValueFunc set the metadata label to the value function. If no metadata can be found this is a noop and |
| 101 | // false is returned. Any existing value is overwritten. |
| 102 | func SetValueFunc(ctx context.Context, label string, f Func) bool { |
| 103 | if metadata := ctx.Value(key{}); metadata != nil { |
| 104 | if m, ok := metadata.(md); ok { |
| 105 | m[label] = f |
| 106 | return true |
| 107 | } |
| 108 | } |
| 109 | return false |
| 110 | } |
| 111 | |
| 112 | // md is metadata information storage. |
| 113 | type md map[string]Func |
searching dependent graphs…