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

Refactor kncloudevents and add SendEvent function #7092

Merged
merged 34 commits into from
Aug 2, 2023

Conversation

creydr
Copy link
Member

@creydr creydr commented Jul 14, 2023

Adds a function (SendEvent) to the kncloudevents package to Send events. This function:

  • configures the client (e.g. for TLS)
  • has option to send replies
  • has option to send to a DLS
  • has option to add additional transformers

This allows e.g. for use cases like the following:

kncloudevents.SendEvent(ctx, event, sub.Subscriber,
	kncloudevents.WithHeader(additionalHeaders),
	kncloudevents.WithReply(sub.Reply),
	kncloudevents.WithDeadLetterSink(sub.DeadLetter),
	kncloudevents.WithRetryConfig(sub.RetryConfig))

The SendMessage function is provided to make integration with existing packages easier (e.g. in dependent projects).

Also migrated the usages of kncloudevents.NewCloudEventRequest() to the new SendEvent() function (mt-broker-filter and mt-broker-ingress):

@knative-prow knative-prow bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 14, 2023
@knative-prow knative-prow bot requested review from aliok and matzew July 14, 2023 12:22
@codecov
Copy link

codecov bot commented Jul 25, 2023

Codecov Report

Patch coverage: 71.00% and project coverage change: -0.17% ⚠️

Comparison is base (874d288) 78.05% compared to head (e11f71a) 77.89%.
Report is 4 commits behind head on main.

❗ Current head e11f71a differs from pull request most recent head 6edacd9. Consider uploading reports for the commit 6edacd9 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7092      +/-   ##
==========================================
- Coverage   78.05%   77.89%   -0.17%     
==========================================
  Files         250      249       -1     
  Lines       13390    13445      +55     
==========================================
+ Hits        10452    10473      +21     
- Misses       2405     2433      +28     
- Partials      533      539       +6     
Files Changed Coverage Δ
pkg/broker/filter/server_manager.go 0.00% <0.00%> (ø)
pkg/broker/ingress/server_manager.go 0.00% <0.00%> (ø)
pkg/channel/message_dispatcher.go 74.63% <ø> (+1.46%) ⬆️
pkg/kncloudevents/attributes/knative_error.go 100.00% <ø> (ø)
pkg/kncloudevents/http_client_new.go 60.33% <ø> (-0.33%) ⬇️
pkg/kncloudevents/message_sender_new.go 83.78% <ø> (ø)
pkg/kncloudevents/utils.go 72.72% <ø> (+2.72%) ⬆️
...reconciler/inmemorychannel/dispatcher/readiness.go 72.41% <ø> (ø)
pkg/utils/headers.go 100.00% <ø> (ø)
pkg/kncloudevents/event_dispatcher.go 63.12% <63.12%> (ø)
... and 9 more

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

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 25, 2023
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 25, 2023
@creydr
Copy link
Member Author

creydr commented Jul 26, 2023

/retest

1 similar comment
@creydr
Copy link
Member Author

creydr commented Jul 26, 2023

/retest

@creydr creydr changed the title [WIP] Refactor kncloudevents SendMessage Refactor kncloudevents SendMessage Jul 28, 2023
@knative-prow knative-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 28, 2023
@creydr
Copy link
Member Author

creydr commented Jul 28, 2023

Hello @pierDipi,
this PR is ready for review now. Could you PTAL? I also added the migration of the existing usages of the kncloudevents.NewCloudEventRequest() to the new SendEvent() function (could have been done in a seperate PR too, but I wanted to confirm, that everything works as expected with the new lib too).

/assign @pierDipi

@creydr creydr changed the title Refactor kncloudevents SendMessage Refactor kncloudevents and add SendEvent function Jul 28, 2023
@creydr
Copy link
Member Author

creydr commented Jul 28, 2023

/hold
need to recheck for the DLS

@knative-prow knative-prow bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 28, 2023
@matzew
Copy link
Member

matzew commented Aug 1, 2023

OK. cool. Let us know when this is no longer WIP, and ready for review

@matzew
Copy link
Member

matzew commented Aug 1, 2023

FWIW: I ran the test now locally as well, and passes here too - after pulling the updated branch

@matzew
Copy link
Member

matzew commented Aug 1, 2023

/test upgrade-tests

@creydr
Copy link
Member Author

creydr commented Aug 1, 2023

/retest

1 similar comment
@creydr
Copy link
Member Author

creydr commented Aug 1, 2023

/retest

@creydr creydr changed the title [WIP] Refactor kncloudevents and add SendEvent function Refactor kncloudevents and add SendEvent function Aug 2, 2023
@knative-prow knative-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 2, 2023
@creydr
Copy link
Member Author

creydr commented Aug 2, 2023

/unhold

@pierDipi @matzew could you recheck on this PR?

@knative-prow knative-prow bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 2, 2023
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package channel
package kncloudevents_test
Copy link
Member

Choose a reason for hiding this comment

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

package _test ?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, to prevent an import cycle. We are importing here pkg/eventingtls/eventingtlstesting for the TLS tests, which is using pkg/kncloudevents.

Copy link
Member

Choose a reason for hiding this comment

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

meh - ok

// tracing
"x-request-id",
"x-request-id", // tracing
"retry-after",
Copy link
Member

Choose a reason for hiding this comment

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

ah, nice - removing the other frm the filter

Copy link
Member

@matzew matzew left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Aug 2, 2023
@knative-prow
Copy link

knative-prow bot commented Aug 2, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: creydr, matzew

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@matzew
Copy link
Member

matzew commented Aug 2, 2023

/test upgrade-tests

@knative-prow knative-prow bot merged commit 3915df7 into knative:main Aug 2, 2023
24 of 27 checks passed
pierDipi pushed a commit to pierDipi/eventing that referenced this pull request Jan 17, 2024
Adds a function (`SendEvent`) to the kncloudevents package to Send
events. This function:
* configures the client (e.g. for TLS)
* has option to send replies
* has option to send to a DLS
* has option to add additional transformers

This allows e.g. for use cases like the following:
```
kncloudevents.SendEvent(ctx, event, sub.Subscriber,
	kncloudevents.WithHeader(additionalHeaders),
	kncloudevents.WithReply(sub.Reply),
	kncloudevents.WithDeadLetterSink(sub.DeadLetter),
	kncloudevents.WithRetryConfig(sub.RetryConfig))
```

The `SendMessage` function is provided to make integration with existing
packages easier (e.g. in dependent projects).

Also migrated the usages of kncloudevents.NewCloudEventRequest() to the
new SendEvent() function (mt-broker-filter and mt-broker-ingress):
* 74c1552
* 9728713
* 958722d
openshift-merge-bot bot pushed a commit to openshift-knative/eventing that referenced this pull request Jan 17, 2024
* Remove deprecated httpclient msgsender (knative#7018)

## Proposed Changes
Removed the legacy http client go, message sender go and respective test
files, Since the functionality are handled in http client new and
message sender new go

Issue related : knative#6995
 
- 🗑️ Remove feature or internal logic

-
-
-

### Pre-review Checklist

- [x] **At least 80% unit test coverage**
- [ ] **E2E tests** for any new behavior
- [ ] **Docs PR** for any user-facing impact
- [ ] **Spec PR** for any new API feature
- [ ] **Conformance test** for any change to the spec

**Release Note**
 
```release-note

```


**Docs**
 
📖 knative#6995

---------

Co-authored-by: Christoph Stäbler <[email protected]>

* Refactor kncloudevents and add `SendEvent` function (knative#7092)

Adds a function (`SendEvent`) to the kncloudevents package to Send
events. This function:
* configures the client (e.g. for TLS)
* has option to send replies
* has option to send to a DLS
* has option to add additional transformers

This allows e.g. for use cases like the following:
```
kncloudevents.SendEvent(ctx, event, sub.Subscriber,
	kncloudevents.WithHeader(additionalHeaders),
	kncloudevents.WithReply(sub.Reply),
	kncloudevents.WithDeadLetterSink(sub.DeadLetter),
	kncloudevents.WithRetryConfig(sub.RetryConfig))
```

The `SendMessage` function is provided to make integration with existing
packages easier (e.g. in dependent projects).

Also migrated the usages of kncloudevents.NewCloudEventRequest() to the
new SendEvent() function (mt-broker-filter and mt-broker-ingress):
* 74c1552
* 9728713
* 958722d

* Remove deprecated kncloudevents.CloudEventsRequest (knative#7146)

* Remove kncloudevents.CloudEventsRequest

* Run hack/update-codegen.sh

* Add unit tests for generateBackoffFn()

* Fix event dispatcher library data race (knative#7280)

Fix dispatcher data race

Signed-off-by: Pierangelo Di Pilato <[email protected]>

---------

Signed-off-by: Pierangelo Di Pilato <[email protected]>
Co-authored-by: Jeevan <[email protected]>
Co-authored-by: Christoph Stäbler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants