"Method calls are executed with at-most-once semantics. This means that Service Weaver does not automatically retry method calls that fail. However, you can detect and retry failed method calls explicitly using weaver.ErrRetriable. If a method call fails because of a transient system error (e.g., a component replica crashed, the network is partitioned), it returns an error with an embedded weaver.ErrRetriable."
With the following example:
// Retry the cache.Get method call up to five times.
var val string
var err error
for i := 0; i < 5; i++ {
val, err = cache.Get(ctx, "key")
if errors.Is(err, weaver.ErrRetriable) {
// Retriable system error! Retry.
continue
}
break
}
[The docs at https://serviceweaver.dev/docs.html are fairly comprehensive, kudos to the team!]