![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
github.com/arsham/retry/v3
This library supports Go >= 1.22
by getting github.com/arsham/retry/v3
. For
older versions (Go >= 1.20
) import github.com/arsham/retry/v2
, or older Go
versions import github.com/arsham/retry
.
Retry
calls your function, and if it errors it calls it again with a delay.
Eventually it returns the last error or nil if one call is successful.
r := &retry.Retry{
Attempts: 666,
Delay: time.Millisecond,
}
err := r.Do(func() error {
// do some work.
return nil
})
You can provide multiple functions:
err := r.Do(func() error {
return nil
}, func() error {
return nil
}}
You can use the DoContext
and pass a context object to stop when the context
is cancelled:
err := r.DoContext(ctx, func() error {
return nil
})
If you want to stop retrying you can return a special error:
err := r.Do(func() error {
if specialCase {
return &retry.StopError{
Err: errors.New("a special stop"),
}
}
return nil
})
The standard behaviour is to delay the amount you set. You can pass any function with this signature to change the delay behaviour:
func(attempt int, delay time.Duration) time.Duration
You can also pass the retry.IncrementalDelay
function that would increase the
delay with a jitter to prevent Thundering
herd.
r := &retry.Retry{
Attempts: 666,
Delay: 10 * time.Millisecond,
Method: retry.IncrementalDelay,
}
err := r.Do(func() error {
if specialCase {
return &retry.StopError{
Err: errors.New("a special stop"),
}
}
return nil
})
Use of this source code is governed by the Apache 2.0 license. License can be found in the LICENSE file.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.