-
Notifications
You must be signed in to change notification settings - Fork 626
API object exposes a huge surface. #172
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
Comments
I understand your concern about the size. The thing to keep in mind is that the goal of the I somewhat understand your suggestion to change the composition, but a more fleshed-out version, in code, would probably make it easier to discuss it further. Another way of achieving your goal would be to use the Also, if you're mainly interested in indexing data, the |
Hi @scudette, I've left a comment at #177 (comment), can you have a look there? |
Hi @karmi I took a very quick look at this pr. I think the pr makes the api much simpler for a user that is not that familiar with elastic because it is very similar to the documented API and feels like a natural part of the API rather than an unintended side effect of another API. Maybe your suggested change works (sorry I haven't tried it) but it feels to me like a hack: as a user not familiar with elastic I have no idea what a transport is and why should I jump through these hacks just to call essentially a rest API. I want to read the documentation for the library and see something like "if you only need to include one API you can compose the client like this" I actually did consider just calling the rest API directly because it is not that hard and maybe that's actually simpler for me to understand than doing some convoluted things like you suggested. But it feels like reinvent the wheel. Your suggestion to vendor a part of the API also feels like a hack. If I need to vendor a part of the code I might as well just fork the entire project and change the couple lines that I need. This is what I did here https://github.com/Velocidex/go-elasticsearch I was surprised at how essentially simple the change is but it did take me a while to figure it out so that's why I think it would be nice to include upstream. Of course this pr is much nicer and the proper way for sure, so I would love to see it merged. |
Hello, sorry for the delay with the response. I don't consider the suggestion in #177 (comment) to be a hack. After all, the As I observe people using the client, there's a fairly balanced split between people calling the methods on the client ( I if I recall correctly, your use case was focused on bulk indexing, which is trickier — the most effective way of bulk indexing with Go is to use the helper, which currently expects the full client. This is actually something much worth looking into. |
Ok sure if there is a documented way to call the bulk index api without a full client then it should solve my issue (I think - I still have to check how much is getting linked in). Currently the sample code builds a full client here
but maybe it can be turned into an interface? |
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:
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.
The text was updated successfully, but these errors were encountered: