greshake / i3status-rust

Very resourcefriendly and feature-rich replacement for i3status, written in pure Rust
GNU General Public License v3.0
2.85k stars 470 forks source link

feat: retry policy on `external_ip` block #1891

Closed hgigas closed 1 year ago

hgigas commented 1 year ago

https://github.com/greshake/i3status-rust/blob/49499c1ca624228c4b9e88b62b36cd0fa5e2dce5/src/blocks/external_ip.rs#L230

In my case the message "Failed to request current location" appears longer than the ip. Maybe basic 3 retries...

MaxVerevkin commented 1 year ago

I don't understand this issue. It already retries after error_interval.

hgigas commented 1 year ago

Actual:

  1. Fetch ip fails
  2. Display error message
  3. After error_interval seconds retry

Suggestion:

  1. Fetch ip fails
  2. Don't display anything and retry, for example, 3 times
  3. If fails then display error message
  4. After error_interval seconds retry

With unstable internet connections there are occasional failures, then error message displays, but if you retry surely it will work

MaxVerevkin commented 1 year ago

I see. Perhaps the same effect cat be achieved by increasing the request timeout? Currently it is hardcoded to 10 seconds: https://github.com/greshake/i3status-rust/blob/00a08b5ebdaeb322392a62baf39ec2648762d405/src/lib.rs#L39

hgigas commented 1 year ago

Usually the request is lost no matter how long you wait.

Another solution could be allow error_interval less than 1... I would set 0.3 in my case.

MaxVerevkin commented 1 year ago

@hgigas would you like to test #1912?

hgigas commented 1 year ago

It is difficult to test because it depends on the state of the network that I cannot control but it seems that the behavior has improved. I have tried it for a few minutes

hgigas commented 1 year ago

Thank you a lot :-)