Skip to content

Empty body stops ReplyTo.#467

Merged
knative-prow-robot merged 11 commits into
knative:masterfrom
Harwayne:buses
Oct 1, 2018
Merged

Empty body stops ReplyTo.#467
knative-prow-robot merged 11 commits into
knative:masterfrom
Harwayne:buses

Conversation

@adamharwayne
Copy link
Copy Markdown
Contributor

Proposed Changes

  • A ReplyTo request is not made if the body of the destination response is emtpy.

Release Note

NONE

@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 26, 2018
@adamharwayne
Copy link
Copy Markdown
Contributor Author

/retest

@adamharwayne
Copy link
Copy Markdown
Contributor Author

/assign @markfisher because I am slightly altering the behavior of ReplyTo.

@adamharwayne
Copy link
Copy Markdown
Contributor Author

/assign @markfisher

Comment thread pkg/buses/message_dispatcher.go Outdated
Comment thread pkg/buses/message_dispatcher_test.go
Comment thread pkg/buses/message_dispatcher.go Outdated

// httpDoer is an interface for making HTTP requests.
type httpDoer interface {
Do(*http.Request) (*http.Response, error)
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.

I think two things:

1- if you want to put an interface infront of the http client, you need to implement all the methods:

type Client
    func (c *Client) Do(req *Request) (*Response, error)
    func (c *Client) Get(url string) (resp *Response, err error)
    func (c *Client) Head(url string) (resp *Response, err error)
    func (c *Client) Post(url, contentType string, body io.Reader) (resp *Response, err error)
    func (c *Client) PostForm(url string, data url.Values) (resp *Response, err error)

2 - the documentation says this: Generally Get, Post, or PostForm will be used instead of Do.

Which implies we are using it wrong and we should take a look at that.

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.

  1. My understanding of Go-style is that we should be creating minimal interfaces. Why add those other methods if we don't use them? If we start using them in the future, then we can add the methods to the interface.

  2. Post() doesn't allow control of the headers. So we use Do() instead.

Comment thread pkg/buses/message_dispatcher_test.go Outdated
Comment thread pkg/buses/message_dispatcher_test.go Outdated
Comment thread pkg/buses/message_dispatcher_test.go Outdated
@adamharwayne
Copy link
Copy Markdown
Contributor Author

/retest

Comment thread pkg/buses/bus.go
ReplyTo: subscription.Spec.ReplyTo,
}
return b.dispatcher.DispatchMessage(message, subscriber, defaults)
return b.dispatcher.DispatchMessage(message, subscriber, subscription.Spec.ReplyTo, defaults)
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.

So, we're in a bit of a wonky world right now since subscription should probably be using the one from eventing since that uses the new "approved to move forward" model. There it's Result?

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.

+1 yeah I wonder if we need to make a copy of bus and have it use the new world subscriptions.

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.

If we end up using the bus abstraction in the new model, then we probably should fork it. This PR is slightly modifying the DispatchMessage() interface, not really modifying anything in the bus abstraction, so I don't think it warrants copying yet.

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.

I tend to agree with @adamharwayne that we should change the existing bus code as little as possible. We want the old objects to continue working while we build the new ones.

@n3wscott
Copy link
Copy Markdown
Contributor

n3wscott commented Oct 1, 2018

/hold
We might need to stop modifying bus and make a copy that acts on new object model.

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 1, 2018
@grantr
Copy link
Copy Markdown
Contributor

grantr commented Oct 1, 2018

/cc @grantr

@adamharwayne
Copy link
Copy Markdown
Contributor Author

/hold cancel

This PR only modifies bus as a side effect of refactoring the DispatchMessage method signature. No functionality is being changed in bus itself.

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 1, 2018
Copy link
Copy Markdown
Contributor

@grantr grantr left a comment

Choose a reason for hiding this comment

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

🎉 yay for increased coverage! Thanks @adamharwayne.

/approve
/lgtm
/hold
Holding for typo fix. Feel free to cancel.

reply, err := d.executeRequest(destinationURL, message)
if err != nil {
return fmt.Errorf("Unable to complete request %v", err)
func (d *MessageDispatcher) DispatchMessage(message *Message, destination, replyTo string, defaults DispatchDefaults) error {
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.

Talked with Adam offline about the signature change that moved defaults.ReplyTo into the positional parameter replyTo. He argued that replyTo is not actually a default since it's specific to each Subscription and is never overridden.

Comment thread pkg/buses/message_dispatcher.go Outdated
Comment thread pkg/buses/bus.go
ReplyTo: subscription.Spec.ReplyTo,
}
return b.dispatcher.DispatchMessage(message, subscriber, defaults)
return b.dispatcher.DispatchMessage(message, subscriber, subscription.Spec.ReplyTo, defaults)
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.

I tend to agree with @adamharwayne that we should change the existing bus code as little as possible. We want the old objects to continue working while we build the new ones.

@knative-prow-robot knative-prow-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. labels Oct 1, 2018
@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adamharwayne, grantr

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

The pull request process is described here

Details 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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 1, 2018
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Oct 1, 2018
Copy link
Copy Markdown
Member

@evankanderson evankanderson left a comment

Choose a reason for hiding this comment

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

/lgtm

Minor nits.

Comment thread pkg/buses/message_dispatcher.go Outdated
Comment thread pkg/buses/message_dispatcher.go Outdated
Comment thread pkg/buses/message_dispatcher_test.go Outdated
@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 1, 2018
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Oct 1, 2018
@knative-metrics-robot
Copy link
Copy Markdown

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/buses/message_dispatcher.go 0.0% 89.1% 89.1

@adamharwayne
Copy link
Copy Markdown
Contributor Author

/hold cancel
Comments addressed.

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 1, 2018
@evankanderson
Copy link
Copy Markdown
Member

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 1, 2018
@knative-prow-robot knative-prow-robot merged commit 644409e into knative:master Oct 1, 2018
@adamharwayne adamharwayne deleted the buses branch October 1, 2018 21:16
sjwoodman pushed a commit to sjwoodman/eventing that referenced this pull request Oct 17, 2018
* Unit tests for passthrough headers.

* Unit tests.

* Respond to PR comments.

* Remove httpDoer and use an in-memory server instead.

* Respond to PR comments.

* Close the response body.

* Respond to PR comments.

* Nil response is an error.

* Unit test improvements suggested by PR comments.
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/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants