Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pooling of Context instances #955

Closed
martintmk opened this issue Aug 11, 2022 · 0 comments · Fixed by #1111
Closed

Pooling of Context instances #955

martintmk opened this issue Aug 11, 2022 · 0 comments · Fixed by #1111

Comments

@martintmk
Copy link
Contributor

martintmk commented Aug 11, 2022

Is your feature request related to a specific problem? Or an existing feature? Please describe.

We have noticed increased allocations related to creating the Context object. This can be easily avoided if Pollu provides built-in support for pooling or at least slightly change the internal implementation of Context so we can easily reset it to default state.

Currently, this is not achievable because of these read-only properties:

  • OperationId
  • CorrelationId

Describe your proposed or preferred solution:

We want to extend the Context API with the following static methods:

public static Context Get();
public static Context Get(string operationName);
public static void Return(Context context);

Alternatively, we can introduce a new ContextPool static class.

The pool can be also used internally to improve Polly performance.

Describe any alternative options you've considered:

Simpler solution is to make the following changes to Context class:

protected Guid? CorrelationIdField { get; protected set; }
public string OperationKey { get; protected set; }

We would just derive from Context and handle the pooling ourselves.

Any additional info?

For pooling support, we need implementation of the pool, and we can either:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant