Skip to content

Commit

Permalink
refactoring and cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
rbarazzutti committed Aug 20, 2023
1 parent 9d1ae30 commit b181243
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
15 changes: 8 additions & 7 deletions app/httpping.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (h *httpPingTestVersion) checkHttp(prep func(*Config)) <-chan string {
http3Advertisement := ""

if m != nil && !m.IsFailure {
if m.AltSvcH3 != "" {
if m.AltSvcH3 != nil {
h.advertisedHttp3 = true
http3Advertisement = " (*)"
}
Expand Down Expand Up @@ -155,9 +155,9 @@ func (httpPingImpl *httpPingImpl) Run() error {

loop := true
first := true

for loop {
select {

case <-tickerChan:
m := throughputMeasurer.Measure()
httpPingImpl.logger.onTick(m)
Expand All @@ -172,19 +172,20 @@ func (httpPingImpl *httpPingImpl) Run() error {
}

httpPingImpl.logger.onMeasure(measure)
if config.Throughput && !tpuStarted {
throughputMeasurer.Measure()
tickerChan = (time.NewTicker(config.ThroughputRefresh)).C
tpuStarted = true
}
if !measure.IsFailure {
if config.Throughput && !tpuStarted {
throughputMeasurer.Measure()
tickerChan = (time.NewTicker(config.ThroughputRefresh)).C
tpuStarted = true
}
throughputMeasurer.Count(measure.MeasuresCollection.Get(stats.Total))

if config.AudibleBell {
_, _ = fmt.Fprintf(stdout, "\a")
}
}
}

case <-ic:
loop = false
}
Expand Down
2 changes: 1 addition & 1 deletion app/pinger.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type HTTPMeasure struct {
RemoteAddr string
TLSEnabled bool
TLSVersion string
AltSvcH3 string
AltSvcH3 *string

MeasuresCollection *stats.MeasuresCollection

Expand Down
10 changes: 3 additions & 7 deletions app/webclientimpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,16 +376,12 @@ func (webClient *webClientImpl) DoMeasure(followRedirect bool) *HTTPMeasure {
}
}

altSvcH3 := ""
altSvcH3 := checkAltSvcH3Header(res.Header)

if val := checkAltSvcH3Header(res.Header); val != nil {
altSvcH3 = *val
}

if altSvcH3 != "" && !strings.HasPrefix(res.Proto, "HTTP/3") && !webClient.config.Http1 && !webClient.config.Http2 {
if altSvcH3 != nil && !strings.HasPrefix(res.Proto, "HTTP/3") && !webClient.config.Http1 && !webClient.config.Http2 {
_, _ = fmt.Printf(" ─→ server advertised HTTP/3 endpoint, using HTTP/3\n")

return webClient.moveToHttp3(altSvcH3, measureContext.timerRegistry, followRedirect)
return webClient.moveToHttp3(*altSvcH3, measureContext.timerRegistry, followRedirect)
}

measureContext.startIngestion()
Expand Down

0 comments on commit b181243

Please sign in to comment.