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

[PoC] Split EnabledParameters into read-write and read-only types #5820

Closed

Conversation

MrAlias
Copy link
Contributor

@MrAlias MrAlias commented Sep 13, 2024

This is a proof-of-concept for refactoring the EnabledParameters into a read-only type. A EnabledParametersBuilder type is added to act as a read-write type that wraps EnabledParameters.

In response to #5816 (comment)

The basic idea is a user will create a EnabledParametersBuilder and pass the built EnabledParameters to the Logger.Enabled method:

epb := new(log.EnabledParametersBuilder)
epb.SetSeverity(log.SeverityInfo)
_ = logger.Enabled(ctx, epb.Build())

The EnabledParametersBuilder type can be reused as it passes a static copy of EnabledParameters every time Build is called.

This means that any Logger, and subsequently any Processor in the SDK, will receive a read-only type. If they wish to update this type they can always create a new copy of EnabledParameters by doing something like this:

func (p *Processor) Enabled(ctx context.Context, ep log.EnabledParameters) bool {
	epb := log.EnableParametersBulider{ep}
	epb.SetSeverity(log.SeverityError)
	return downstream(ctx, epb.Build())
}

@MrAlias
Copy link
Contributor Author

MrAlias commented Sep 13, 2024

Closing, not needed: #5816 (comment)

@MrAlias MrAlias closed this Sep 13, 2024
@MrAlias MrAlias deleted the EnabledParametersBuilder branch September 13, 2024 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant