-
Notifications
You must be signed in to change notification settings - Fork 0
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
go: generate *Ctx version of public functions #457
go: generate *Ctx version of public functions #457
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @passichenko and the rest of your teammates on Graphite |
@@ -684,6 +693,10 @@ func (g *goGenerator) genGoForFeature(ctx context.Context, r repo.ConfigurationR | |||
if err := templ.Execute(&ret, data); err != nil { | |||
return nil, err | |||
} | |||
data.PassCtx = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is ugly and relies on the fact that we don't use PassCtx
in private functions
but it was the simplest way to reuse the template
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: a comment here to explain the reasoning behind doing this twice would be helpful
@@ -401,19 +402,22 @@ func (c *LekkoClient) {{$.FuncName}}({{$.ArgumentString}}) {{$.RetType}} { | |||
} | |||
debug.LogDebug("Lekko fallback", "name", "{{$.Namespace}}/{{$.Key}}", "result", result) | |||
return result | |||
}`, | |||
} | |||
`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here and below: this is to have a newline after each function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought gofmt should handle this automatically 🤔 but don't mind this change regardless
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this case the issue was that without a newline the description of the context-aware function was on the same line as the closing }
and gofmt can't fix that
df08ed7
to
cc33fff
Compare
@@ -401,19 +402,22 @@ func (c *LekkoClient) {{$.FuncName}}({{$.ArgumentString}}) {{$.RetType}} { | |||
} | |||
debug.LogDebug("Lekko fallback", "name", "{{$.Namespace}}/{{$.Key}}", "result", result) | |||
return result | |||
}`, | |||
} | |||
`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought gofmt should handle this automatically 🤔 but don't mind this change regardless
@@ -684,6 +693,10 @@ func (g *goGenerator) genGoForFeature(ctx context.Context, r repo.ConfigurationR | |||
if err := templ.Execute(&ret, data); err != nil { | |||
return nil, err | |||
} | |||
data.PassCtx = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: a comment here to explain the reasoning behind doing this twice would be helpful
cc33fff
to
5bc5295
Compare
OTel integration requires passing contexts down into lekko client. It's a common practice in Go to have special versions of functions that take context, so with this change we will generate two public getters:
GetFoo()
andGetFooCtx(ctx)
.