-
Notifications
You must be signed in to change notification settings - Fork 14
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
Wrap microcluster app and API endpoints #283
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, LGTM.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great overall. Only minor comments
// Endpoints returns the list of endpoints for a given microcluster app. | ||
func Endpoints(app *microcluster.MicroCluster) []rest.Endpoint { | ||
func (e *Endpoints) Endpoints() []rest.Endpoint { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Endpoints.Endpoints()
reads a bit weird. Maybe call this API
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usage is api.New(...).Endpoints()
, should we maybe rename the type to *api.API
?
@@ -55,10 +55,10 @@ func New(ctx context.Context, cfg Config) (*App, error) { | |||
func (a *App) Run(customHooks *config.Hooks) error { | |||
// TODO: consider improving API for overriding hooks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: is this still relevant? Seems outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, we now pass a *config.Hooks
and selectively apply some of the non-nil hooks. which works ok, as we do hange some hooks in a couple of tests.
but this is not too clean, i'd keep the TODO around for the future
Summary
Capture all required state for the microcluster and the API endpoint implementation in structs.
Changes
*app.App
now wraps the microcluster app and the snap interface*app.App
now implementsapi.Provider
*api.Endpoints
now wraps the required provider (to have access to the snap and microcluster app), and implements the API endpointswrapHandlerWithMicrocluster
closure, and retrieving the snap through the server context.Notes
This will allow us to add more configs to the application, and works towards making it easier to write tests for our API endpoints