(config *retryConfig, tokenRefresher func(ctx context.Context) (string, error))
| 335 | } |
| 336 | |
| 337 | func newUnifiedInterceptor(config *retryConfig, tokenRefresher func(ctx context.Context) (string, error)) *unifiedInterceptor { |
| 338 | ui := &unifiedInterceptor{ |
| 339 | tokenMgr: newTokenManager(), |
| 340 | tokenRefresher: tokenRefresher, |
| 341 | } |
| 342 | |
| 343 | if config != nil && config.maxAttempts > 1 { |
| 344 | ui.maxAttempts = config.maxAttempts |
| 345 | ui.initialInterval = config.initialInterval |
| 346 | ui.maxInterval = config.maxInterval |
| 347 | } else { |
| 348 | // Default retry config for auth errors |
| 349 | ui.maxAttempts = 2 |
| 350 | ui.initialInterval = 1 * time.Second |
| 351 | ui.maxInterval = 1 * time.Second |
| 352 | } |
| 353 | |
| 354 | return ui |
| 355 | } |
| 356 | |
| 357 | func (ui *unifiedInterceptor) WrapUnary(next connect.UnaryFunc) connect.UnaryFunc { |
| 358 | return func(ctx context.Context, req connect.AnyRequest) (connect.AnyResponse, error) { |
no test coverage detected