1
0
mirror of https://github.com/chai2010/advanced-go-programming-book.git synced 2025-05-24 12:32:21 +00:00

Merge pull request #309 from fuwensun/pr6-5-1f

ch6-5-fix typo
This commit is contained in:
Xargin 2018-08-15 13:29:26 +08:00 committed by GitHub
commit 2366c43f40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -242,7 +242,7 @@ func insertDocument(db string, table string, obj map[string]interface{}) {
```go
func query(indexName string, typeName string) (*elastic.SearchResult, error) {
// 通过 bool must 和 bool shoud 添加 bool 查询条件
// 通过 bool must 和 bool should 添加 bool 查询条件
q := elastic.NewBoolQuery().Must(elastic.NewMatchPhraseQuery("id", 1),
elastic.NewBoolQuery().Must(elastic.NewMatchPhraseQuery("male", "m")))

View File

@ -8,7 +8,7 @@
1. 按顺序挑: 例如上次选了第一台,那么这次就选第二台,下次第三台,如果已经到了最后一台,那么下一次从第一台开始。这种情况下我们可以把 endpoint 都存储在数组中,每次请求完成下游之后,将一个索引后移即可。在移到尽头时再移回数组开头处。
2. 随机挑一个: 每次都随机挑,真随机伪随机均可。设选择第 x 台机器,那么 x 可描述为 `rand.Intn() % n`
2. 随机挑一个: 每次都随机挑,真随机伪随机均可。设选择第 x 台机器,那么 x 可描述为 `rand.Intn() % n`
3. 根据某种权重,对下游 endpoints 进行排序,选择权重最大/小的那一个。