Commit 384a7ee9 authored by lukasburgey's avatar lukasburgey
Browse files

Add arg on initial fetches

parent 4d488353
Pipeline #92939 failed with stages
in 1 minute and 51 seconds
......@@ -25,7 +25,7 @@ var (
httpClient = &http.Client{}
)
func (src Source) fetchDeps(sink chan<- deps.Dep) (err error) {
func (src Source) fetchDeps(sink chan<- deps.Dep, initial bool) (err error) {
if len(src.Config.EntitlementToServiceIDs) == 0 && len(src.Config.GroupToServiceIDs) == 0 {
log.Printf("[HTTP] Not fetching because the are no services to fetch")
return
......@@ -36,6 +36,9 @@ func (src Source) fetchDeps(sink chan<- deps.Dep) (err error) {
// construct a request
uri := "https://" + src.Config.Hostname + "/client/dep-states"
if initial {
uri += "?initial=true"
}
req, err := http.NewRequest("GET", uri, nil)
if err != nil {
err = fmt.Errorf("Request creation failed: %s", err)
......@@ -104,7 +107,7 @@ func (src *Source) Connect() (<-chan deps.Dep, error) {
log.Printf("[HTTP] Source stopping")
return
}
err = src.fetchDeps(sinkPipe)
err = src.fetchDeps(sinkPipe, false)
if err != nil {
log.Printf("[HTTP] Error fetching: %s", err)
}
......@@ -112,9 +115,9 @@ func (src *Source) Connect() (<-chan deps.Dep, error) {
}
}()
// start one fetch right now
// start an initial fetch right now
go func() {
err := src.fetchDeps(sinkPipe)
err := src.fetchDeps(sinkPipe, true)
if err != nil {
log.Printf("[HTTP] Error fetching: %s", err)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment