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

Basic runtime support for dynamic providers #2102

Merged
merged 9 commits into from
Jun 18, 2024
Merged

Basic runtime support for dynamic providers #2102

merged 9 commits into from
Jun 18, 2024

Conversation

iwahbe
Copy link
Member

@iwahbe iwahbe commented Jun 17, 2024

This PR replaces the .Replace method with a sounder construct: XParameterizeResetProvider.

  • To achieve a working result, it relaxes an assert in ProposeNew.
  • To clarify how XParameterizeResetProvider works, a level of interface indirection was removed.

Copy link

codecov bot commented Jun 17, 2024

Codecov Report

Attention: Patch coverage is 13.51351% with 32 lines in your changes missing coverage. Please review.

Project coverage is 60.74%. Comparing base (2094289) to head (53ffefd).

Files Patch % Lines
pf/internal/pfutils/proposed_new.go 21.73% 18 Missing ⚠️
pf/tfbridge/provider.go 0.00% 13 Missing ⚠️
pf/tfbridge/main.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2102      +/-   ##
==========================================
- Coverage   60.76%   60.74%   -0.03%     
==========================================
  Files         350      350              
  Lines       45686    45711      +25     
==========================================
+ Hits        27762    27768       +6     
- Misses      16405    16425      +20     
+ Partials     1519     1518       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

info = providerInfo(ctx, tfServer)
}

err = pfbridge.XParameterizeResetProvider(ctx, info, metadata)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the variable which contains the lambda? Is it passed as a reference?

Copy link
Member Author

Choose a reason for hiding this comment

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

If your talking about the lambda introduced in provider.go:

ctx = context.WithValue(ctx, xResetProviderKey{},
func(ctx context.Context, info tfbridge.ProviderInfo, meta ProviderMetadata) error {
pp, err := newProviderWithContext(ctx, info, meta)
if err != nil {
return err
}
*p = *pp
return nil
})

Then ctx is the variable which contains the lambda. XParameterizeResetProvider unpacks the lambda from ctx and then calls it.

Copy link
Contributor

Choose a reason for hiding this comment

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

The metadata used on this line comes from line 51, as far as I can see, right?

The same metadata also contains this function which captures it.

It looks a bit odd and I was wondering if it's passed as a reference for this to work.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I think I know what you mean. In Go, lambdas always have access to the location of variables in their scope. If your familiar with C++, then lambdas close over the lvalue of variables they reference.

dynamic/main.go Show resolved Hide resolved
@iwahbe iwahbe enabled auto-merge (squash) June 18, 2024 18:39
@iwahbe iwahbe force-pushed the iwahbe/runtime branch 2 times, most recently from 34d34e7 to 36c0398 Compare June 18, 2024 21:47
@iwahbe iwahbe merged commit 91c66e4 into master Jun 18, 2024
11 checks passed
@iwahbe iwahbe deleted the iwahbe/runtime branch June 18, 2024 22:25
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.

None yet

2 participants