Comments (6)
Hey @leosunmo!
I would gladly accept a PR to change the signature to use string pointers, thanks for your thoughts on this.
from vulcanizer.
Thanks for this issue @leosunmo! Totally agree we should handle this.
I'm debating right now between three options:
- adding a new
ClearClusterSetting(string)
function - changing the signature of
SetClusterSetting(string, string)
toSetClusterSetting(string, *string)
so you can actually passnil
to the function - add a special case for when
"null"
is passed toSetClusterSetting
.
Right now I'm leaning towards option 3, although it's a little messy code-wise, that's the thing I would have tried intuitively as well.
from vulcanizer.
Hey @nickcanz , thanks for your reply.
Since the user is supposed to save the original setting and perform actions based on it (like resetting the settings once their operation is complete) we have to keep that in mind.
- This could be an OK setup, just have to keep in mind that the user is supposed to use the return of
SetClusterSetting()
. Here's probably how I would use it:
oldSetting, newSetting, err := client.SetClusterSetting(setting, value)
defer func() {
if oldSetting == "" {
ClearClusterSetting(setting)
return
}
client.SetClusterSetting(setting, oldSetting)
}()
- If you change the signature to use pointers you'll probably have to change the return as well (so it can be used when resetting the settings using the
oldSetting
return). Documentation around the function also has to be very clear.
oldSetting, newSetting, err := client.SetClusterSetting(setting, valuePtr)
defer func() {
client.SetClusterSetting(setting, oldSetting) // oldSetting has to be a pointer as well or we'll have to check if it's nil all the time.
}()
- This is a bit messy and confusing since the
"null"
is a string, not an actual JSONnull
value, which is not a string.
SetClusterSetting()
would also have to check if the return from Elasticsearch is""
/null
and return a"null"
string instead, otherwise it couldn't be used in adefer
like I did above.
IfSetClusterSetting()
returned a"null"
string it would be quite tidy from a code perspective.
oldSetting, newSetting, err := client.SetClusterSetting(setting, value)
defer func() {
client.SetClusterSetting(setting, oldSetting) // We don't care if oldSetting is "500" or unset/"null" because SetClusterSetting will deal with it internally.
}()
If the user wants to use the value for something other than SetClusterSetting()
it might a bit confusing when the value is suddenly a "null"
string however, so documentation will be important.
from vulcanizer.
I'm not quite sure which one I prefer yet. I guess if I was writing SetClusterSetting
from scratch I'd probably use string pointers since it makes sense when you marshal the response from ES you'd get nil values where the value wasn't explicitly set.
from vulcanizer.
If you could have a think after the holidays I could send a PR implementing a solution.
from vulcanizer.
Will work on this when I get time
from vulcanizer.
Related Issues (19)
- Integrate public CI server HOT 1
- Integrate linting to the project HOT 1
- Compatibility with Elasticsearch Domain hidden behind a Loadbalancer HOT 8
- Snapshot list show incorrect finished date while running a snapshot HOT 4
- allow setting username/password in yaml config HOT 1
- Integrate go-docs to build documentation HOT 1
- Panic during golangci-lint typecheck (cgo files)
- Diff mappings HOT 4
- Add an ability to set multiple hosts per cluster HOT 1
- Malformed http request HOT 3
- Request to add prompt for password HOT 8
- Passing authentication through Go API HOT 2
- Get index settings for "private" indices not working HOT 3
- Get Disk Allocation information for Nodes HOT 2
- Release v0.5.2 HOT 3
- A link in this repo's readme points to a folder called "vendor" which does not (or no longer?) exists in this repo. Gives Status code [404:NotFound] HOT 1
- Provide pre built releases for the major platforms HOT 3
- AWS Elasticsearch Service Support - PR's Welcome? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vulcanizer.