hashicorp / hashicorp/consul

[feature] Extend query endpoint and DNS interface with sort filter and limit capabilities

Open
#9,780 5 comments 2 reactions 0 assignees View on GitHub
theme/dns theme/prepared-query type/enhancement
Dominant language
Go
Stars
30.1k
Forks
4.6k
Avg merge
2d 6h
Merged PRs (30d)
43

Description

#### Feature Description

The current query endpoint already allows some kind of failover and sorting. It would be nice to extend the query endpoint (and the DNS interface) allowing us to do things like:

### sort
Sort the query and DNS output
- by weight
- by metadata
- by tags
- by nodename
- by address
- by random

### limit
limit the query and DNS output
- to N nodes
- to only nodes with a weight < or > N

### filter
filter the query and DNS output
- by removing or/and keeping nodes based on (multiple?) regex (tags, nodename, metadata, weight, ...)
- by removing another query's result
- by the status ("passing" and/or "warning"/"critical")

#### Use Case(s)

An example use case would be Galera (MariaDB or Percona or MySQL). If your application is able to do read and write split and you would like to balance all writes to the same node but all reads to all other or all nodes you could:

1. Create two services like dbread and dbwrite
2. Use the query feature to sort DNS output by weight, filter out all services not having the tag "write" or having status "passing" and limit the output to 1
3. Use the default DNS roundrobin behavior to load-balance all reads OR use the query feature to do RR to all passing nodes but the one chosen with the query done for dbwrite.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.