Description
Currently the API is exposed via an API object which initializes all the API functions in members (https://github.com/elastic/go-elasticsearch/blob/master/esapi/api._.go#L465)
Our application only needs to access the Bulk API to push to elastic but we are forced to use the API Client as obtained from NewClient(), This adds approximately 6mb to our executable size for a single linked function! Please consider making the API a bit lighter to use. We only need to replicate a few functions in a more flexible way to avoid this cost:
- Allow a transport to be created without an API object (Basically NewClient() first part without calling esapi.New(tp)
- Make the new* functions public in esapi so we could initialize just the API functions we need.
This will allow the Go compiler to remove all the unused code from the binary since it is not called. The current API design forces the Go compiler to include all code because it has no idea if it will be called at runtime through the API members.
It would actually be cleaner design to decompose the API client into a transport and distinct handlers that require the transport as parameter - i.e. rather than calling through a function pointer in the API struct, simply allow callers to call the handlers directly.