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

Receive responses via subscribers #8

Merged
merged 1 commit into from
Jan 25, 2019
Merged

Conversation

alexellis
Copy link
Member

Receive responses via subscribers

  • change enables HTTP body, HTTP status, HTTP headers and any
    error whilst invoking to be received by 1-many subscribers.
  • "print response" behaviour is also moved into a subscriber

Tested with the "tester" example connector.

Example:

// ResponseReceiver enables connector to receive results from the
// function invocation
type ResponseReceiver struct {
}

// Response is triggered by the controller when a message is
// received from the function invocation
func (ResponseReceiver) Response(res types.InvokerResponse) {
	if res.Error != nil {
		log.Printf("tester got error: %s", res.Error.Error())
	} else {
		log.Printf("tester got result: [%d] %s => %s (%d) bytes", res.Status, res.Topic, res.Function, len(*res.Body))
	}
}
	receiver := ResponseReceiver{}
	controller.Subscribe(&receiver)

Closes: #4

Signed-off-by: Alex Ellis (VMware) [email protected]

- change enables HTTP body, HTTP status, HTTP headers and any
error whilst invoking to be received by 1-many subscribers.

Tested with the "tester" example connector.

Signed-off-by: Alex Ellis (VMware) <[email protected]>
@alexellis alexellis merged commit 61c6728 into master Jan 25, 2019
@alexellis alexellis deleted the alexellis/receive-responses branch January 25, 2019 12:59
@alexellis
Copy link
Member Author

This may have breaking changes for the other connectors, I will do a release and raise some issues for the connectors we are tracking.

The tests from @Templum would also be good to bring across.

@Templum
Copy link

Templum commented Jan 25, 2019

@alexellis I will port them. Should I reference this pr ?

@Templum Templum mentioned this pull request Jan 25, 2019
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.

2 participants