Skip to content
martincostello edited this page Sep 28, 2023 · 6 revisions

No-Op

ℹ️ This documentation describes the previous Polly v7 API. If you are using the new v8 API, please refer to pollydocs.org.

Purpose

Provides a policy which executes passed delegates without intervention.

Premise: 'Bypass Polly'

Sometimes you have code which expects a policy, but you want to run the execution without intervention.

A common use is to stub out Polly in unit tests (to test a system-under-test without the effects of policies you might use in production intervening in the test).

NoOpPolicy can also be used in code architectures where you expect callers to pass in a policy to govern an executed action, but you have some actions where you have no policy to apply.

Syntax

NoOpPolicy noOp = Policy.NoOp();

Syntax examples above are sync; comparable async overloads exist for asynchronous operation. See readme and wiki for more details.

Operation

Executes the passed delegate without intervention.

Thread safety and policy reuse

Thread safety

The operation of NoOpPolicy is thread-safe: multiple calls may safely be placed concurrently through a policy instance.

Policy reuse

NoOpPolicy instances may be re-used across multiple call sites.

Clone this wiki locally