Log failed resolve attempts in fallbackResolver

main
Max Ignatenko 2024-02-18 15:34:14 +00:00
parent 1038ca3bea
commit 8b89a1544e
1 changed files with 4 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import (
"github.com/bluesky-social/indigo/api"
"github.com/bluesky-social/indigo/did"
"github.com/rs/zerolog"
)
var Resolver did.Resolver
@ -36,11 +37,14 @@ type fallbackResolver struct {
}
func (r *fallbackResolver) GetDocument(ctx context.Context, didstr string) (*did.Document, error) {
log := zerolog.Ctx(ctx)
errs := []error{}
for _, res := range r.resolvers {
if d, err := res.GetDocument(ctx, didstr); err == nil {
return d, nil
} else {
log.Warn().Err(err).Str("plc", res.(*api.PLCServer).Host).
Msgf("Failed to resolve %q using %q: %s", didstr, res.(*api.PLCServer).Host, err)
errs = append(errs, err)
}
}