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

Drop context arg from HTTP handler #58

Merged
merged 2 commits into from
Mar 14, 2024

Conversation

dprotaso
Copy link
Contributor

No description provided.

@knative-prow knative-prow bot requested review from lance and salaboy March 13, 2024 23:03
@knative-prow knative-prow bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 13, 2024
@@ -32,7 +32,7 @@ const (
// Start an intance using a new Service
// Note that for CloudEvent Handlers this effectively accepts ANY because
// the actual type of the handler function is determined later.
func Start(f any) error {
func Start(f Handler) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed this - since we want a proper Handler to be passed here.

We shouldn't be failing this during runtime - it will swallow errors.

Copy link
Contributor

@lkingland lkingland Mar 14, 2024

Choose a reason for hiding this comment

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

Well, I thought so too. But then thought it would be possible one might want a Function which fires "OnStart" and "OnStop" but does not accept HTTP requests, or is set to never scale to 0 and performs some action on a chron-like timer. This would open us up to having Functions which fill very different roles than the expected, request-response HTTP cycle... and I think that's a good thing. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This would open us up to having Functions which fill very different roles than the expected, request-response HTTP cycle

For these use cases I'd use a different template and not the HTTP one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Secondly, if the user typos Handle then they won't get feedback here because it's loosely typed.

@dprotaso
Copy link
Contributor Author

/hold for @lkingland

@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 Mar 13, 2024
@dprotaso
Copy link
Contributor Author

/assign @lkingland

@dprotaso
Copy link
Contributor Author

/hold cancel

@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 Mar 14, 2024
@@ -91,7 +91,7 @@ func (s *Service) Start(ctx context.Context) (err error) {
s.handleSignals()

go func() {
if err = s.Server.Serve(s.listener); err != http.ErrServerClosed {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

data race was here

@@ -123,7 +120,7 @@ func (s *Service) Start(ctx context.Context) (err error) {

// Listen and serve
go func() {
if err = s.Server.Serve(s.listener); err != http.ErrServerClosed {
if err := s.Serve(s.listener); err != http.ErrServerClosed {
Copy link
Contributor Author

@dprotaso dprotaso Mar 14, 2024

Choose a reason for hiding this comment

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

data race was here

Copy link
Contributor

@lkingland lkingland left a comment

Choose a reason for hiding this comment

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

Thank you very much! I just have a comment about why we might want to be more permissive and not require the user's Function to be a Handler after all.

@@ -32,7 +32,7 @@ const (
// Start an intance using a new Service
// Note that for CloudEvent Handlers this effectively accepts ANY because
// the actual type of the handler function is determined later.
func Start(f any) error {
func Start(f Handler) error {
Copy link
Contributor

@lkingland lkingland Mar 14, 2024

Choose a reason for hiding this comment

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

Well, I thought so too. But then thought it would be possible one might want a Function which fires "OnStart" and "OnStop" but does not accept HTTP requests, or is set to never scale to 0 and performs some action on a chron-like timer. This would open us up to having Functions which fill very different roles than the expected, request-response HTTP cycle... and I think that's a good thing. WDYT?

@lkingland lkingland added the lgtm Indicates that a PR is ready to be merged. label Mar 14, 2024
Copy link

knative-prow bot commented Mar 14, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dprotaso, lkingland

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

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 14, 2024
@lkingland lkingland merged commit 501e027 into knative-extensions:main Mar 14, 2024
18 checks passed
@dprotaso dprotaso deleted the drop-context-http branch March 14, 2024 00:33
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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants