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

dispatchserver package #3

Merged
merged 8 commits into from
Jun 10, 2024
Merged

dispatchserver package #3

merged 8 commits into from
Jun 10, 2024

Conversation

chriso
Copy link
Contributor

@chriso chriso commented Jun 7, 2024

This adds a dispatchserver package for use by Dispatch itself when serving its API, and when making requests to an endpoint. Having the server and client live in this repo allows us to use higher level interfaces everywhere, and consolidate request signature generation and validation here (without opening up the internal/auth package).

There were two components from the dispatchtest package that I've repurposed for the task.

@chriso chriso self-assigned this Jun 7, 2024
}

// Run sends a RunRequest and returns a RunResponse.
func (c *EndpointClient) Run(ctx context.Context, header http.Header, req dispatch.Request) (dispatch.Response, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you considered making the header part of the dispatch.Request type instead of passing it into the function each time?

If we don't have a use case for configuring the header differently on each request it could also be a property of EndpointClient to take it out of the Run method signature.

What do you think?

Copy link
Contributor Author

@chriso chriso Jun 10, 2024

Choose a reason for hiding this comment

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

See dc653d6.

We have a use case upstream where we need to change the header on each request, but we also need to change the signing key too, which is currently set via an option 👍

Copy link
Contributor

@achille-roussel achille-roussel left a comment

Choose a reason for hiding this comment

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

Really nice work 🙌

@chriso chriso merged commit 3111a8d into main Jun 10, 2024
2 checks passed
@chriso chriso deleted the dispatchserver branch June 10, 2024 06:37
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