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 ( ...@@ -25,7 +25,7 @@ var (
httpClient = &http.Client{} 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 { if len(src.Config.EntitlementToServiceIDs) == 0 && len(src.Config.GroupToServiceIDs) == 0 {
log.Printf("[HTTP] Not fetching because the are no services to fetch") log.Printf("[HTTP] Not fetching because the are no services to fetch")
return return
...@@ -36,6 +36,9 @@ func (src Source) fetchDeps(sink chan<- deps.Dep) (err error) { ...@@ -36,6 +36,9 @@ func (src Source) fetchDeps(sink chan<- deps.Dep) (err error) {
// construct a request // construct a request
uri := "https://" + src.Config.Hostname + "/client/dep-states" uri := "https://" + src.Config.Hostname + "/client/dep-states"
if initial {
uri += "?initial=true"
}
req, err := http.NewRequest("GET", uri, nil) req, err := http.NewRequest("GET", uri, nil)
if err != nil { if err != nil {
err = fmt.Errorf("Request creation failed: %s", err) err = fmt.Errorf("Request creation failed: %s", err)
...@@ -104,7 +107,7 @@ func (src *Source) Connect() (<-chan deps.Dep, error) { ...@@ -104,7 +107,7 @@ func (src *Source) Connect() (<-chan deps.Dep, error) {
log.Printf("[HTTP] Source stopping") log.Printf("[HTTP] Source stopping")
return return
} }
err = src.fetchDeps(sinkPipe) err = src.fetchDeps(sinkPipe, false)
if err != nil { if err != nil {
log.Printf("[HTTP] Error fetching: %s", err) log.Printf("[HTTP] Error fetching: %s", err)
} }
...@@ -112,9 +115,9 @@ func (src *Source) Connect() (<-chan deps.Dep, error) { ...@@ -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() { go func() {
err := src.fetchDeps(sinkPipe) err := src.fetchDeps(sinkPipe, true)
if err != nil { if err != nil {
log.Printf("[HTTP] Error fetching: %s", err) 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