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

feat: add function runtime to dig.CallbackInfo #412

Merged
merged 2 commits into from
Jul 2, 2024

Conversation

tchung1118
Copy link
Contributor

@tchung1118 tchung1118 commented Jun 27, 2024

This change adds runtime of the associated constructor
or decorator to dig.CallbackInfo.

For example, users can access the runtime of a particular
constructor by:

c := dig.New()
c.Provide(NewFoo, dig.WithProviderCallback(func(ci dig.CallbackInfo) {
    if ci.Error == nil {
        fmt.Printf("constructor %q finished running in %v", ci.Name, ci.Runtime)
    }
}))

This change is a prerequisite for adding uber-go/fx#1213
to report runtime of constructors in Run events.

Copy link

codecov bot commented Jun 27, 2024

Codecov Report

Attention: Patch coverage is 95.23810% with 1 line in your changes missing coverage. Please review.

Project coverage is 98.35%. Comparing base (897df36) to head (1ed1d62).
Report is 1 commits behind head on master.

Current head 1ed1d62 differs from pull request most recent head 26d26ec

Please upload reports for the commit 26d26ec to get more accurate results.

Files Patch % Lines
container.go 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #412      +/-   ##
==========================================
- Coverage   98.40%   98.35%   -0.05%     
==========================================
  Files          22       23       +1     
  Lines        1507     1524      +17     
==========================================
+ Hits         1483     1499      +16     
- Misses         15       16       +1     
  Partials        9        9              

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

Copy link
Contributor

@JacobOaks JacobOaks left a comment

Choose a reason for hiding this comment

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

LGTM modulo some small nits.

Can you also put an example of how this is accessed in the PR summary?

callback.go Outdated Show resolved Hide resolved
internal/digclock/clock.go Outdated Show resolved Hide resolved
internal/digclock/clock.go Outdated Show resolved Hide resolved
dig_test.go Outdated Show resolved Hide resolved
@tchung1118 tchung1118 merged commit 89f5733 into master Jul 2, 2024
9 checks passed
@tchung1118 tchung1118 deleted the taiwon/ctor-runtime branch July 2, 2024 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants