mirror of
https://github.com/Gouryella/drip.git
synced 2026-02-24 05:10:43 +00:00
fix(tunnel): Fixes the delayed display logic to correctly handle microsecond-level delays.
- Adjust the delayed formatting function to prioritize checking if the delay is 0 to avoid displaying errors. - When the delay is less than 1 millisecond, it is displayed in microseconds to improve the precision of the expression. feat (constants): Shorten heart rate intervals and timeouts to improve response speed. - Adjust HeartbeatInterval from 5 seconds to 2 seconds - Adjust HeartbeatTimeout from 15 seconds to 6 seconds - Improve the sensitivity of heartbeat detection between the client and the server
This commit is contained in:
@@ -158,13 +158,13 @@ func RenderRetrying(interval time.Duration) string {
|
||||
|
||||
// formatLatency formats latency with color
|
||||
func formatLatency(d time.Duration) string {
|
||||
ms := d.Milliseconds()
|
||||
var style lipgloss.Style
|
||||
|
||||
if ms == 0 {
|
||||
if d == 0 {
|
||||
return mutedStyle.Render("measuring...")
|
||||
}
|
||||
|
||||
ms := d.Milliseconds()
|
||||
var style lipgloss.Style
|
||||
|
||||
switch {
|
||||
case ms < 50:
|
||||
style = lipgloss.NewStyle().Foreground(latencyFastColor)
|
||||
@@ -176,6 +176,11 @@ func formatLatency(d time.Duration) string {
|
||||
style = lipgloss.NewStyle().Foreground(latencyRedColor)
|
||||
}
|
||||
|
||||
if ms == 0 {
|
||||
us := d.Microseconds()
|
||||
return style.Render(fmt.Sprintf("%dµs", us))
|
||||
}
|
||||
|
||||
return style.Render(fmt.Sprintf("%dms", ms))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user