-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[1.x] Ignore offline servers (continued) #355
Conversation
Thanks, @JustinElst and @leventdev! I changed the config to be in seconds rather than minutes to be consistent with other config values like thresholds. I also removed the additional 30-second grace period, as I don't think it made as much sense with the config in seconds. |
95fe9de
to
2bd9d5e
Compare
API: <!-- Ignore servers after 600 seconds: -->
<livewire:pulse.servers cols="full" ignore-after="600" />
<!-- Ignore servers after 2 hours: -->
<livewire:pulse.servers cols="full" ignore-after="2 hours" /> |
2bd9d5e
to
13720b1
Compare
13720b1
to
3e5b95a
Compare
/** | ||
* Determine if the system should be ignored. | ||
* | ||
* @param object{ timestamp: int, key: string, value: string } $system | ||
*/ | ||
protected function ignoreSystem(object $system): bool | ||
{ | ||
if ($this->ignoreAfter === null) { | ||
return false; | ||
} | ||
|
||
$ignoreAfter = is_numeric($this->ignoreAfter) | ||
? (int) $this->ignoreAfter | ||
: CarbonInterval::createFromDateString($this->ignoreAfter)->totalSeconds; | ||
|
||
return CarbonImmutable::createFromTimestamp($system->timestamp)->addSeconds($ignoreAfter)->isPast(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've called this ignoreSystem
to differentiate it from our shared ignore
method on the Ignores
trait.
use InteractsWithTime; | ||
|
||
public int|string|null $ignoreAfter = null; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Livewire does not support DateInterval
as a prop value, so I've excluded it from the type here.
Due to the way Livewire serializes values, we also cannot use now()->addSeconds(60)
in the prop value.
Docs: laravel/docs#9622 |
This pull request continues the work in [1.x] Ignore offline servers.
Thanks leventdev for starting this.
With this pull-request I wanted to complete the request made by in jessarcher in her comment.