Skip to content

Commit

Permalink
Update to Hangfire 1.8.3 (#357)
Browse files Browse the repository at this point in the history
- Update to Hangfire.Core 1.8.3
- Update to MongoDB.Driver 2.20.0
- Fix using local server time for server heartbeats #356
  • Loading branch information
gottscj authored Jul 13, 2023
1 parent e97ce16 commit 9768d25
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 28 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@

## Change log

### v1.9.7 (2023-07-11)
- Update to Hangfire.Core 1.8.3
- Update to MongoDB.Driver 2.20.0
- Fix using local server time for server heartbeats #356

### v1.9.6 (2023-06-12)
- Update to Hangfire.Core 1.8.2
- Update to MongoDB.Driver 2.19.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Description />
<Version>1.9.6</Version>
<Version>1.9.7</Version>
<Description>MongoDB storage implementation for Hangfire (background job system for ASP.NET applications).</Description>
<Copyright>Copyright © 2014-2019 Sergey Zwezdin, Martin Lobger, Jonas Gottschau</Copyright>
<Authors>Sergey Zwezdin, Martin Lobger, Jonas Gottschau</Authors>
Expand All @@ -20,11 +20,11 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="bootstrap" Version="5.3.0" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.2" />
<PackageReference Include="Hangfire.Core" Version="1.8.2" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.3" />
<PackageReference Include="Hangfire.Core" Version="1.8.3" />
<PackageReference Include="jquery" Version="3.7.0" />
<PackageReference Include="Mongo2Go" Version="3.1.3" />
<PackageReference Include="MongoDB.Driver" Version="2.19.2" />
<PackageReference Include="MongoDB.Driver" Version="2.20.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Description />
<Version>1.9.6</Version>
<Version>1.9.7</Version>
<Description>MongoDB storage implementation for Hangfire (background job system for ASP.NET applications).</Description>
<Copyright>Copyright © 2014-2019 Sergey Zwezdin, Martin Lobger, Jonas Gottschau</Copyright>
<Authors>Sergey Zwezdin, Martin Lobger, Jonas Gottschau</Authors>
Expand All @@ -20,10 +20,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="bootstrap" Version="5.3.0" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.2" />
<PackageReference Include="Hangfire.Core" Version="1.8.2" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.3" />
<PackageReference Include="Hangfire.Core" Version="1.8.3" />
<PackageReference Include="jquery" Version="3.7.0" />
<PackageReference Include="MongoDB.Driver" Version="2.19.2" />
<PackageReference Include="MongoDB.Driver" Version="2.20.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<AssemblyName>Hangfire.Mongo.Sample.NETCore</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>Hangfire.Mongo.Sample.NETCore</PackageId>
<Version>1.9.6</Version>
<Version>1.9.7</Version>
<Description>MongoDB storage implementation for Hangfire (background job system for ASP.NET applications).</Description>
<Copyright>Copyright © 2014-2019 Sergey Zwezdin, Martin Lobger, Jonas Gottschau</Copyright>
<Authors>Sergey Zwezdin, Martin Lobger, Jonas Gottschau</Authors>
Expand All @@ -18,8 +18,8 @@
<ProjectReference Include="..\Hangfire.Mongo\Hangfire.Mongo.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Hangfire.Core" Version="1.8.2" />
<PackageReference Include="Hangfire.Core" Version="1.8.3" />
<PackageReference Include="Mongo2Go" Version="3.1.3" />
<PackageReference Include="MongoDB.Driver" Version="2.19.2" />
<PackageReference Include="MongoDB.Driver" Version="2.20.0" />
</ItemGroup>
</Project>
8 changes: 4 additions & 4 deletions src/Hangfire.Mongo.Tests/Hangfire.Mongo.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
<ProjectReference Include="../Hangfire.Mongo/Hangfire.Mongo.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="EphemeralMongo6" Version="1.1.0" />
<PackageReference Include="EphemeralMongo6" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit" Version="2.5.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.IO.Compression" />
Expand Down
8 changes: 4 additions & 4 deletions src/Hangfire.Mongo.Tests/MongoWriteOnlyTransactionFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ public void AddRangeToSet_AddToExistingSetData()

var testSet2 = GetTestSet(_database, "Set2");
Assert.NotNull(testSet2);
Assert.Equal(1, testSet2.Count);
Assert.Single( testSet2);
}

[Fact]
Expand All @@ -870,10 +870,10 @@ public void RemoveSet_ClearsTheSetData()
Commit(x => x.RemoveSet("Set1"));

var testSet1 = GetTestSet(_database, "Set1");
Assert.Equal(0, testSet1.Count);
Assert.Empty(testSet1);

var testSet2 = GetTestSet(_database, "Set2");
Assert.Equal(1, testSet2.Count);
Assert.Single(testSet2);
}

[Fact]
Expand All @@ -891,7 +891,7 @@ public void RemoveSet_ClearsTheSetData_WhenKeyContainsRegexSpecialChars()
Commit(x => x.RemoveSet(key));

var testSet1 = GetTestSet(_database, key);
Assert.Equal(0, testSet1.Count);
Assert.Empty(testSet1);
}

private static JobDto GetTestJob(HangfireDbContext database, string jobId)
Expand Down
15 changes: 8 additions & 7 deletions src/Hangfire.Mongo/Hangfire.Mongo.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<VersionPrefix>1.9.6</VersionPrefix>
<VersionPrefix>1.9.7</VersionPrefix>
<TargetFramework>netstandard2.0</TargetFramework>
<NoWarn>$(NoWarn);CS0618</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand All @@ -21,10 +21,11 @@
<owners>Sergey Zwezdin, Jonas Gottschau</owners>
<Description>MongoDB storage implementation for Hangfire (background job system for ASP.NET applications).</Description>
<PackageTags>Hangfire AspNet OWIN MongoDB CosmosDB Long-Running Background Fire-And-Forget Delayed Recurring Tasks Jobs Scheduler Threading Queues</PackageTags>
<PackageReleaseNotes>1.9.6
- Update to Hangfire.Core 1.8.2
- Update to MongoDB.Driver 2.19.2
</PackageReleaseNotes>
<PackageReleaseNotes>1.9.7
- Update to Hangfire.Core 1.8.3
- Update to MongoDB.Driver 2.20.0
- Fix using local server time for server heartbeats #356
</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<!--<PackageLicenseUrl>https://raw.githubusercontent.com/sergun/Hangfire.Mongo/master/LICENSE</PackageLicenseUrl>-->
<PackageProjectUrl>https://github.com/sergeyzwezdin/Hangfire.Mongo</PackageProjectUrl>
Expand All @@ -34,7 +35,7 @@
<None Include="../../README.md" pack="true" PackagePath="." />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Hangfire.Core" Version="1.8.2" />
<PackageReference Include="MongoDB.Driver" Version="2.19.2" />
<PackageReference Include="Hangfire.Core" Version="1.8.3" />
<PackageReference Include="MongoDB.Driver" Version="2.20.0" />
</ItemGroup>
</Project>
6 changes: 4 additions & 2 deletions src/Hangfire.Mongo/MongoConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,13 @@ public override void Heartbeat(string serverId)
throw new ArgumentNullException(nameof(serverId));
}

var now = GetUtcDateTime();
var updateResult = _dbContext.Server.UpdateMany(new BsonDocument("_id", serverId),
new BsonDocument
{
["$set"] = new BsonDocument
{
[nameof(ServerDto.LastHeartbeat)] = DateTime.UtcNow
[nameof(ServerDto.LastHeartbeat)] = now
}
});

Expand All @@ -257,13 +258,14 @@ public override int RemoveTimedOutServers(TimeSpan timeOut)
throw new ArgumentException("The `timeOut` value must be positive.", nameof(timeOut));
}

var now = GetUtcDateTime();
return (int)_dbContext
.Server
.DeleteMany(new BsonDocument
{
[nameof(ServerDto.LastHeartbeat)] = new BsonDocument
{
["$lt"] = DateTime.UtcNow.Add(timeOut.Negate())
["$lt"] = now.Add(timeOut.Negate())
}
})
.DeletedCount;
Expand Down

0 comments on commit 9768d25

Please sign in to comment.