Fix race-condition in remote joins
This commit is contained in:
parent
a25fb16507
commit
9aa4928d7b
|
@ -231,6 +231,7 @@ func (c *coreContext) resolveRemotes(
|
||||||
|
|
||||||
to[n] = jsn.Field{[]byte(s.FieldName), ob.Bytes()}
|
to[n] = jsn.Field{[]byte(s.FieldName), ob.Bytes()}
|
||||||
}(i, id, s)
|
}(i, id, s)
|
||||||
|
fmt.Println(">>>", i)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
|
21
serv/reso.go
21
serv/reso.go
|
@ -86,11 +86,6 @@ func initRemotes(t configTable) {
|
||||||
func buildFn(r configRemote) func(*http.Request, []byte) ([]byte, error) {
|
func buildFn(r configRemote) func(*http.Request, []byte) ([]byte, error) {
|
||||||
reqURL := strings.Replace(r.URL, "$id", "%s", 1)
|
reqURL := strings.Replace(r.URL, "$id", "%s", 1)
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
h := make(http.Header, len(r.PassHeaders))
|
|
||||||
|
|
||||||
for _, v := range r.SetHeaders {
|
|
||||||
h.Set(v.Name, v.Value)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn := func(inReq *http.Request, id []byte) ([]byte, error) {
|
fn := func(inReq *http.Request, id []byte) ([]byte, error) {
|
||||||
req, err := http.NewRequest("GET", fmt.Sprintf(reqURL, id), nil)
|
req, err := http.NewRequest("GET", fmt.Sprintf(reqURL, id), nil)
|
||||||
|
@ -98,14 +93,16 @@ func buildFn(r configRemote) func(*http.Request, []byte) ([]byte, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range r.PassHeaders {
|
for _, v := range r.SetHeaders {
|
||||||
h.Set(v, inReq.Header.Get(v))
|
req.Header.Set(v.Name, v.Value)
|
||||||
}
|
}
|
||||||
if len(h) != 0 {
|
|
||||||
if host, ok := h["Host"]; ok {
|
for _, v := range r.PassHeaders {
|
||||||
req.Host = host[0]
|
req.Header.Set(v, inReq.Header.Get(v))
|
||||||
}
|
}
|
||||||
req.Header = h
|
|
||||||
|
if host, ok := req.Header["Host"]; ok {
|
||||||
|
req.Host = host[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := client.Do(req)
|
res, err := client.Do(req)
|
||||||
|
|
Loading…
Reference in New Issue