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

cleanup api server struct creation #3823

Open
michel-laterman opened this issue Aug 19, 2024 · 0 comments
Open

cleanup api server struct creation #3823

michel-laterman opened this issue Aug 19, 2024 · 0 comments
Labels
good first issue Good for newcomers Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team tech debt

Comments

@michel-laterman
Copy link
Contributor

The api.Server's creation signature is:

NewServer(addr string, cfg *config.Server, ct *CheckinT, et *EnrollerT, at *ArtifactT, ack *AckT, st *StatusT, sm policy.SelfMonitor, bi build.Info, ut *UploadT, ft *FileDeliveryT, pt *PGPRetrieverT, bulker bulk.Bulk, tracer *apm.Tracer) *server

This leads to test cases where we pass a lot of nil args:

srv := NewServer(addr, cfg, nil, nil, nil, nil, nil, nil, fbuild.Info{}, nil, nil, nil, nil, nil)

We should change the signature of NewServer to take a struct that has the pointers to all the route handlers, i.e.,

NewServer(addr string, cfg *config.Server, bi build.Info, handlers *Handlers)

or use optional args, i.e.,

NewServer(addr string, cfg *config.Server, bi build.Info, ...options Option)

We can also try to change where we apply the handler rate-limiters to get rid of the pathToOperation function and clean up how the endpoints are wrapped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team tech debt
Projects
None yet
Development

No branches or pull requests

2 participants