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()
|
||||||
|
|
||||||
|
|
17
serv/reso.go
17
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,15 +93,17 @@ func buildFn(r configRemote) func(*http.Request, []byte) ([]byte, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, v := range r.SetHeaders {
|
||||||
|
req.Header.Set(v.Name, v.Value)
|
||||||
|
}
|
||||||
|
|
||||||
for _, v := range r.PassHeaders {
|
for _, v := range r.PassHeaders {
|
||||||
h.Set(v, inReq.Header.Get(v))
|
req.Header.Set(v, inReq.Header.Get(v))
|
||||||
}
|
}
|
||||||
if len(h) != 0 {
|
|
||||||
if host, ok := h["Host"]; ok {
|
if host, ok := req.Header["Host"]; ok {
|
||||||
req.Host = host[0]
|
req.Host = host[0]
|
||||||
}
|
}
|
||||||
req.Header = h
|
|
||||||
}
|
|
||||||
|
|
||||||
res, err := client.Do(req)
|
res, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue