Add sniffer callback - #1
Open
masnec wants to merge 1 commit into
Open
Conversation
SnifferCallback allows callers to intercept in the sniffing process and decide which (healthy) nodes are considered for receiving requests. When the sniffing process finds a healthy node, the callback is invoked with the [`NodesInfoNode`](https://github.com/olivere/elastic/blob/release-branch.v5/nodes_info.go#L136) struct passed into it. The callback can inspect that struct and return false when the node should be ignored. No requests are routed to that node by the client. Example: ```go func MySnifferCallback(node *elastic.NodeInfoNode) bool { // This sniffer simply ignores node with name "node1" if node.Name == "node1" { return false } return true } ... client, err := elastic.NewClient( elastic.SetSnifferCallback(MySnifferCallback)) if err != nil { log.Fatal(err) } ``` The official clients have a similar feature, e.g. the [`nodesToHostCallback` in the Node.js client](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/configuration.html). See olivere#388 for further discussion.
Owner
Author
|
test doublecheck for masnec |
7 similar comments
Owner
Author
|
test doublecheck for masnec |
Owner
Author
|
test doublecheck for masnec |
Owner
Author
|
test doublecheck for masnec |
Owner
Author
|
test doublecheck for masnec |
Owner
Author
|
test doublecheck for masnec |
Owner
Author
|
test doublecheck for masnec |
Owner
Author
|
test doublecheck for masnec |
|
Deputy for @masnec has completed the 2nd review of this Pull Request and has the following comments: Deputy Reviews
Other suggestionsExpand for more details
|
Owner
Author
|
test doublecheck for masnec |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SnifferCallback allows callers to intercept in the sniffing process and decide which (healthy) nodes are considered for receiving requests.
When the sniffing process finds a healthy node, the callback is invoked with the
NodesInfoNodestruct passed into it. The callback can inspect that struct and return false when the node should be ignored. No requests are routed to that node by the client.Example:
The official clients have a similar feature, e.g. the
nodesToHostCallbackin the Node.jsclient.
See olivere#388 for further discussion.