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

Lazy POC to help with updating singleton components in composite commands or middleware usage #1

Draft
wants to merge 2 commits into
base: hooks-middleware
Choose a base branch
from

Conversation

wbreza
Copy link
Owner

@wbreza wbreza commented Jan 25, 2023

Introduces a Lazy[T] type that we can use to inject into actions that are used within composite actions.

Examples:

  • AzdContext (created in init, used in provision & deploy)
  • Project config (event handlers registered in middleware, used in many other actions)

}

// Sets a value on the lazy type
func (l *Lazy[T]) SetValue(value T) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about, instead we make Lazy accept a mutation, SetInitializer. This will error if someone has already called GetValue that resulted in an initialization. That way, we can avoid having pointers to lazy. It also pushes the error correctly to where we incorrectly set it, versus undefined behavior.

We can also make it the usage of the wrapped lazy value thread-safe, since we don't expose SetValue (unless needed for tests).

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 this pull request may close these issues.

2 participants