Skip to content

Commit

Permalink
add small delay
Browse files Browse the repository at this point in the history
  • Loading branch information
awill1988 committed Oct 31, 2024
1 parent 73dc677 commit b0ab6c5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion jwk/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"encoding/json"
"encoding/pem"
"sync"
"time"

hydra "github.com/ory/hydra-client-go/v2"

Expand All @@ -26,6 +27,7 @@ import (
"github.com/pkg/errors"
)

var waitDelay = 3 * time.Millisecond
var mapLock sync.RWMutex
var locks = map[string]*sync.RWMutex{}

Expand Down Expand Up @@ -54,6 +56,7 @@ func GetOrGenerateKeys(ctx context.Context, r InternalRegistry, m Manager, set,
return nil, err
}
} else {
time.Sleep(waitDelay)
return GetOrGenerateKeys(ctx, r, m, set, kid, alg)
}
} else if err != nil {
Expand All @@ -80,7 +83,7 @@ func GetOrGenerateKeys(ctx context.Context, r InternalRegistry, m Manager, set,
}
return privKey, nil
}

time.Sleep(waitDelay)
return GetOrGenerateKeys(ctx, r, m, set, kid, alg)
}

Expand Down

0 comments on commit b0ab6c5

Please sign in to comment.