February 2018
Intermediate to advanced
246 pages
6h 3m
English
Query all the available Librarian instances to retrieve search query results, rank them in order, and then send back the results:
package api import ( "bytes" "encoding/json" "fmt" "io" "io/ioutil" "log" "net/http" "os" "sort" "github.com/last-ent/distributed-go/chapter8/goophr/concierge/common" ) var librarianEndpoints = map[string]string{} func init() { librarianEndpoints["a-m"] = os.Getenv("LIB_A_M") librarianEndpoints["n-z"] = os.Getenv("LIB_N_Z") librarianEndpoints["*"] = os.Getenv("LIB_OTHERS") } type docs struct { DocID string 'json:"doc_id"' Score int 'json:"doc_score"' } type queryResult struct { Count int 'json:"count"' Data []docs 'json:"data"' } func queryLibrarian(endpoint string, stBytes io.Reader, ch ...Read now
Unlock full access