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

Implement fmt.Stringer interface for StreamType #495

Merged
merged 2 commits into from
May 10, 2023

Conversation

svrana
Copy link
Contributor

@svrana svrana commented Apr 8, 2023

Following the example of Code, implement fmt.Stringer for StreamType. This makes it easier to use stream types in logs, traces, metric tags, and the like.

@CLAassistant
Copy link

CLAassistant commented Apr 8, 2023

CLA assistant check
All committers have signed the CLA.

@svrana
Copy link
Contributor Author

svrana commented Apr 8, 2023

I started porting/writing a logging interceptor at github.com/svrana/go-connect-middleware and it'd be nice to be able output the StreamType as a string as is done in the grpc version of this code. Course I could do that in my own project, but thought it might generally be useful.

@bufdev
Copy link
Member

bufdev commented Apr 10, 2023

I'm not sure we want to do this for this single enum - we'll discuss if we want to expose fmt.Stringer across enums. It adds to the API surface, so we want to make sure this is something we want to do.

case StreamTypeBidi:
return "bidi"
}
return fmt.Sprintf("stream_%d", s)
Copy link
Member

Choose a reason for hiding this comment

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

If we do do this, generally we've just done strconv.Itoa(int(s)) for these cases

@svrana svrana closed this Apr 11, 2023
@akshayjshah akshayjshah reopened this May 4, 2023
@akshayjshah
Copy link
Member

@svrana I'm going to reopen this, tack on a few commits, and get this merged in :)

Copy link
Member

@akshayjshah akshayjshah left a comment

Choose a reason for hiding this comment

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

This looks good to me. Thanks for following the example of Code so closely, @svrana!

@akshayjshah akshayjshah merged commit acc59cb into connectrpc:main May 10, 2023
renovate bot referenced this pull request in open-feature/flagd May 31, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[github.com/bufbuild/connect-go](https://togithub.com/bufbuild/connect-go)
| require | minor | `v1.7.0` -> `v1.8.0` |

---

### Release Notes

<details>
<summary>bufbuild/connect-go</summary>

###
[`v1.8.0`](https://togithub.com/bufbuild/connect-go/releases/tag/v1.8.0)

[Compare
Source](https://togithub.com/bufbuild/connect-go/compare/v1.7.0...v1.8.0)

#### What's Changed

##### Enhancements

- Expose HTTP method of unary requests (see
[documentation][http-method-docs]) by
[@&#8203;jhump](https://togithub.com/jhump) and
[@&#8203;akshayjshah](https://togithub.com/akshayjshah) in
[https://github.com/bufbuild/connect-go/pull/502](https://togithub.com/bufbuild/connect-go/pull/502)
and
[https://github.com/bufbuild/connect-go/pull/509](https://togithub.com/bufbuild/connect-go/pull/509)
- Implement `fmt.Stringer` interface for StreamType to improve debug
logging by [@&#8203;svrana](https://togithub.com/svrana) in
[https://github.com/bufbuild/connect-go/pull/495](https://togithub.com/bufbuild/connect-go/pull/495)

##### Bugfixes

- Fix documentation comments to use correct identifier name by
[@&#8203;cuishuang](https://togithub.com/cuishuang) in
[https://github.com/bufbuild/connect-go/pull/498](https://togithub.com/bufbuild/connect-go/pull/498)
- Fix Makefile quotes to handle paths with spaces by
[@&#8203;bufdev](https://togithub.com/bufdev) in
[https://github.com/bufbuild/connect-go/pull/508](https://togithub.com/bufbuild/connect-go/pull/508)
- Always close response body in `CloseRead` by
[@&#8203;pkwarren](https://togithub.com/pkwarren) in
[https://github.com/bufbuild/connect-go/pull/515](https://togithub.com/bufbuild/connect-go/pull/515)

#### New Contributors

- [@&#8203;cuishuang](https://togithub.com/cuishuang) made their first
contribution in
[https://github.com/bufbuild/connect-go/pull/498](https://togithub.com/bufbuild/connect-go/pull/498)
- [@&#8203;svrana](https://togithub.com/svrana) made their first
contribution in
[https://github.com/bufbuild/connect-go/pull/495](https://togithub.com/bufbuild/connect-go/pull/495)

**Full Changelog**:
bufbuild/connect-go@v1.7.0...v1.8.0

[http-method-docs]:
https://connect.build/docs/go/get-requests-and-caching#distinguishing-get-requests

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/open-feature/flagd).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMDIuMTAiLCJ1cGRhdGVkSW5WZXIiOiIzNS4xMDIuMTAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
akshayjshah added a commit that referenced this pull request Jul 26, 2023
Following the example of `Code`, implement `fmt.Stringer` for
`StreamType`. This makes it easier to use stream types in logs, traces,
metric tags, and the like.

Co-authored-by: Akshay Shah <akshayjshah@users.noreply.github.com>
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