-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #353 from timpikelmg/feature/209-add-sliding-invis…
…ibility-timeouts #209 - Add Support for Sliding Invisibility Timeouts
- Loading branch information
Showing
9 changed files
with
415 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// This file is part of Hangfire.PostgreSql. | ||
// Copyright © 2014 Frank Hommers <http://hmm.rs/Hangfire.PostgreSql>. | ||
// | ||
// Hangfire.PostgreSql is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as | ||
// published by the Free Software Foundation, either version 3 | ||
// of the License, or any later version. | ||
// | ||
// Hangfire.PostgreSql is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public | ||
// License along with Hangfire.PostgreSql. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
// This work is based on the work of Sergey Odinokov, author of | ||
// Hangfire. <http://hangfire.io/> | ||
// | ||
// Special thanks goes to him. | ||
|
||
using System; | ||
using System.Collections.Concurrent; | ||
using System.Threading; | ||
using Hangfire.Common; | ||
using Hangfire.Server; | ||
|
||
namespace Hangfire.PostgreSql | ||
{ | ||
#pragma warning disable CS0618 | ||
internal sealed class PostgreSqlHeartbeatProcess : IServerComponent, IBackgroundProcess | ||
#pragma warning restore CS0618 | ||
{ | ||
private readonly ConcurrentDictionary<PostgreSqlFetchedJob, object> _items = new(); | ||
|
||
public void Track(PostgreSqlFetchedJob item) | ||
{ | ||
_items.TryAdd(item, null); | ||
} | ||
|
||
public void Untrack(PostgreSqlFetchedJob item) | ||
{ | ||
_items.TryRemove(item, out var _); | ||
} | ||
|
||
public void Execute(CancellationToken cancellationToken) | ||
{ | ||
foreach (var item in _items) | ||
{ | ||
item.Key.ExecuteKeepAliveQueryIfRequired(); | ||
} | ||
|
||
cancellationToken.Wait(TimeSpan.FromSeconds(1)); | ||
} | ||
|
||
public void Execute(BackgroundProcessContext context) | ||
{ | ||
Execute(context.StoppingToken); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// This file is part of Hangfire. Copyright © 2022 Hangfire OÜ. | ||
// | ||
// Hangfire is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as | ||
// published by the Free Software Foundation, either version 3 | ||
// of the License, or any later version. | ||
// | ||
// Hangfire is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public | ||
// License along with Hangfire. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
// Borrowed from Hangfire | ||
|
||
using System; | ||
|
||
namespace Hangfire.PostgreSql.Utils | ||
{ | ||
internal static class ExceptionTypeHelper | ||
{ | ||
#if !NETSTANDARD1_3 | ||
private static readonly Type StackOverflowType = typeof(StackOverflowException); | ||
#endif | ||
private static readonly Type OutOfMemoryType = typeof(OutOfMemoryException); | ||
|
||
internal static bool IsCatchableExceptionType(this Exception e) | ||
{ | ||
var type = e.GetType(); | ||
return | ||
#if !NETSTANDARD1_3 | ||
type != StackOverflowType && | ||
#endif | ||
type != OutOfMemoryType; | ||
} | ||
} | ||
} |
Oops, something went wrong.