Add chaos middleware
This commit is contained in:
parent
1c19b22d8c
commit
d3b902b410
@ -285,6 +285,18 @@ func kiotaMiddlewares(
|
|||||||
cc *clientConfig,
|
cc *clientConfig,
|
||||||
counter *count.Bus,
|
counter *count.Bus,
|
||||||
) []khttp.Middleware {
|
) []khttp.Middleware {
|
||||||
|
// Add chaos handler to default middleware
|
||||||
|
chaosOpt := &khttp.ChaosHandlerOptions{
|
||||||
|
ChaosStrategy: khttp.Random,
|
||||||
|
ChaosPercentage: 50,
|
||||||
|
StatusCode: 429,
|
||||||
|
}
|
||||||
|
|
||||||
|
chaosHandler, err := khttp.NewChaosHandlerWithOptions(chaosOpt)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
retryOptions := khttp.RetryHandlerOptions{
|
retryOptions := khttp.RetryHandlerOptions{
|
||||||
ShouldRetry: func(
|
ShouldRetry: func(
|
||||||
delay time.Duration,
|
delay time.Duration,
|
||||||
@ -311,6 +323,7 @@ func kiotaMiddlewares(
|
|||||||
khttp.NewParametersNameDecodingHandler(),
|
khttp.NewParametersNameDecodingHandler(),
|
||||||
khttp.NewUserAgentHandler(),
|
khttp.NewUserAgentHandler(),
|
||||||
&LoggingMiddleware{},
|
&LoggingMiddleware{},
|
||||||
|
chaosHandler,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optionally add concurrency limiter middleware if it has been initialized.
|
// Optionally add concurrency limiter middleware if it has been initialized.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user