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

CLOUDP-237245: adding helper for using Http transport interface #35

Merged
merged 2 commits into from Mar 26, 2024

Conversation

wtrocki
Copy link
Collaborator

@wtrocki wtrocki commented Mar 26, 2024

Context

Current digest library uses transport *http.Transport as interface for creating new transport.
However the generic http interface relies on http.RoundTripper pointer interface.

Change

Adding helper to support interoperability with libraries that confirm with http.RoundTripper.

Notes

Left previous version of the method to not cause unneeded breaking changes. Both use cases are correct and valid.

Copy link
Collaborator

@gssbzn gssbzn left a comment

Choose a reason for hiding this comment

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

LGTM

@wtrocki wtrocki marked this pull request as ready for review March 26, 2024 15:47
@gssbzn gssbzn merged commit 104934e into mongodb-forks:master Mar 26, 2024
7 checks passed
@wtrocki wtrocki deleted the patch-1 branch March 26, 2024 16:06
@@ -124,6 +124,16 @@ func NewTransportWithHTTPTransport(username, password string, transport *http.Tr
return t
}

// NewTransportWithHTTPRoundTripper creates a new digest transport using the supplied http.RoundTripper interface.
func NewTransportWithHTTPRoundTripper(username, password string, transport http.RoundTripper) *Transport {

Choose a reason for hiding this comment

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

Is the prefix New a common convention?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes there are no constructors in go so this is the convention for constructor like behavior, also there's no method overloading so the With is somewhat common as well

Copy link
Collaborator

@gssbzn gssbzn Mar 26, 2024

Choose a reason for hiding this comment

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

And I didn't mention this on the code review since NewTransportWithHTTPTransport already exists but both NewTransportWithHTTPTransport and the new method are not necessary can already create a new transport doing

t := &digest.Transport{
		Username:  username,
		Password:  password,
		Transport: transport,
	}

or even

t := &digest.Transport{
		username,
		password,
		transport,
	}

New methods are only needed if there are private fields or added logic but Transport has none

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My personal opinion is that New methods produce slightly better end user API as new fields in the structure would not cause compilation issues.

Example:
mongodb/atlas-sdk-go@0f2d20a

dmitryax pushed a commit to open-telemetry/opentelemetry-collector-contrib that referenced this pull request Mar 26, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[github.com/mongodb-forks/digest](https://togithub.com/mongodb-forks/digest)
| `v1.0.5` -> `v1.1.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fmongodb-forks%2fdigest/v1.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fmongodb-forks%2fdigest/v1.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fmongodb-forks%2fdigest/v1.0.5/v1.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fmongodb-forks%2fdigest/v1.0.5/v1.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>mongodb-forks/digest
(github.com/mongodb-forks/digest)</summary>

###
[`v1.1.0`](https://togithub.com/mongodb-forks/digest/releases/tag/v1.1.0)

[Compare
Source](https://togithub.com/mongodb-forks/digest/compare/v1.0.5...v1.1.0)

#### What's Changed

- build(deps): bump actions/checkout from 3 to 4 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[mongodb-forks/digest#30
- build(deps): bump golangci/golangci-lint-action from 3.7.0 to 4.0.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[mongodb-forks/digest#31
- build(deps): bump actions/cache from 3 to 4 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[mongodb-forks/digest#32
- build(deps): bump actions/setup-go from 4 to 5 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[mongodb-forks/digest#33
- task: update go matrix by
[@&#8203;gssbzn](https://togithub.com/gssbzn) in
[mongodb-forks/digest#34
- CLOUDP-237245: adding helper for using Http transport interface by
[@&#8203;wtrocki](https://togithub.com/wtrocki) in
[mongodb-forks/digest#35

**Full Changelog**:
mongodb-forks/digest@v1.0.5...v1.1.0

</details>

---

### Configuration

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

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **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://developer.mend.io/github/open-telemetry/opentelemetry-collector-contrib).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjkuMiIsInVwZGF0ZWRJblZlciI6IjM3LjI2OS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: opentelemetrybot <107717825+opentelemetrybot@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
3 participants