Skip to content

Add methodForTest() convention to the style guide.#1240

Merged
mattklein123 merged 2 commits intoenvoyproxy:masterfrom
dnoe:style_update
Jul 11, 2017
Merged

Add methodForTest() convention to the style guide.#1240
mattklein123 merged 2 commits intoenvoyproxy:masterfrom
dnoe:style_update

Conversation

@dnoe
Copy link
Copy Markdown
Contributor

@dnoe dnoe commented Jul 11, 2017

This naming convention is used throughout Envoy but I didn't see any
reference to it in the style guide.

This naming convention is used throughout Envoy but I didn't see any
reference to it in the style guide.
@dnoe dnoe requested a review from mattklein123 July 11, 2017 14:20
STYLE.md Outdated
Envoy namespace there should be a comment of the form `// NOLINT(namespace-envoy)` at
the top of the file.
* If a public method is only intended to be called from test code then it should
have a name that ends in ForTest() such as aMethodForTest().
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: ForTest() in quotes etc.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we also add some kind of clause that this should be a last resort thing. IMO it's rare this is really necessary in prod code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I didn't call it out here explicitly but my understanding is that in Envoy style this is preferable to doing something with friend-ing the test code. Thoughts on that?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't really have a strong opinion either way. My point mainly is that I think in practice it is actually quite rare that one needs to add a public method just for testing or friend the test code. Tests can frequently be written without doing any of that which IMO makes the tests better as the don't see into the inner details of the code under test. I would point that out, but I don't feel very strongly about it either way.

STYLE.md Outdated
Envoy namespace there should be a comment of the form `// NOLINT(namespace-envoy)` at
the top of the file.
* If a public method is only intended to be called from test code then it should
have a name that ends in ForTest() such as aMethodForTest().
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for adding this convention!

Is this also true for protected methods? Would "If a method defined outside of the test directory is only intended..." be more clear or too wordy?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think that's a better way to say it, I'll update.

@mattklein123 mattklein123 merged commit e68ea47 into envoyproxy:master Jul 11, 2017
jpsim pushed a commit that referenced this pull request Nov 28, 2022
Description: Because there was no separate callbacks struct, `c_on_engine_running` and `c_on_exit` were namespaced under `Engine`. This PR moves the `std::function` closures to a dedicated `EngineCallbacks` and moves `c_on_engine_running` and `c_on_exit` into an anonymous namespace.

This PR also normalizes the callback structure for both `EngineCallbacks` and `StreamCallbacks`, so they're constructed & passed around the same.

Risk Level: Low, none of this code is built into a production target.
Testing: Pending

Signed-off-by: Cerek Hillen <chillen@lyft.com>
Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
Description: Because there was no separate callbacks struct, `c_on_engine_running` and `c_on_exit` were namespaced under `Engine`. This PR moves the `std::function` closures to a dedicated `EngineCallbacks` and moves `c_on_engine_running` and `c_on_exit` into an anonymous namespace.

This PR also normalizes the callback structure for both `EngineCallbacks` and `StreamCallbacks`, so they're constructed & passed around the same.

Risk Level: Low, none of this code is built into a production target.
Testing: Pending

Signed-off-by: Cerek Hillen <chillen@lyft.com>
Signed-off-by: JP Simard <jp@jpsim.com>
mathetake pushed a commit that referenced this pull request Mar 3, 2026
**Description**

This adds embeddings tracing per OpenInference OpenAI semantics, and
adjusts docs accordingly.

**Related Issues/PRs**

Fixes #1085

---------

Signed-off-by: Adrian Cole <adrian@tetrate.io>
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.

4 participants