Resolve attempts to resolve the runtime value of this field from the store via the given Resolver.
(ctx context.Context, r Resolver)
| 67 | |
| 68 | // Resolve attempts to resolve the runtime value of this field from the store via the given Resolver. |
| 69 | func (e RuntimeEntry[T]) Resolve(ctx context.Context, r Resolver) (T, error) { |
| 70 | var zero T |
| 71 | |
| 72 | name, err := e.name() |
| 73 | if err != nil { |
| 74 | return zero, xerrors.Errorf("resolve, name issue: %w", err) |
| 75 | } |
| 76 | |
| 77 | val, err := r.GetRuntimeConfig(ctx, name) |
| 78 | if err != nil { |
| 79 | return zero, xerrors.Errorf("resolve runtime: %w", err) |
| 80 | } |
| 81 | |
| 82 | inst := create[T]() |
| 83 | if err = inst.Set(val); err != nil { |
| 84 | return zero, xerrors.Errorf("instantiate new %T: %w", inst, err) |
| 85 | } |
| 86 | return inst, nil |
| 87 | } |
| 88 | |
| 89 | // name returns the configured name, or fails with ErrNameNotSet. |
| 90 | func (e RuntimeEntry[T]) name() (string, error) { |