-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Description
While working on several issues on goiardi project it became painfully obvious that due to the age of it and its legacy its not easy to deal with changes and (especially) testing because of the constant need to try to adapt "modern" approach and not break existing features/legacy.
I'd like to propose a v2 version of goiardi which hopefully permit us to be able to deal with several issues in much more optimal manner. I think most of the project related to chef (requests, validations, cookbook searching, etc) can be reused so we should be able to get away with only minor blood.
Main points:
- Use echo (https://echo.labstack.com/) for the underlying web framework. It would permit us to be much more flexible with auth/authorization layer by using middleware, and hook up logging/monitoring/tracing if needed.
- Structured logging (i.e. https://github.com/rs/zerolog). Atm its nearly impossible to hook and parse properly logging messages coming from goiardi. Ideally, on every request, we would propogate a context with logging data which would be amended/emitted on need base
- Using opencensus (https://opencensus.io) and passing contexes for any i/o functions. We really need a better tracing/monitoring. Its not "easy" to monitor and debug goiardi atm. With opencensus, we can emit data in whatever format we want (see exporters https://opencensus.io/exporters/)
- Use of viper (https://github.com/spf13/viper) for configuration. It would easily permit us to ingest different file structure (and yaml is so much easier to parse/manage compared to toml), and it supports automatic casting to env var for whatever config variable we need. Also, since its dynamic, any additional implementation (3d party) can rely on it without touching goiardi entrypoint
- Data layer and File layer should be represented as interfaces and be choosen at start. We should not have conditional (if mysql/postgresl/data) but we should have just a dataLayer.getCookbook(). How it works inside should not be exposed in controller. In this way we will be able to add additional plugins without touching the main code.
- Anonymous json... We really need to stop using it and create a proper structures. In your previous reply on another issue you mentioned malformed json, do you have any example of that by any chance?
- Reduce usage of pointers. Current implementation (especially in cookbook bit) is pretty prone to memory leaks partially due to the usage of pointers. In most of the cases it would be much more performant to just copy back the structure since we are using those objects only as data (as in, accessing their property directly without using any calls, do not modify them inside other methods, etc).Some interesting points on the subject. https://medium.com/@vCabbage/go-are-pointers-a-performance-optimization-a95840d3ef85 . I do realize that it was mainly done due to in memory layer, which brings me to the next point
- Local Datastore. Should we still keep it? If we adopt the interface data/file model, it would be much better off to implement a sqlite driver and have a similar database structure to mysql/postgresql
- Db migration: we really should have a instrument to manage the db migration/versioning integrated in goiardi
- Testing testing testing
- Abandon vendor and move completely to gomod. Since its a breaking change (v2) there is not a lot of to gain in remaining with both solutions, we are using public repos, so we can replace vendoring with go modules without any issue.
- Usage of https://github.com/golangci/golangci-lint for new code
Thats it for now, let me know your thoughts.
Metadata
Metadata
Assignees
Labels
No labels