code cleanup, migrated to dotnet core, builds for dnx46, dnx451, net45, net451, net452, net46, net461, netcoreapp1.0, netstandard1.6

This commit is contained in:
Austin Winstanley
2016-09-12 20:03:18 -05:00
parent 343603fd7c
commit c65b8b1314
45 changed files with 11709 additions and 841 deletions
+19 -13
View File
@@ -1,33 +1,39 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hangfire.Raven", "src\Hangfire.Raven\Hangfire.Raven.csproj", "{A523C0E3-097D-4869-977F-15A717EA3E83}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleSample", "src\ConsoleSample\ConsoleSample.csproj", "{C02BB718-2AE4-434C-8668-C894FF663FCE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_", "_", "{8CF2D2F6-BEFE-47FE-B141-0017FC6F97D8}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Hangfire.Raven", "src\Hangfire.Raven\Hangfire.Raven.xproj", "{BA18F6BF-5613-4B9D-A57A-C05C51148EC5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{EF9BFE2C-0386-4EC4-83EC-D7E315F56735}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ConsoleSample", "src\ConsoleSample\ConsoleSample.xproj", "{3955F2F1-99AF-4CC0-88F5-C9B69757A1B2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A523C0E3-097D-4869-977F-15A717EA3E83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A523C0E3-097D-4869-977F-15A717EA3E83}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A523C0E3-097D-4869-977F-15A717EA3E83}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A523C0E3-097D-4869-977F-15A717EA3E83}.Release|Any CPU.Build.0 = Release|Any CPU
{C02BB718-2AE4-434C-8668-C894FF663FCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C02BB718-2AE4-434C-8668-C894FF663FCE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C02BB718-2AE4-434C-8668-C894FF663FCE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C02BB718-2AE4-434C-8668-C894FF663FCE}.Release|Any CPU.Build.0 = Release|Any CPU
{BA18F6BF-5613-4B9D-A57A-C05C51148EC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BA18F6BF-5613-4B9D-A57A-C05C51148EC5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BA18F6BF-5613-4B9D-A57A-C05C51148EC5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BA18F6BF-5613-4B9D-A57A-C05C51148EC5}.Release|Any CPU.Build.0 = Release|Any CPU
{3955F2F1-99AF-4CC0-88F5-C9B69757A1B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3955F2F1-99AF-4CC0-88F5-C9B69757A1B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3955F2F1-99AF-4CC0-88F5-C9B69757A1B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3955F2F1-99AF-4CC0-88F5-C9B69757A1B2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{BA18F6BF-5613-4B9D-A57A-C05C51148EC5} = {EF9BFE2C-0386-4EC4-83EC-D7E315F56735}
{3955F2F1-99AF-4CC0-88F5-C9B69757A1B2} = {EF9BFE2C-0386-4EC4-83EC-D7E315F56735}
EndGlobalSection
EndGlobal
-88
View File
@@ -1,88 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C02BB718-2AE4-434C-8668-C894FF663FCE}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ConsoleSample</RootNamespace>
<AssemblyName>ConsoleSample</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>89909a41</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="Hangfire.Core, Version=1.6.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Hangfire.Core.1.6.2\lib\net45\Hangfire.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
<HintPath>..\..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="GenericServices.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Hangfire.Raven\Hangfire.Raven.csproj">
<Project>{a523c0e3-097d-4869-977f-15a717ea3e83}</Project>
<Name>Hangfire.Raven</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
+21
View File
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>3955f2f1-99af-4cc0-88f5-c9b69757a1b2</ProjectGuid>
<RootNamespace>ConsoleSample</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
+21 -17
View File
@@ -1,6 +1,6 @@
using System;
using Hangfire;
using HangFire.Raven.Storage;
using Hangfire.Raven.Storage;
namespace ConsoleSample
{
@@ -10,32 +10,36 @@ namespace ConsoleSample
public static void Main()
{
// you can use Raven Storage and specify the connection string and database name
GlobalConfiguration.Configuration
.UseColouredConsoleLogProvider()
.UseRavenStorage("http://localhost:8080", "hangfire", "apikeytest");
try {
// you can use Raven Storage and specify the connection string and database name
GlobalConfiguration.Configuration
.UseColouredConsoleLogProvider()
.UseRavenStorage("http://localhost:9090", "Hangfire");
// you can use Raven Embedded Storage which runs in memory!
//GlobalConfiguration.Configuration
// .UseColouredConsoleLogProvider()
// .UseEmbeddedRavenStorage();
// you can use Raven Embedded Storage which runs in memory!
//GlobalConfiguration.Configuration
// .UseColouredConsoleLogProvider()
// .UseEmbeddedRavenStorage();
//you have to create an instance of background job server at least once for background jobs to run
var client = new BackgroundJobServer();
//you have to create an instance of background job server at least once for background jobs to run
var client = new BackgroundJobServer();
//BackgroundJob.Enqueue(() => Console.WriteLine("Background Job: Hello, world!"));
BackgroundJob.Enqueue(() => test());
//RecurringJob.AddOrUpdate(() => test(), Cron.Minutely);
//BackgroundJob.Enqueue(() => Console.WriteLine("Background Job: Hello, world!"));
//BackgroundJob.Enqueue(() => test());
RecurringJob.AddOrUpdate(() => test(), Cron.Minutely);
Console.WriteLine("Press Enter to exit...");
Console.ReadLine();
Console.WriteLine("Press Enter to exit...");
Console.ReadLine();
} catch (Exception ex) {
throw ex;
}
}
[AutomaticRetry(Attempts = 2, LogEvents = true, OnAttemptsExceeded = AttemptsExceededAction.Delete)]
public static void test()
{
Console.WriteLine($"{x++} Cron Job: Hello, world!");
throw new ArgumentException("fail");
//throw new ArgumentException("fail");
}
}
}
+6 -22
View File
@@ -1,35 +1,19 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Hangfire.Hosts.Console")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Hangfire.Hosts.Console")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyProduct("ConsoleSample")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("3c3451fc-663d-4e33-ab72-d92beae38a97")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: Guid("3955f2f1-99af-4cc0-88f5-c9b69757a1b2")]
-6
View File
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Hangfire.Core" version="1.6.2" targetFramework="net45" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
</packages>
+55
View File
@@ -0,0 +1,55 @@
{
"title": "Hangfire.Raven ConsoleSample",
"version": "2.0.0",
"description": "RavenDB job storage for Hangfire",
"copyright": "Copyright @ 2016 Cady, LLC",
"authors": [
"Cady <contact@cady.io>"
],
"buildOptions": {
"allowUnsafe": true,
"debugType": "portable",
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"packOptions": {
"tags": [
"Hangfire",
"AspNet",
"MVC",
"OWIN",
"RavenDB",
"Long-Running",
"Background",
"Fire-And-Forget",
"Delayed",
"Recurring",
"Tasks",
"Jobs",
"Scheduler",
"Threading",
"Queues"
],
"iconUrl": "https://avatars2.githubusercontent.com/u/7880472?v=3&s=200",
"projectUrl": "https://github.com/cady-io/hangfire-ravendb",
"licenseUrl": "http://www.gnu.org/licenses/lgpl-3.0.html",
"owners": [
"Cady <contact@cady.io>"
],
"repository": {
"type": "git",
"url": "https://github.com/cady-io/hangfire-ravendb"
},
"summary": "RavenDB job storage for Hangfire"
},
"runtimes": {
"win10-x64": {}
},
"frameworks": {
"net452": {}
},
"dependencies": {
"Hangfire.Raven": "2.0.0",
"System.ComponentModel.Primitives": "4.1.0"
}
}
+423
View File
@@ -0,0 +1,423 @@
{
"locked": false,
"version": 2,
"targets": {
".NETFramework,Version=v4.5.2": {
"Hangfire.Core/1.6.4": {
"type": "package",
"dependencies": {
"Newtonsoft.Json": "5.0.0",
"Owin": "1.0.0"
},
"compile": {
"lib/net45/Hangfire.Core.dll": {}
},
"runtime": {
"lib/net45/Hangfire.Core.dll": {}
}
},
"Microsoft.DotNet.InternalAbstractions/1.0.0": {
"type": "package",
"compile": {
"lib/net451/Microsoft.DotNet.InternalAbstractions.dll": {}
},
"runtime": {
"lib/net451/Microsoft.DotNet.InternalAbstractions.dll": {}
}
},
"Microsoft.Extensions.DependencyModel/1.0.0": {
"type": "package",
"dependencies": {
"Microsoft.DotNet.InternalAbstractions": "1.0.0",
"Newtonsoft.Json": "9.0.1"
},
"compile": {
"lib/net451/Microsoft.Extensions.DependencyModel.dll": {}
},
"runtime": {
"lib/net451/Microsoft.Extensions.DependencyModel.dll": {}
}
},
"Newtonsoft.Json/9.0.1": {
"type": "package",
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"Owin/1.0.0": {
"type": "package",
"compile": {
"lib/net40/Owin.dll": {}
},
"runtime": {
"lib/net40/Owin.dll": {}
}
},
"RavenDB.Client/3.5.0-rc-35169": {
"type": "package",
"frameworkAssemblies": [
"System.ComponentModel.Composition"
],
"compile": {
"lib/net45/Raven.Abstractions.dll": {},
"lib/net45/Raven.Client.Lightweight.dll": {}
},
"runtime": {
"lib/net45/Raven.Abstractions.dll": {},
"lib/net45/Raven.Client.Lightweight.dll": {}
}
},
"System.ComponentModel.Primitives/4.1.0": {
"type": "package",
"frameworkAssemblies": [
"System",
"mscorlib"
],
"compile": {
"ref/net45/System.ComponentModel.Primitives.dll": {}
},
"runtime": {
"lib/net45/System.ComponentModel.Primitives.dll": {}
}
},
"System.Data.Common/4.1.0": {
"type": "package",
"frameworkAssemblies": [
"System.Data",
"mscorlib"
],
"compile": {
"ref/net451/System.Data.Common.dll": {}
},
"runtime": {
"lib/net451/System.Data.Common.dll": {}
}
},
"Hangfire.Raven/2.0.0": {
"type": "project",
"framework": ".NETFramework,Version=v4.5.2",
"dependencies": {
"Hangfire.Core": "1.6.4",
"Microsoft.Extensions.DependencyModel": "1.0.0",
"Newtonsoft.Json": "9.0.1",
"RavenDB.Client": "3.5.0-rc-35169",
"System.Data.Common": "4.1.0"
},
"compile": {
"net452/Hangfire.Raven.dll": {}
},
"runtime": {
"net452/Hangfire.Raven.dll": {}
}
}
},
".NETFramework,Version=v4.5.2/win10-x64": {
"Hangfire.Core/1.6.4": {
"type": "package",
"dependencies": {
"Newtonsoft.Json": "5.0.0",
"Owin": "1.0.0"
},
"compile": {
"lib/net45/Hangfire.Core.dll": {}
},
"runtime": {
"lib/net45/Hangfire.Core.dll": {}
}
},
"Microsoft.DotNet.InternalAbstractions/1.0.0": {
"type": "package",
"compile": {
"lib/net451/Microsoft.DotNet.InternalAbstractions.dll": {}
},
"runtime": {
"lib/net451/Microsoft.DotNet.InternalAbstractions.dll": {}
}
},
"Microsoft.Extensions.DependencyModel/1.0.0": {
"type": "package",
"dependencies": {
"Microsoft.DotNet.InternalAbstractions": "1.0.0",
"Newtonsoft.Json": "9.0.1"
},
"compile": {
"lib/net451/Microsoft.Extensions.DependencyModel.dll": {}
},
"runtime": {
"lib/net451/Microsoft.Extensions.DependencyModel.dll": {}
}
},
"Newtonsoft.Json/9.0.1": {
"type": "package",
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"Owin/1.0.0": {
"type": "package",
"compile": {
"lib/net40/Owin.dll": {}
},
"runtime": {
"lib/net40/Owin.dll": {}
}
},
"RavenDB.Client/3.5.0-rc-35169": {
"type": "package",
"frameworkAssemblies": [
"System.ComponentModel.Composition"
],
"compile": {
"lib/net45/Raven.Abstractions.dll": {},
"lib/net45/Raven.Client.Lightweight.dll": {}
},
"runtime": {
"lib/net45/Raven.Abstractions.dll": {},
"lib/net45/Raven.Client.Lightweight.dll": {}
}
},
"System.ComponentModel.Primitives/4.1.0": {
"type": "package",
"frameworkAssemblies": [
"System",
"mscorlib"
],
"compile": {
"ref/net45/System.ComponentModel.Primitives.dll": {}
},
"runtime": {
"lib/net45/System.ComponentModel.Primitives.dll": {}
}
},
"System.Data.Common/4.1.0": {
"type": "package",
"frameworkAssemblies": [
"System.Data",
"mscorlib"
],
"compile": {
"ref/net451/System.Data.Common.dll": {}
},
"runtime": {
"lib/net451/System.Data.Common.dll": {}
}
},
"Hangfire.Raven/2.0.0": {
"type": "project",
"framework": ".NETFramework,Version=v4.5.2",
"dependencies": {
"Hangfire.Core": "1.6.4",
"Microsoft.Extensions.DependencyModel": "1.0.0",
"Newtonsoft.Json": "9.0.1",
"RavenDB.Client": "3.5.0-rc-35169",
"System.Data.Common": "4.1.0"
},
"compile": {
"net452/Hangfire.Raven.dll": {}
},
"runtime": {
"net452/Hangfire.Raven.dll": {}
}
}
}
},
"libraries": {
"Hangfire.Core/1.6.4": {
"sha512": "QM+WNZ/B7t3BzOBumLb2NU9aoh76hb/Jdt9pV95+HSHZbPsvms7Jk9kUC9PLopdh9gpUL7L6dmnhEnpQJBBs+Q==",
"type": "package",
"path": "Hangfire.Core/1.6.4",
"files": [
"Hangfire.Core.1.6.4.nupkg.sha512",
"Hangfire.Core.nuspec",
"lib/net45/Hangfire.Core.dll",
"lib/net45/Hangfire.Core.xml",
"lib/netstandard1.3/Hangfire.Core.dll",
"lib/netstandard1.3/Hangfire.Core.xml"
]
},
"Microsoft.DotNet.InternalAbstractions/1.0.0": {
"sha512": "AAguUq7YyKk3yDWPoWA8DrLZvURxB/LrDdTn1h5lmPeznkFUpfC3p459w5mQYQE0qpquf/CkSQZ0etiV5vRHFA==",
"type": "package",
"path": "Microsoft.DotNet.InternalAbstractions/1.0.0",
"files": [
"Microsoft.DotNet.InternalAbstractions.1.0.0.nupkg.sha512",
"Microsoft.DotNet.InternalAbstractions.nuspec",
"lib/net451/Microsoft.DotNet.InternalAbstractions.dll",
"lib/netstandard1.3/Microsoft.DotNet.InternalAbstractions.dll"
]
},
"Microsoft.Extensions.DependencyModel/1.0.0": {
"sha512": "n55Y2T4qMgCNMrJaqAN+nlG2EH4XL+e9uxIg4vdFsQeF+L8UKxRdD3C35Bt+xk3vO3Zwp3g+6KFq2VPH2COSmg==",
"type": "package",
"path": "Microsoft.Extensions.DependencyModel/1.0.0",
"files": [
"Microsoft.Extensions.DependencyModel.1.0.0.nupkg.sha512",
"Microsoft.Extensions.DependencyModel.nuspec",
"lib/net451/Microsoft.Extensions.DependencyModel.dll",
"lib/netstandard1.6/Microsoft.Extensions.DependencyModel.dll"
]
},
"Newtonsoft.Json/9.0.1": {
"sha512": "U82mHQSKaIk+lpSVCbWYKNavmNH1i5xrExDEquU1i6I5pV6UMOqRnJRSlKO3cMPfcpp0RgDY+8jUXHdQ4IfXvw==",
"type": "package",
"path": "Newtonsoft.Json/9.0.1",
"files": [
"Newtonsoft.Json.9.0.1.nupkg.sha512",
"Newtonsoft.Json.nuspec",
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netstandard1.0/Newtonsoft.Json.dll",
"lib/netstandard1.0/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml",
"tools/install.ps1"
]
},
"Owin/1.0.0": {
"sha512": "OseTFniKmyp76mEzOBwIKGBRS5eMoYNkMKaMXOpxx9jv88+b6mh1rSaw43vjBOItNhaLFG3d0a20PfHyibH5sw==",
"type": "package",
"path": "Owin/1.0.0",
"files": [
"Owin.1.0.0.nupkg.sha512",
"Owin.nuspec",
"lib/net40/Owin.dll"
]
},
"RavenDB.Client/3.5.0-rc-35169": {
"sha512": "xP23wh0U4h8/MmuiFEYhCB+y9AA87DvsJOifmfynPrYYV9jOjFLLWa55iOmy/RNWakDso7td0m3AcfGygULXQw==",
"type": "package",
"path": "RavenDB.Client/3.5.0-rc-35169",
"files": [
"RavenDB.Client.3.5.0-rc-35169.nupkg.sha512",
"RavenDB.Client.nuspec",
"lib/net45/Raven.Abstractions.dll",
"lib/net45/Raven.Abstractions.pdb",
"lib/net45/Raven.Abstractions.xml",
"lib/net45/Raven.Client.Lightweight.XML",
"lib/net45/Raven.Client.Lightweight.dll",
"lib/net45/Raven.Client.Lightweight.pdb",
"lib/netstandard1.6/Raven.Abstractions.dll",
"lib/netstandard1.6/Raven.Abstractions.pdb",
"lib/netstandard1.6/Raven.Client.Lightweight.deps.json",
"lib/netstandard1.6/Raven.Client.Lightweight.dll",
"lib/netstandard1.6/Raven.Client.Lightweight.pdb",
"lib/netstandard1.6/Sparrow.dll",
"lib/netstandard1.6/Sparrow.pdb"
]
},
"System.ComponentModel.Primitives/4.1.0": {
"sha512": "sc/7eVCdxPrp3ljpgTKVaQGUXiW05phNWvtv/m2kocXqrUQvTVWKou1Edas2aDjTThLPZOxPYIGNb/HN0QjURg==",
"type": "package",
"path": "System.ComponentModel.Primitives/4.1.0",
"files": [
"System.ComponentModel.Primitives.4.1.0.nupkg.sha512",
"System.ComponentModel.Primitives.nuspec",
"ThirdPartyNotices.txt",
"dotnet_library_license.txt",
"lib/MonoAndroid10/_._",
"lib/MonoTouch10/_._",
"lib/net45/System.ComponentModel.Primitives.dll",
"lib/netstandard1.0/System.ComponentModel.Primitives.dll",
"lib/xamarinios10/_._",
"lib/xamarinmac20/_._",
"lib/xamarintvos10/_._",
"lib/xamarinwatchos10/_._",
"ref/MonoAndroid10/_._",
"ref/MonoTouch10/_._",
"ref/net45/System.ComponentModel.Primitives.dll",
"ref/netstandard1.0/System.ComponentModel.Primitives.dll",
"ref/netstandard1.0/System.ComponentModel.Primitives.xml",
"ref/netstandard1.0/de/System.ComponentModel.Primitives.xml",
"ref/netstandard1.0/es/System.ComponentModel.Primitives.xml",
"ref/netstandard1.0/fr/System.ComponentModel.Primitives.xml",
"ref/netstandard1.0/it/System.ComponentModel.Primitives.xml",
"ref/netstandard1.0/ja/System.ComponentModel.Primitives.xml",
"ref/netstandard1.0/ko/System.ComponentModel.Primitives.xml",
"ref/netstandard1.0/ru/System.ComponentModel.Primitives.xml",
"ref/netstandard1.0/zh-hans/System.ComponentModel.Primitives.xml",
"ref/netstandard1.0/zh-hant/System.ComponentModel.Primitives.xml",
"ref/xamarinios10/_._",
"ref/xamarinmac20/_._",
"ref/xamarintvos10/_._",
"ref/xamarinwatchos10/_._"
]
},
"System.Data.Common/4.1.0": {
"sha512": "epU8jeTe7aE7RqGHq9rZ8b0Q4Ah7DgubzHQblgZMSqgW1saW868WmooSyC5ywf8upLBkcVLDu93W9GPWUYsU2Q==",
"type": "package",
"path": "System.Data.Common/4.1.0",
"files": [
"System.Data.Common.4.1.0.nupkg.sha512",
"System.Data.Common.nuspec",
"ThirdPartyNotices.txt",
"dotnet_library_license.txt",
"lib/MonoAndroid10/_._",
"lib/MonoTouch10/_._",
"lib/net451/System.Data.Common.dll",
"lib/netstandard1.2/System.Data.Common.dll",
"lib/portable-net451+win8+wp8+wpa81/System.Data.Common.dll",
"lib/xamarinios10/_._",
"lib/xamarinmac20/_._",
"lib/xamarintvos10/_._",
"lib/xamarinwatchos10/_._",
"ref/MonoAndroid10/_._",
"ref/MonoTouch10/_._",
"ref/net451/System.Data.Common.dll",
"ref/netstandard1.2/System.Data.Common.dll",
"ref/netstandard1.2/System.Data.Common.xml",
"ref/netstandard1.2/de/System.Data.Common.xml",
"ref/netstandard1.2/es/System.Data.Common.xml",
"ref/netstandard1.2/fr/System.Data.Common.xml",
"ref/netstandard1.2/it/System.Data.Common.xml",
"ref/netstandard1.2/ja/System.Data.Common.xml",
"ref/netstandard1.2/ko/System.Data.Common.xml",
"ref/netstandard1.2/ru/System.Data.Common.xml",
"ref/netstandard1.2/zh-hans/System.Data.Common.xml",
"ref/netstandard1.2/zh-hant/System.Data.Common.xml",
"ref/portable-net451+win8+wp8+wpa81/System.Data.Common.dll",
"ref/portable-net451+win8+wp8+wpa81/System.Data.Common.xml",
"ref/portable-net451+win8+wp8+wpa81/de/System.Data.Common.xml",
"ref/portable-net451+win8+wp8+wpa81/es/System.Data.Common.xml",
"ref/portable-net451+win8+wp8+wpa81/fr/System.Data.Common.xml",
"ref/portable-net451+win8+wp8+wpa81/it/System.Data.Common.xml",
"ref/portable-net451+win8+wp8+wpa81/ja/System.Data.Common.xml",
"ref/portable-net451+win8+wp8+wpa81/ko/System.Data.Common.xml",
"ref/portable-net451+win8+wp8+wpa81/ru/System.Data.Common.xml",
"ref/portable-net451+win8+wp8+wpa81/zh-hans/System.Data.Common.xml",
"ref/portable-net451+win8+wp8+wpa81/zh-hant/System.Data.Common.xml",
"ref/xamarinios10/_._",
"ref/xamarinmac20/_._",
"ref/xamarintvos10/_._",
"ref/xamarinwatchos10/_._"
]
},
"Hangfire.Raven/2.0.0": {
"type": "project",
"path": "../Hangfire.Raven/project.json",
"msbuildProject": "../Hangfire.Raven/Hangfire.Raven.xproj"
}
},
"projectFileDependencyGroups": {
"": [
"Hangfire.Raven >= 2.0.0",
"System.ComponentModel.Primitives >= 4.1.0"
],
".NETFramework,Version=v4.5.2": []
},
"tools": {},
"projectFileToolGroups": {}
}
+19 -2
View File
@@ -2,8 +2,9 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
#if !NET45
using Microsoft.Extensions.DependencyModel;
#endif
namespace Hangfire.Raven
{
@@ -18,7 +19,14 @@ namespace Hangfire.Raven
/// <returns></returns>
public static IEnumerable<Assembly> Get()
{
#if NET45
return AppDomain.CurrentDomain.GetAssemblies().Where(a => a != null);
#else
return (from compilationLibrary in DependencyContext.Default.CompileLibraries
where compilationLibrary.Name.Contains(typeof(Assemblies).Namespace)
select Assembly.Load(new AssemblyName(compilationLibrary.Name)))
.ToList();
#endif
}
/// <summary>
@@ -33,5 +41,14 @@ namespace Hangfire.Raven
where t.FullName == type //&& !t.IsAbstract && t.IsClass
select t).FirstOrDefault();
}
public static string GetAssemblyName(MemberInfo value)
{
#if NET45
return value.DeclaringType.Assembly.GetName().Name;
#else
return value.DeclaringType.GetTypeInfo().Assembly.GetName().Name;
#endif
}
}
}
@@ -1,12 +1,10 @@
using System.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading;
using Hangfire.Annotations;
using Hangfire.Raven.Entities;
using Hangfire.Raven.Storage;
using System;
using Raven.Json.Linq;
namespace Hangfire.Raven.DistributedLocks
{
@@ -36,7 +34,7 @@ namespace Hangfire.Raven.DistributedLocks
_resource = resource;
// -- Skip some locks
if(!_skipLocks.Any(a => _resource.StartsWith(a)))
if (!_skipLocks.Any(a => _resource.StartsWith(a)))
Lock();
}
@@ -47,10 +45,8 @@ namespace Hangfire.Raven.DistributedLocks
private void Lock()
{
using (var session = _storage.Repository.OpenSession())
{
_distributedLock = new DistributedLock()
{
using (var session = _storage.Repository.OpenSession()) {
_distributedLock = new DistributedLock() {
ClientId = _storage.Options.ClientId,
Resource = _resource
};
@@ -58,14 +54,11 @@ namespace Hangfire.Raven.DistributedLocks
session.Store(_distributedLock);
session.Advanced.AddExpire(_distributedLock, DateTime.UtcNow + _timeout);
try
{
try {
// Blocking session!
session.Advanced.UseOptimisticConcurrency = true;
session.SaveChanges();
}
catch (Exception e)
{
} catch (Exception e) {
_distributedLock = null;
throw new RavenDistributedLockException("Lock already given.", e);
}
@@ -76,21 +69,15 @@ namespace Hangfire.Raven.DistributedLocks
private void Release()
{
lock (_lock)
{
if (_distributedLock != null)
{
lock (_lock) {
if (_distributedLock != null) {
// Non blocking session!
try
{
using (var session = _storage.Repository.OpenSession())
{
try {
using (var session = _storage.Repository.OpenSession()) {
session.Delete(_distributedLock.Id);
session.SaveChanges();
}
}
catch
{
} catch {
Console.WriteLine("Unable to delete lock: {0}", _resource);
}
@@ -98,8 +85,7 @@ namespace Hangfire.Raven.DistributedLocks
}
// Stop timer
if (_heartbeatTimer != null)
{
if (_heartbeatTimer != null) {
_heartbeatTimer.Dispose();
_heartbeatTimer = null;
}
@@ -111,21 +97,16 @@ namespace Hangfire.Raven.DistributedLocks
Console.WriteLine(".Starting heartbeat for resource: {0}", _resource);
TimeSpan timerInterval = TimeSpan.FromMilliseconds(_timeout.TotalMilliseconds / 3);
_heartbeatTimer = new Timer(state =>
{
try
{
_heartbeatTimer = new Timer(state => {
try {
Console.WriteLine("..Heartbeat for resource {0}", _resource);
using (var session = _storage.Repository.OpenSession())
{
using (var session = _storage.Repository.OpenSession()) {
var distributedLock = session.Load<DistributedLock>(_distributedLock.Id);
session.Advanced.AddExpire(distributedLock, DateTime.UtcNow + _timeout);
session.SaveChanges();
}
}
catch (Exception ex)
{
} catch (Exception ex) {
Console.WriteLine("...Unable to update heartbeat on the resource '{0}'", ex, _resource);
Release();
}
+1 -7
View File
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Hangfire.Raven.Entities
namespace Hangfire.Raven.Entities
{
public class Counter
{
@@ -1,20 +1,16 @@
using System;
namespace Hangfire.Raven.Entities
namespace Hangfire.Raven.Entities
{
public class DistributedLock
{
public string Id
{
get
{
public string Id {
get {
return string.Format("DistributedLocks/{0}", Resource);
}
set
{
set {
}
}
public string Resource { get; set; }
public string ClientId { get; set; }
}
@@ -1,6 +1,6 @@
using Hangfire.Annotations;
using Hangfire.Storage;
using Hangfire.Raven.Storage;
using Hangfire.Storage;
namespace Hangfire.Raven.Entities
{
@@ -32,12 +32,10 @@ namespace Hangfire.Raven.Entities
public void RemoveFromQueue()
{
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var job = repository.Load<JobQueue>(Id);
if (job != null)
{
if (job != null) {
repository.Delete(job);
}
repository.SaveChanges();
@@ -48,8 +46,7 @@ namespace Hangfire.Raven.Entities
public void Requeue()
{
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var job = repository.Load<JobQueue>(Id);
job.FetchedAt = null;
+2 -3
View File
@@ -1,9 +1,8 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
namespace Hangfire.Raven.Entities
{
public class RavenHash
public class RavenHash
{
public RavenHash()
{
+4 -4
View File
@@ -1,10 +1,10 @@
using Hangfire.Common;
using Hangfire.Storage;
using System;
using System.Collections.Generic;
using Hangfire.Storage.Monitoring;
using System.Reflection;
using System.Linq;
using System.Reflection;
using Hangfire.Common;
using Hangfire.Storage;
using Hangfire.Storage.Monitoring;
namespace Hangfire.Raven.Entities
{
+1 -3
View File
@@ -1,6 +1,4 @@
using System;
namespace Hangfire.Raven.Entities
namespace Hangfire.Raven.Entities
{
public class RavenList
{
+1 -2
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
namespace Hangfire.Raven.Entities
{
@@ -1,2 +0,0 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=DataTypes/@EntryIndexedValue">False</s:Boolean></wpf:ResourceDictionary>
-132
View File
@@ -1,132 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A523C0E3-097D-4869-977F-15A717EA3E83}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Hangfire.Raven</RootNamespace>
<AssemblyName>Hangfire.Raven</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>5f064ca7</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Hangfire.Raven.xml</DocumentationFile>
<Prefer32Bit>false</Prefer32Bit>
<NoWarn>1591</NoWarn>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Hangfire.Raven.xml</DocumentationFile>
<Prefer32Bit>false</Prefer32Bit>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="Hangfire.Core, Version=1.6.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Hangfire.Core.1.6.3\lib\net45\Hangfire.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Raven.Abstractions, Version=3.0.0.0, Culture=neutral, PublicKeyToken=37f41c7f99471593, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\RavenDB.Client.3.0.30115\lib\net45\Raven.Abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Raven.Client.Lightweight, Version=3.0.0.0, Culture=neutral, PublicKeyToken=37f41c7f99471593, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\RavenDB.Client.3.0.30115\lib\net45\Raven.Client.Lightweight.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Transactions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Assemblies.cs" />
<Compile Include="DistributedLocks\RavenDistributedLock.cs" />
<Compile Include="DistributedLocks\RavenDistributedLockException.cs" />
<Compile Include="Entities\AggregatedCounter.cs" />
<Compile Include="Entities\Counter.cs" />
<Compile Include="Entities\DistributedLocks.cs" />
<Compile Include="Entities\EnqueuedAndFetchedCount.cs" />
<Compile Include="Entities\JobQueue.cs" />
<Compile Include="Entities\RavenHash.cs" />
<Compile Include="Entities\RavenList.cs" />
<Compile Include="Entities\RavenSet.cs" />
<Compile Include="Entities\RavenJob.cs" />
<Compile Include="Entities\RavenServer.cs" />
<Compile Include="Extensions\DatabaseExtensions.cs" />
<Compile Include="Indexes\Hangfire_RavenJobs.cs" />
<Compile Include="Indexes\Raven_DocumentsByEntityName.cs" />
<Compile Include="JobQueues\IPersistentJobQueue.cs" />
<Compile Include="JobQueues\IPersistentJobQueueMonitoringApi.cs" />
<Compile Include="JobQueues\IPersistentJobQueueProvider.cs" />
<Compile Include="Listeners\TakeNewestConflictResolutionListener.cs" />
<Compile Include="JobQueues\PersistentJobQueueProviderCollection.cs" />
<Compile Include="JobQueues\RavenJobQueue.cs" />
<Compile Include="Entities\RavenFetchedJob.cs" />
<Compile Include="ObjectExtensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="JobQueues\RavenJobQueueProvider.cs" />
<Compile Include="RavenJsonConverters.cs" />
<Compile Include="Repository.cs" />
<Compile Include="JobQueues\RavenJobQueueMonitoringApi.cs" />
<Compile Include="Storage\RavenStorageMonitoringApi.cs" />
<Compile Include="Storage\RavenStorage.cs" />
<Compile Include="Storage\RavenStorageExtensions.cs" />
<Compile Include="Storage\RavenStorageOptions.cs" />
<Compile Include="RavenConnection.cs" />
<Compile Include="RavenWriteOnlyTransaction.cs" />
<Compile Include="StateHandlers\DeletedStateHandler.cs" />
<Compile Include="StateHandlers\FailedStateHandler.cs" />
<Compile Include="StateHandlers\ProcessingStateHandler.cs" />
<Compile Include="StateHandlers\SucceededStateHandler.cs" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Hangfire.Raven.nuspec" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
-29
View File
@@ -1,29 +0,0 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<description>$description$</description>
<authors>Axial Commerce</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<copyright>Copyright © Axial Commerce</copyright>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
<projectUrl>https://github.com/axial/hangfire-ravendb</projectUrl>
<dependencies>
<group targetFramework="net45">
<dependency id="Dewey.Net" version="3.3.0.0" />
<dependency id="Hangfire" version="1.5.3" />
<dependency id="Hangfire.Core" version="1.5.3" />
<dependency id="Hangfire.SqlServer" version="1.5.3" />
<dependency id="Microsoft.Owin" version="3.0.1" />
<dependency id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" />
<dependency id="Newtonsoft.Json" version="8.0.2" />
<dependency id="Owin" version="1.0" />
<dependency id="RavenDB.Client" version="3.0.30037" />
<dependency id="RavenDB.Database" version="3.0.30037" />
<dependency id="RavenDB.Embedded" version="3.0.30037" />
</group>
</dependencies>
</metadata>
</package>
+19
View File
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>ba18f6bf-5613-4b9d-a57a-c05c51148ec5</ProjectGuid>
<RootNamespace>Hangfire.Raven</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
@@ -1,10 +1,7 @@
using Hangfire.Raven.Entities;
using Raven.Client.Indexes;
using System;
using System.Collections.Generic;
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Hangfire.Raven.Entities;
using Raven.Client.Indexes;
namespace Hangfire.Raven.Indexes
{
@@ -21,11 +18,10 @@ namespace Hangfire.Raven.Indexes
public Hangfire_RavenJobs()
{
Map = results => from result in results
select new Mapping
{
StateName = result.StateData.Name,
CreatedAt = result.CreatedAt
};
select new Mapping {
StateName = result.StateData.Name,
CreatedAt = result.CreatedAt
};
this.Analyze("StateName", "WhitespaceAnalyzer");
}
}
@@ -1,10 +1,6 @@
using Raven.Abstractions.Indexing;
using System;
using Raven.Abstractions.Indexing;
using Raven.Client.Indexes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Hangfire.Raven.Indexes
{
@@ -7,7 +7,7 @@ namespace Hangfire.Raven.JobQueues
public class PersistentJobQueueProviderCollection : IEnumerable<IPersistentJobQueueProvider>
{
private readonly List<IPersistentJobQueueProvider> _providers
= new List<IPersistentJobQueueProvider>();
= new List<IPersistentJobQueueProvider>();
private readonly Dictionary<string, IPersistentJobQueueProvider> _providersByQueue
= new Dictionary<string, IPersistentJobQueueProvider>(StringComparer.OrdinalIgnoreCase);
@@ -29,15 +29,14 @@ namespace Hangfire.Raven.JobQueues
_providers.Add(provider);
foreach (var queue in queues)
{
foreach (var queue in queues) {
_providersByQueue.Add(queue, provider);
}
}
public IPersistentJobQueueProvider GetProvider(string queue)
{
return _providersByQueue.ContainsKey(queue)
return _providersByQueue.ContainsKey(queue)
? _providersByQueue[queue]
: _defaultProvider;
}
+19 -37
View File
@@ -1,18 +1,16 @@
using System;
using System.Collections.Concurrent;
using System.Linq;
using System.Threading;
using Hangfire.Annotations;
using Hangfire.Storage;
using Raven.Client.Linq;
using System.Linq;
using Hangfire.Raven.Entities;
using Hangfire.Raven.Storage;
using Hangfire.Storage;
using Raven.Abstractions.Data;
using System.Collections.Generic;
using System.Collections.Concurrent;
namespace Hangfire.Raven.JobQueues
{
public class RavenJobQueue
public class RavenJobQueue
: IPersistentJobQueue
{
private readonly RavenStorage _storage;
@@ -28,25 +26,19 @@ namespace Hangfire.Raven.JobQueues
_options = options;
_queue = new BlockingCollection<string>();
using (var session = _storage.Repository.OpenSession())
{
using (var session = _storage.Repository.OpenSession()) {
var missed = session.Advanced.LoadStartingWith<JobQueue>(Repository.GetId(typeof(JobQueue), ""));
foreach(var miss in missed)
{
foreach (var miss in missed) {
_queue.Add(miss.Id);
}
}
// -- Queue listening
if (options.QueueNames == null)
{
if (options.QueueNames == null) {
Console.WriteLine("Starting on ALL Queue's, this is not recommended, please specify using RavenStorageOptions. Use an empty IEnumerable (such as List<string> or string[0]) to not listen to any queue.");
_storage.Repository.DocumentChange(typeof(JobQueue), QueueFiller);
}
else
{
foreach (var queue in options.QueueNames)
{
} else {
foreach (var queue in options.QueueNames) {
Console.WriteLine("Starting on queue: {0}", queue);
_storage.Repository.DocumentChange(typeof(JobQueue), queue, QueueFiller);
}
@@ -55,7 +47,7 @@ namespace Hangfire.Raven.JobQueues
private void QueueFiller(DocumentChangeNotification notification)
{
if(notification.Type == DocumentChangeTypes.Put)
if (notification.Type == DocumentChangeTypes.Put)
_queue.Add(notification.Id);
}
@@ -69,33 +61,25 @@ namespace Hangfire.Raven.JobQueues
}
JobQueue fetchedJob = null;
do
{
do {
var jobId = _queue.Take(cancellationToken);
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
fetchedJob = repository.Load<JobQueue>(jobId);
if (fetchedJob != null &&
if (fetchedJob != null &&
fetchedJob.FetchedAt == null &&
queues.Contains(fetchedJob.Queue))
{
queues.Contains(fetchedJob.Queue)) {
fetchedJob.FetchedAt = DateTime.UtcNow;
repository.Store(fetchedJob);
try
{
try {
// Did someone else already picked it up?
repository.Advanced.UseOptimisticConcurrency = true;
repository.SaveChanges();
}
catch
{
} catch {
fetchedJob = null;
}
}
else
{
} else {
fetchedJob = null;
}
}
@@ -107,10 +91,8 @@ namespace Hangfire.Raven.JobQueues
public void Enqueue(string queue, string jobId)
{
using (var repository = _storage.Repository.OpenSession())
{
var jobQueue = new JobQueue
{
using (var repository = _storage.Repository.OpenSession()) {
var jobQueue = new JobQueue {
Id = Repository.GetId(typeof(JobQueue), queue, jobId),
JobId = jobId,
Queue = queue
@@ -1,13 +1,12 @@
using System.Collections.Generic;
using System.Linq;
using Hangfire.Raven.Entities;
using Hangfire.Raven.JobQueues;
using Hangfire.Raven.Storage;
using Hangfire.Annotations;
using Hangfire.Raven.Entities;
using Hangfire.Raven.Storage;
namespace Hangfire.Raven.JobQueues
{
internal class RavenJobQueueMonitoringApi
internal class RavenJobQueueMonitoringApi
: IPersistentJobQueueMonitoringApi
{
private RavenStorage _storage;
@@ -21,8 +20,7 @@ namespace Hangfire.Raven.JobQueues
public IEnumerable<string> GetQueues()
{
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
return repository.Query<JobQueue>()
.Select(x => x.Queue)
.Distinct()
@@ -35,8 +33,7 @@ namespace Hangfire.Raven.JobQueues
int start = @from + 1;
int end = from + perPage;
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var jobs = repository.Query<JobQueue>()
.Where(t => t.Queue == queue && t.FetchedAt == null)
.Select((data, i) => new { Index = i + 1, Data = data })
@@ -49,7 +46,7 @@ namespace Hangfire.Raven.JobQueues
foreach (var item in jobs) {
var job = repository.Load<RavenJob>(item.JobId);
if(job.StateData != null)
if (job.StateData != null)
results.Add(job);
}
@@ -63,8 +60,7 @@ namespace Hangfire.Raven.JobQueues
int start = @from + 1;
int end = from + perPage;
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var jobs = repository.Query<JobQueue>().Where(t => t.Queue == queue && t.FetchedAt != null)
.Select((data, i) => new { Index = i + 1, Data = data })
.Where(_ => (_.Index >= start) && (_.Index <= end))
@@ -72,8 +68,7 @@ namespace Hangfire.Raven.JobQueues
var results = new List<string>();
foreach (var item in jobs)
{
foreach (var item in jobs) {
var job = repository.Load<RavenJob>(item.JobId);
if (job != null) {
@@ -87,13 +82,11 @@ namespace Hangfire.Raven.JobQueues
public EnqueuedAndFetchedCount GetEnqueuedAndFetchedCount(string queue)
{
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
int enqueuedCount = repository.Query<JobQueue>().Where(t => t.Queue == queue && t.FetchedAt == null).Count();
int fetchedCount = repository.Query<JobQueue>().Where(t => t.Queue == queue && t.FetchedAt != null).Count();
return new EnqueuedAndFetchedCount
{
return new EnqueuedAndFetchedCount {
EnqueuedCount = enqueuedCount,
FetchedCount = fetchedCount
};
@@ -1,10 +1,9 @@
using System;
using Hangfire.Annotations;
using Hangfire.Annotations;
using Hangfire.Raven.Storage;
namespace Hangfire.Raven.JobQueues
{
public class RavenJobQueueProvider
public class RavenJobQueueProvider
: IPersistentJobQueueProvider
{
private readonly IPersistentJobQueue _jobQueue;
@@ -1,10 +1,10 @@
using Raven.Abstractions.Data;
using System.Linq;
using Raven.Abstractions.Data;
using Raven.Client.Listeners;
using System.Linq;
namespace Hangfire.Raven.Listeners
{
public class TakeNewestConflictResolutionListener
public class TakeNewestConflictResolutionListener
: IDocumentConflictListener
{
public bool TryResolveConflict(string key, JsonDocument[] conflictedDocs, out JsonDocument resolvedDocument)
+13 -11
View File
@@ -2,16 +2,18 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Hangfire Raven")]
[assembly: AssemblyDescription("Raven job storage for Hangfire")]
[assembly: Guid("3d96bf2f-8854-4872-aee3-faf81d121a4d")]
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Hangfire.Raven.Core")]
[assembly: AssemblyTrademark("")]
[assembly: InternalsVisibleTo("Hangfire.Raven.Tests")]
// Allow the generation of mocks for internal types
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
[assembly: AssemblyCompany("Axial Commerce")]
[assembly: AssemblyProduct("Hangfire Raven")]
[assembly: AssemblyCopyright("Copyright © Axial Commerce")]
[assembly: AssemblyVersion("1.8")]
[assembly: AssemblyFileVersion("1.8")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("ba18f6bf-5613-4b9d-a57a-c05c51148ec5")]
+72 -101
View File
@@ -19,12 +19,11 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Hangfire.Common;
using Hangfire.Server;
using Hangfire.Storage;
using Raven.Client;
using Hangfire.Raven.DistributedLocks;
using Hangfire.Raven.Entities;
using Hangfire.Raven.Storage;
using Hangfire.Raven.DistributedLocks;
using Hangfire.Server;
using Hangfire.Storage;
using static Hangfire.Raven.Entities.RavenJob;
namespace Hangfire.Raven
@@ -40,20 +39,14 @@ namespace Hangfire.Raven
_storage = ravenStorage;
}
public override IWriteOnlyTransaction CreateWriteTransaction()
{
return new RavenWriteOnlyTransaction(_storage);
}
public override IDisposable AcquireDistributedLock(string resource, TimeSpan timeout)
{
return new RavenDistributedLock(_storage, string.Format("HangFire/{0}", resource), timeout);
}
public override IWriteOnlyTransaction CreateWriteTransaction() => new RavenWriteOnlyTransaction(_storage);
public override IDisposable AcquireDistributedLock(string resource, TimeSpan timeout) => new RavenDistributedLock(_storage, string.Format("HangFire/{0}", resource), timeout);
public override IFetchedJob FetchNextJob(string[] queues, CancellationToken cancellationToken)
{
queues.ThrowIfNull("queues");
if (queues.Length == 0) {
throw new ArgumentNullException("queues");
}
@@ -70,6 +63,7 @@ namespace Hangfire.Raven
}
var persistentQueue = providers[0].GetJobQueue();
return persistentQueue.Dequeue(queues, cancellationToken);
}
@@ -82,12 +76,10 @@ namespace Hangfire.Raven
job.ThrowIfNull("job");
parameters.ThrowIfNull("parameters");
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var guid = Guid.NewGuid().ToString();
var ravenJob = new RavenJob
{
var ravenJob = new RavenJob {
Id = Repository.GetId(typeof(RavenJob), guid),
Job = JobWrapper.Create(job),
CreatedAt = createdAt,
@@ -107,18 +99,17 @@ namespace Hangfire.Raven
{
key.ThrowIfNull("key");
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var id = Repository.GetId(typeof(RavenJob), key);
var jobData = repository.Load<RavenJob>(id);
if (jobData == null)
{
if (jobData == null) {
return null;
}
var job = jobData.Job.GetJob();
return new JobData
{
return new JobData {
Job = job,
State = jobData.StateData?.Name,
CreatedAt = jobData.CreatedAt
@@ -130,8 +121,7 @@ namespace Hangfire.Raven
{
jobId.ThrowIfNull("jobId");
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var id = Repository.GetId(typeof(RavenJob), jobId);
var job = repository.Load<RavenJob>(id);
@@ -148,12 +138,12 @@ namespace Hangfire.Raven
jobId.ThrowIfNull("jobId");
name.ThrowIfNull("name");
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var id = Repository.GetId(typeof(RavenJob), jobId);
var job = repository.Load<RavenJob>(id);
job.Parameters[name] = value;
repository.SaveChanges();
}
}
@@ -163,23 +153,23 @@ namespace Hangfire.Raven
jobId.ThrowIfNull("jobId");
name.ThrowIfNull("name");
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var id = Repository.GetId(typeof(RavenJob), jobId);
var job = repository.Load<RavenJob>(id);
string value;
if (!job.Parameters.TryGetValue(name, out value))
{
if (name == "RetryCount")
{
if (!job.Parameters.TryGetValue(name, out value)) {
if (name == "RetryCount") {
job.Parameters["RetryCount"] = "0";
repository.SaveChanges();
return "0";
}
return null;
}
return value;
}
}
@@ -188,13 +178,13 @@ namespace Hangfire.Raven
{
key.ThrowIfNull("key");
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var id = Repository.GetId(typeof(RavenSet), key);
var set = repository.Load<RavenSet>(id);
if (set == null)
if (set == null) {
return null;
}
return new HashSet<string>(set.Scores.Keys);
}
@@ -208,13 +198,13 @@ namespace Hangfire.Raven
throw new ArgumentException("The `toScore` value must be higher or equal to the `fromScore` value.");
}
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var id = Repository.GetId(typeof(RavenSet), key);
var set = repository.Load<RavenSet>(id);
if (set == null)
if (set == null) {
return null;
}
return set.Scores.OrderBy(a => a.Value).Select(a => a.Key).FirstOrDefault();
}
@@ -225,22 +215,19 @@ namespace Hangfire.Raven
key.ThrowIfNull("key");
keyValuePairs.ThrowIfNull("keyValuePairs");
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var id = Repository.GetId(typeof(RavenHash), key);
var result = repository.Load<RavenHash>(id);
if (result == null)
{
result = new RavenHash()
{
if (result == null) {
result = new RavenHash() {
Id = id
};
repository.Store(result);
}
foreach (var keyValuePair in keyValuePairs)
{
foreach (var keyValuePair in keyValuePairs) {
result.Fields[keyValuePair.Key] = keyValuePair.Value;
}
@@ -252,8 +239,7 @@ namespace Hangfire.Raven
{
key.ThrowIfNull("key");
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var result = repository.Load<RavenHash>(Repository.GetId(typeof(RavenHash), key));
return result?.Fields;
@@ -265,18 +251,16 @@ namespace Hangfire.Raven
serverId.ThrowIfNull("serverId");
context.ThrowIfNull("context");
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var id = Repository.GetId(typeof(RavenServer), serverId);
var server = repository.Load<RavenServer>(id);
if(server == null)
{
server = new RavenServer()
{
if (server == null) {
server = new RavenServer() {
Id = id,
Data = new RavenServer.ServerData()
};
repository.Store(server);
}
@@ -294,9 +278,9 @@ namespace Hangfire.Raven
{
serverId.ThrowIfNull("serverId");
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var id = Repository.GetId(typeof(RavenServer), serverId);
repository.Delete(id);
repository.SaveChanges();
@@ -307,20 +291,18 @@ namespace Hangfire.Raven
{
serverId.ThrowIfNull("serverId");
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var id = Repository.GetId(typeof(RavenServer), serverId);
var server = repository.Load<RavenServer>(id);
if (server == null)
{
server = new RavenServer
{
if (server == null) {
server = new RavenServer {
Id = id
};
}
server.LastHeartbeat = DateTime.UtcNow;
repository.SaveChanges();
}
}
@@ -331,8 +313,7 @@ namespace Hangfire.Raven
throw new ArgumentException("The `timeOut` value must be positive.", "timeOut");
}
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var heartBeatCutOff = DateTime.UtcNow.Add(timeOut.Negate());
var results = repository.Query<RavenServer>()
@@ -342,6 +323,7 @@ namespace Hangfire.Raven
foreach (var item in results) {
repository.Delete(item);
}
repository.SaveChanges();
return results.Count;
@@ -352,13 +334,13 @@ namespace Hangfire.Raven
{
key.ThrowIfNull("key");
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var id = Repository.GetId(typeof(RavenSet), key);
var set = repository.Load<RavenSet>(id);
if (set == null)
if (set == null) {
return 0;
}
return set.Scores.Count;
}
@@ -368,13 +350,13 @@ namespace Hangfire.Raven
{
key.ThrowIfNull("key");
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var id = Repository.GetId(typeof(RavenSet), key);
var set = repository.Load<RavenSet>(id);
if (set == null)
if (set == null) {
return new List<string>();
}
return set.Scores.Skip(startingFrom - 1)
.Take(endingAt - startingFrom + 1)
@@ -387,15 +369,15 @@ namespace Hangfire.Raven
{
key.ThrowIfNull("key");
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var id = Repository.GetId(typeof(RavenSet), key);
var set = repository.Load<RavenSet>(id);
var expireAt = repository.Advanced.GetExpire(set);
if(expireAt == null)
if (expireAt == null) {
return TimeSpan.FromSeconds(-1);
}
return expireAt.Value - DateTime.UtcNow;
}
@@ -405,8 +387,7 @@ namespace Hangfire.Raven
{
key.ThrowIfNull("key");
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var values = repository.Query<AggregatedCounter>()
.Where(t => t.Key == key)
.Select(t => t.Value)
@@ -420,8 +401,7 @@ namespace Hangfire.Raven
{
key.ThrowIfNull("key");
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var ravenHash = repository.Load<RavenHash>(Repository.GetId(typeof(RavenHash), key));
return ravenHash.Fields.Count;
@@ -432,11 +412,11 @@ namespace Hangfire.Raven
{
key.ThrowIfNull("key");
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var ravenHash = repository.Load<RavenHash>(Repository.GetId(typeof(RavenHash), key));
var expireAt = repository.Advanced.GetExpire(ravenHash);
if (!expireAt.HasValue) {
return TimeSpan.FromSeconds(-1);
}
@@ -450,13 +430,14 @@ namespace Hangfire.Raven
key.ThrowIfNull("key");
name.ThrowIfNull("name");
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var ravenHash = repository.Load<RavenHash>(Repository.GetId(typeof(RavenHash), key));
string result;
if(!ravenHash.Fields.TryGetValue(name, out result))
if (!ravenHash.Fields.TryGetValue(name, out result)) {
return null;
}
return result;
}
@@ -466,13 +447,10 @@ namespace Hangfire.Raven
{
key.ThrowIfNull("key");
using (var repository = _storage.Repository.OpenSession())
{
var count = repository.Query<RavenList>()
using (var repository = _storage.Repository.OpenSession()) {
return repository.Query<RavenList>()
.Where(t => t.Key == key)
.Count();
return count;
}
}
@@ -480,8 +458,7 @@ namespace Hangfire.Raven
{
key.ThrowIfNull("key");
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
// TODO: Implement!
return TimeSpan.FromSeconds(-1);
@@ -492,16 +469,13 @@ namespace Hangfire.Raven
{
key.ThrowIfNull("key");
using (var repository = _storage.Repository.OpenSession())
{
var results = repository.Query<RavenList>()
using (var repository = _storage.Repository.OpenSession()) {
return repository.Query<RavenList>()
.Where(t => t.Key == key)
.Select(t => t.Value)
.Skip(startingFrom - 1)
.Take(endingAt - startingFrom + 1)
.ToList();
return results;
}
}
@@ -509,14 +483,11 @@ namespace Hangfire.Raven
{
key.ThrowIfNull("key");
using (var repository = _storage.Repository.OpenSession())
{
var results = repository.Query<RavenList>()
using (var repository = _storage.Repository.OpenSession()) {
return repository.Query<RavenList>()
.Where(t => t.Key == key)
.Select(t => t.Value)
.ToList();
return results;
}
}
}
+14 -41
View File
@@ -1,11 +1,8 @@
using Raven.Imports.Newtonsoft.Json;
using Raven.Imports.Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Raven.Imports.Newtonsoft.Json;
using Raven.Imports.Newtonsoft.Json.Linq;
namespace Hangfire.Raven
{
@@ -41,10 +38,7 @@ namespace Hangfire.Raven
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public override bool CanConvert(Type type)
{
return typeof(T).IsAssignableFrom(type);
}
public override bool CanConvert(Type type) => typeof(T).IsAssignableFrom(type);
/// <summary>
/// Overriding the ReadJson of JsonConvert
@@ -57,8 +51,8 @@ namespace Hangfire.Raven
public override object ReadJson(JsonReader reader, Type type, object existingValue, JsonSerializer serializer)
{
T toReturn;
switch (reader.TokenType)
{
switch (reader.TokenType) {
case JsonToken.StartArray:
toReturn = Read(type, JArray.Load(reader), serializer);
break;
@@ -84,7 +78,7 @@ namespace Hangfire.Raven
serializer.Serialize(writer, Write((T)value, serializer));
}
}
public class RavenJsonMethodConverter
: RavenJsonConverterBase<MethodInfo>
{
@@ -92,25 +86,14 @@ namespace Hangfire.Raven
{
var splitted = value.ToString().Split(';');
if (splitted.Count() == 3)
{
var assembly = Assemblies.Get().Where(a => a.GetName().Name == splitted[0]).First();
var assemblyClass = Assemblies.GetClass(assembly, splitted[1]);
if (assemblyClass != null)
return assemblyClass.GetMethod(splitted[2]);
if (splitted.Count() == 3) {
return Assembly.GetEntryAssembly().GetType(splitted[1]).GetMethod(splitted[2]);
}
return null;
}
protected override object Write(MethodInfo value, JsonSerializer serializer)
{
return string.Format("{0};{1};{2}",
value.DeclaringType.Assembly.GetName().Name,
value.DeclaringType.FullName,
value.Name);
}
protected override object Write(MethodInfo value, JsonSerializer serializer) => $"{value.DeclaringType.GetTypeInfo().Assembly.GetName().Name};{value.DeclaringType.FullName};{value.Name}";
}
public class RavenJsonPropertyConverter
@@ -120,23 +103,13 @@ namespace Hangfire.Raven
{
var splitted = value.ToString().Split(';');
if (splitted.Count() == 3)
{
var assembly = Assemblies.Get().Where(a => a.GetName().Name == splitted[0]).First();
var assemblyType = Assemblies.GetClass(assembly, splitted[1]);
if (assemblyType != null)
return assemblyType.GetProperty(splitted[2]);
if (splitted.Count() == 3) {
return Assembly.GetEntryAssembly().GetType(splitted[1]).GetProperty(splitted[2]);
}
return null;
}
protected override object Write(PropertyInfo value, JsonSerializer serializer)
{
return string.Format("{0};{1};{2}",
value.DeclaringType.Assembly.GetName().Name,
value.DeclaringType.FullName,
value.Name);
}
protected override object Write(PropertyInfo value, JsonSerializer serializer) => $"{value.DeclaringType.GetTypeInfo().Assembly.GetName().Name};{value.DeclaringType.FullName};{value.Name}";
}
}
+47 -54
View File
@@ -2,23 +2,22 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Hangfire.Annotations;
using Hangfire.Common;
using Hangfire.States;
using Hangfire.Storage;
using Hangfire.Raven.Entities;
using Hangfire.Raven.Storage;
using Hangfire.States;
using Hangfire.Storage;
using Hangfire.Storage.Monitoring;
using Raven.Client;
using Raven.Abstractions.Data;
using Raven.Client;
namespace Hangfire.Raven
{
internal class RavenWriteOnlyTransaction
internal class RavenWriteOnlyTransaction
: JobStorageTransaction
{
private readonly RavenStorage _storage;
private IDocumentSession _session;
private List<KeyValuePair<string,PatchRequest>> _patchRequests;
private List<KeyValuePair<string, PatchRequest>> _patchRequests;
public RavenWriteOnlyTransaction([NotNull] RavenStorage storage)
{
@@ -32,20 +31,18 @@ namespace Hangfire.Raven
public override void Commit()
{
try
{
try {
_session.SaveChanges();
_session.Dispose();
var toPatch = _patchRequests.ToLookup(a => a.Key, a => a.Value);
foreach(var item in toPatch)
{
foreach (var item in toPatch) {
_session.Advanced.DocumentStore.DatabaseCommands.Patch(item.Key, item.ToArray());
}
}
catch
{
} catch {
Console.WriteLine("- Concurrency exception");
throw;
}
}
@@ -70,17 +67,15 @@ namespace Hangfire.Raven
{
var id = Repository.GetId(typeof(RavenJob), jobId);
var result = _session.Load<RavenJob>(id);
result.History.Insert(0, new StateHistoryDto()
{
result.History.Insert(0, new StateHistoryDto() {
StateName = state.Name,
Data = state.SerializeData(),
Reason = state.Reason,
CreatedAt = DateTime.UtcNow
});
result.StateData = new StateData()
{
result.StateData = new StateData() {
Name = state.Name,
Data = state.SerializeData(),
Reason = state.Reason
@@ -89,7 +84,7 @@ namespace Hangfire.Raven
public override void AddJobState(string jobId, IState state)
{
this.SetJobState(jobId, state);
SetJobState(jobId, state);
}
public override void AddToQueue(string queue, string jobId)
@@ -102,27 +97,26 @@ namespace Hangfire.Raven
public override void IncrementCounter(string key)
{
this.IncrementCounter(key, TimeSpan.MinValue);
IncrementCounter(key, TimeSpan.MinValue);
}
public override void IncrementCounter(string key, TimeSpan expireIn)
{
var id = Repository.GetId(typeof(Counter), key);
if (_session.Load<Counter>(id) == null)
{
var counter = new Counter()
{
if (_session.Load<Counter>(id) == null) {
var counter = new Counter() {
Id = id,
Value = 1
};
_session.Store(counter);
if (expireIn != TimeSpan.MinValue)
if (expireIn != TimeSpan.MinValue) {
_session.Advanced.AddExpire(counter, DateTime.UtcNow + expireIn);
}
else
{
_patchRequests.Add(new KeyValuePair<string, PatchRequest>(id, new PatchRequest()
{
}
} else {
_patchRequests.Add(new KeyValuePair<string, PatchRequest>(id, new PatchRequest() {
Type = PatchCommandType.Inc,
Name = "Value",
Value = 1
@@ -132,27 +126,26 @@ namespace Hangfire.Raven
public override void DecrementCounter(string key)
{
this.DecrementCounter(key, TimeSpan.MinValue);
DecrementCounter(key, TimeSpan.MinValue);
}
public override void DecrementCounter(string key, TimeSpan expireIn)
{
var id = Repository.GetId(typeof(Counter), key);
if (_session.Load<Counter>(id) == null)
{
var counter = new Counter()
{
if (_session.Load<Counter>(id) == null) {
var counter = new Counter() {
Id = id,
Value = -1
};
_session.Store(counter);
if (expireIn != TimeSpan.MinValue)
if (expireIn != TimeSpan.MinValue) {
_session.Advanced.AddExpire(counter, DateTime.UtcNow + expireIn);
}
else
{
_patchRequests.Add(new KeyValuePair<string, PatchRequest>(id, new PatchRequest()
{
}
} else {
_patchRequests.Add(new KeyValuePair<string, PatchRequest>(id, new PatchRequest() {
Type = PatchCommandType.Inc,
Name = "Value",
Value = -1
@@ -168,12 +161,13 @@ namespace Hangfire.Raven
public override void AddToSet(string key, string value, double score)
{
var id = Repository.GetId(typeof(RavenSet), key);
var set = _session.Load<RavenSet>(id) ?? new RavenSet()
{
var set = _session.Load<RavenSet>(id) ?? new RavenSet() {
Id = id
};
_session.Store(set);
set.Scores[value] = score;
}
@@ -182,10 +176,10 @@ namespace Hangfire.Raven
var id = Repository.GetId(typeof(RavenSet), key);
var set = _session.Load<RavenSet>(id);
set.Scores.Remove(value);
if(set.Scores.Count == 0)
{
if (set.Scores.Count == 0) {
_session.Delete(set);
}
}
@@ -195,6 +189,7 @@ namespace Hangfire.Raven
key.ThrowIfNull("key");
var id = Repository.GetId(typeof(RavenSet), key);
_session.Delete(id);
}
@@ -224,14 +219,14 @@ namespace Hangfire.Raven
var list = _session.Query<RavenList>().FirstOrDefault(t => t.Key == key && t.Value == value);
if (list == null) {
list = new RavenList
{
list = new RavenList {
Id = Guid.NewGuid().ToString(),
Key = key
};
}
list.Value = value;
_session.Store(list);
}
@@ -269,22 +264,20 @@ namespace Hangfire.Raven
{
key.ThrowIfNull("key");
keyValuePairs.ThrowIfNull("keyValuePairs");
var id = Repository.GetId(typeof(RavenHash), key);
var result = _session.Load<RavenHash>(id);
// Not exists? Insert
if(result == null)
{
result = new RavenHash()
{
if (result == null) {
result = new RavenHash() {
Id = id
};
_session.Store(result);
}
foreach (var keyValuePair in keyValuePairs)
{
foreach (var keyValuePair in keyValuePairs) {
result.Fields[keyValuePair.Key] = keyValuePair.Value;
}
}
+19 -33
View File
@@ -1,18 +1,12 @@
using Raven.Client;
using System;
using Raven.Client.Document;
using System.Threading.Tasks;
using System;
using System.Collections.Generic;
using Raven.Abstractions.Data;
using System.Collections.Concurrent;
using Raven.Client.Linq;
using System.Linq;
using System.Linq.Expressions;
using Hangfire.Raven.Extensions;
using Hangfire.Raven.Listeners;
using Hangfire.Raven.Storage;
using Raven.Client.Indexes;
using Hangfire.Raven.Indexes;
using Hangfire.Raven.Listeners;
using Raven.Abstractions.Data;
using Raven.Client;
using Raven.Client.Document;
using Raven.Client.Indexes;
using Raven.Imports.Newtonsoft.Json;
namespace Hangfire.Raven
@@ -60,34 +54,25 @@ namespace Hangfire.Raven
{
_config = config;
if (!string.IsNullOrEmpty(_config.ConnectionString))
{
_documentStore = new DocumentStore
{
if (!string.IsNullOrEmpty(_config.ConnectionString)) {
_documentStore = new DocumentStore {
ConnectionStringName = _config.ConnectionString,
ApiKey = _config.APIKey,
DefaultDatabase = _config.Database,
Conventions = new DocumentConvention()
{
CustomizeJsonSerializer = delegate (JsonSerializer input)
{
Conventions = new DocumentConvention() {
CustomizeJsonSerializer = delegate (JsonSerializer input) {
input.Converters.Add(new RavenJsonPropertyConverter());
input.Converters.Add(new RavenJsonMethodConverter());
}
}
};
}
else
{
_documentStore = new DocumentStore
{
} else {
_documentStore = new DocumentStore {
Url = _config.ConnectionUrl,
ApiKey = _config.APIKey,
DefaultDatabase = _config.Database,
Conventions = new DocumentConvention()
{
CustomizeJsonSerializer = delegate (JsonSerializer input)
{
Conventions = new DocumentConvention() {
CustomizeJsonSerializer = delegate (JsonSerializer input) {
input.Converters.Add(new RavenJsonPropertyConverter());
input.Converters.Add(new RavenJsonMethodConverter());
}
@@ -113,7 +98,7 @@ namespace Hangfire.Raven
public static string GetId(Type type, params string[] id)
{
return Repository._documentStore.Conventions.FindFullDocumentKeyFromNonStringIdentifier(string.Join("/", id), type, false);
return _documentStore.Conventions.FindFullDocumentKeyFromNonStringIdentifier(string.Join("/", id), type, false);
}
public void Destroy()
@@ -127,19 +112,19 @@ namespace Hangfire.Raven
public void Create()
{
if (_documentStore.DatabaseExists(_config.Database))
{
if (_documentStore.DatabaseExists(_config.Database)) {
return;
}
_documentStore.DatabaseCommands.GlobalAdmin.EnsureDatabaseExists(_config.Database);
}
public IDisposable DocumentChange(Type documentType, Action<DocumentChangeNotification> action)
{
return _documentStore.Changes(_config.Database).ForDocumentsStartingWith(GetId(documentType, ""))
.Subscribe(new RepositoryObserver<DocumentChangeNotification>(action));
}
public IDisposable DocumentChange(Type documentType, string suffix, Action<DocumentChangeNotification> action)
{
return _documentStore.Changes(_config.Database).ForDocumentsStartingWith(
@@ -152,6 +137,7 @@ namespace Hangfire.Raven
{
return _documentStore.OpenSession(_config.Database);
}
public IAsyncDocumentSession OpenAsyncSession()
{
return _documentStore.OpenAsyncSession(_config.Database);
@@ -7,17 +7,16 @@ namespace Hangfire.Raven.StateHandlers
{
public void Apply(ApplyStateContext context, IWriteOnlyTransaction transaction)
{
transaction.InsertToList("deleted", context.JobId);
transaction.InsertToList("deleted", context.BackgroundJob.Id);
transaction.TrimList("deleted", 0, 99);
}
public void Unapply(ApplyStateContext context, IWriteOnlyTransaction transaction)
{
transaction.RemoveFromList("deleted", context.JobId);
transaction.RemoveFromList("deleted", context.BackgroundJob.Id);
}
public string StateName
{
public string StateName {
get { return DeletedState.StateName; }
}
}
@@ -1,7 +1,7 @@
using Hangfire.Common;
using System;
using Hangfire.Common;
using Hangfire.States;
using Hangfire.Storage;
using System;
namespace Hangfire.Raven.StateHandlers
{
@@ -9,16 +9,15 @@ namespace Hangfire.Raven.StateHandlers
{
public void Apply(ApplyStateContext context, IWriteOnlyTransaction transaction)
{
transaction.AddToSet("failed", context.JobId, JobHelper.ToTimestamp(DateTime.UtcNow));
transaction.AddToSet("failed", context.BackgroundJob.Id, JobHelper.ToTimestamp(DateTime.UtcNow));
}
public void Unapply(ApplyStateContext context, IWriteOnlyTransaction transaction)
{
transaction.RemoveFromSet("failed", context.JobId);
transaction.RemoveFromSet("failed", context.BackgroundJob.Id);
}
public string StateName
{
public string StateName {
get { return FailedState.StateName; }
}
}
@@ -1,7 +1,7 @@
using Hangfire.Common;
using System;
using Hangfire.Common;
using Hangfire.States;
using Hangfire.Storage;
using System;
namespace Hangfire.Raven.StateHandlers
{
@@ -9,16 +9,15 @@ namespace Hangfire.Raven.StateHandlers
{
public void Apply(ApplyStateContext context, IWriteOnlyTransaction transaction)
{
transaction.AddToSet("processing", context.JobId, JobHelper.ToTimestamp(DateTime.UtcNow));
transaction.AddToSet("processing", context.BackgroundJob.Id, JobHelper.ToTimestamp(DateTime.UtcNow));
}
public void Unapply(ApplyStateContext context, IWriteOnlyTransaction transaction)
{
transaction.RemoveFromSet("processing", context.JobId);
transaction.RemoveFromSet("processing", context.BackgroundJob.Id);
}
public string StateName
{
public string StateName {
get { return ProcessingState.StateName; }
}
}
@@ -7,17 +7,16 @@ namespace Hangfire.Raven.StateHandlers
{
public void Apply(ApplyStateContext context, IWriteOnlyTransaction transaction)
{
transaction.InsertToList("succeeded", context.JobId);
transaction.InsertToList("succeeded", context.BackgroundJob.Id);
transaction.TrimList("succeeded", 0, 99);
}
public void Unapply(ApplyStateContext context, IWriteOnlyTransaction transaction)
{
transaction.RemoveFromList("succeeded", context.JobId);
transaction.RemoveFromList("succeeded", context.BackgroundJob.Id);
}
public string StateName
{
public string StateName {
get { return SucceededState.StateName; }
}
}
+3 -6
View File
@@ -1,12 +1,9 @@
using System;
using System.Collections.Generic;
using Hangfire.Logging;
using Hangfire.Server;
using Hangfire.Storage;
using Raven.Client.Document;
using Hangfire.Raven.JobQueues;
using Raven.Client.Indexes;
using Hangfire.Raven.Indexes;
using Hangfire.Raven.JobQueues;
using Hangfire.Storage;
using Raven.Client.Indexes;
namespace Hangfire.Raven.Storage
{
@@ -1,7 +1,4 @@
using System;
using Hangfire;
using Hangfire.Raven.Storage;
using Hangfire.Raven;
using Raven.Client;
using Raven.Json.Linq;
@@ -20,8 +17,7 @@ namespace Hangfire.Raven.Storage
public static DateTime? GetExpire<T>(this ISyncAdvancedSessionOperation advanced, T obj)
{
RavenJToken token;
if (advanced.GetMetadataFor(obj).TryGetValue("Raven-Expiration-Date", out token))
{
if (advanced.GetMetadataFor(obj).TryGetValue("Raven-Expiration-Date", out token)) {
var date = token.Value<DateTime>();
return date;
}
@@ -40,8 +36,7 @@ namespace Hangfire.Raven.Storage
configuration.ThrowIfNull("configuration");
connectionString.ThrowIfNull("connectionString");
var config = new RepositoryConfig()
{
var config = new RepositoryConfig() {
ConnectionString = connectionString
};
var storage = new RavenStorage(config);
@@ -59,8 +54,7 @@ namespace Hangfire.Raven.Storage
throw new ArgumentException("Connection Url must begin with http or https!");
}
var config = new RepositoryConfig()
{
var config = new RepositoryConfig() {
ConnectionUrl = connectionUrl,
Database = database
};
@@ -79,8 +73,7 @@ namespace Hangfire.Raven.Storage
throw new ArgumentException("Connection Url must begin with http or https!");
}
var config = new RepositoryConfig()
{
var config = new RepositoryConfig() {
ConnectionUrl = connectionUrl,
Database = database,
APIKey = APIKey
@@ -102,8 +95,7 @@ namespace Hangfire.Raven.Storage
throw new ArgumentException("Connection Url must begin with http or https!");
}
var config = new RepositoryConfig()
{
var config = new RepositoryConfig() {
ConnectionUrl = connectionUrl,
Database = database
};
@@ -1,22 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Hangfire.Annotations;
using Hangfire.Common;
using Hangfire.Raven.Entities;
using Hangfire.Raven.Indexes;
using Hangfire.States;
using Hangfire.Storage;
using Hangfire.Storage.Monitoring;
using Hangfire.Raven.Entities;
using Raven.Abstractions.Data;
using Raven.Client;
using Raven.Client.Linq;
using Hangfire.Annotations;
using Raven.Client.Indexes;
using Raven.Abstractions.Indexing;
using Raven.Abstractions.Data;
using Hangfire.Raven.Indexes;
namespace Hangfire.Raven.Storage
{
public class RavenStorageMonitoringApi
public class RavenStorageMonitoringApi
: IMonitoringApi
{
private RavenStorage _storage;
@@ -27,11 +25,10 @@ namespace Hangfire.Raven.Storage
_storage = storage;
}
public long EnqueuedCount(string queue)
{
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
RavenQueryStatistics stats;
repository.Query<JobQueue>()
.Where(a => a.FetchedAt == null && a.Queue == queue)
@@ -44,8 +41,7 @@ namespace Hangfire.Raven.Storage
}
public long FetchedCount(string queue)
{
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
RavenQueryStatistics stats;
repository.Query<JobQueue>()
.Where(a => a.FetchedAt != null && a.Queue == queue)
@@ -78,8 +74,7 @@ namespace Hangfire.Raven.Storage
}
private long GetNumberOfJobsByStateName(string stateName)
{
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
RavenQueryStatistics stats;
repository.Query<RavenJob>()
.Where(a => a.StateData.Name == stateName)
@@ -112,8 +107,7 @@ namespace Hangfire.Raven.Storage
var endDate = DateTime.UtcNow;
var dates = new List<DateTime>();
for (var i = 0; i < 24; i++)
{
for (var i = 0; i < 24; i++) {
dates.Add(endDate);
endDate = endDate.AddHours(-1);
}
@@ -125,8 +119,7 @@ namespace Hangfire.Raven.Storage
var endDate = DateTime.UtcNow.Date;
var dates = new List<DateTime>();
for (var i = 0; i < 7; i++)
{
for (var i = 0; i < 7; i++) {
dates.Add(endDate);
endDate = endDate.AddDays(-1);
}
@@ -137,10 +130,8 @@ namespace Hangfire.Raven.Storage
Func<DateTime, string> formatorAction)
{
var stats = new Dictionary<DateTime, long>();
using (var repository = _storage.Repository.OpenSession())
{
foreach(var item in dates)
{
using (var repository = _storage.Repository.OpenSession()) {
foreach (var item in dates) {
var id = Repository.GetId(typeof(Counter), formatorAction(item));
var counters = repository.Load<Counter>(id);
@@ -155,8 +146,7 @@ namespace Hangfire.Raven.Storage
}
public StatisticsDto GetStatistics()
{
using (var transaction = _storage.Repository.OpenSession())
{
using (var transaction = _storage.Repository.OpenSession()) {
var stat = new RavenQueryStatistics();
transaction.Query<Raven_DocumentsByEntityName.Mapping, Raven_DocumentsByEntityName>()
.Where(a => a.Tag == "RavenServers")
@@ -179,8 +169,7 @@ namespace Hangfire.Raven.Storage
});
var getFacetValues = facetResults.Results["StateName"].Values;
return new StatisticsDto()
{
return new StatisticsDto() {
Servers = stat.TotalResults,
Queues = 2,
Recurring = recurringJobs?.Scores?.Count ?? 0,
@@ -203,16 +192,14 @@ namespace Hangfire.Raven.Storage
from,
count,
DeletedState.StateName,
(jsonJob, job, stateData) => new DeletedJobDto
{
(jsonJob, job, stateData) => new DeletedJobDto {
Job = job,
DeletedAt = JobHelper.DeserializeNullableDateTime(stateData["DeletedAt"])
});
}
public JobList<EnqueuedJobDto> EnqueuedJobs(string queue, int from, int perPage)
{
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var results = repository.Query<JobQueue>()
.Where(a => a.FetchedAt == null && a.Queue == queue)
.Skip(from)
@@ -226,8 +213,7 @@ namespace Hangfire.Raven.Storage
{
return GetJobs(from, count,
FailedState.StateName,
(jsonJob, job, stateData) => new FailedJobDto
{
(jsonJob, job, stateData) => new FailedJobDto {
Job = job,
Reason = jsonJob.StateData.Reason,
ExceptionDetails = stateData["ExceptionDetails"],
@@ -238,8 +224,7 @@ namespace Hangfire.Raven.Storage
}
public JobList<FetchedJobDto> FetchedJobs(string queue, int from, int perPage)
{
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var results = repository.Query<JobQueue>()
.Where(a => a.FetchedAt != null && a.Queue == queue)
.Skip(from)
@@ -253,8 +238,7 @@ namespace Hangfire.Raven.Storage
{
return GetJobs(from, count,
ScheduledState.StateName,
(jsonJob, job, stateData) => new ScheduledJobDto
{
(jsonJob, job, stateData) => new ScheduledJobDto {
Job = job,
EnqueueAt = JobHelper.DeserializeDateTime(stateData["EnqueueAt"]),
ScheduledAt = JobHelper.DeserializeDateTime(stateData["ScheduledAt"])
@@ -264,8 +248,7 @@ namespace Hangfire.Raven.Storage
{
return GetJobs(from, count,
ProcessingState.StateName,
(jsonJob, job, stateData) => new ProcessingJobDto
{
(jsonJob, job, stateData) => new ProcessingJobDto {
Job = job,
ServerId = stateData.ContainsKey("ServerId") ? stateData["ServerId"] : stateData["ServerName"],
StartedAt = JobHelper.DeserializeDateTime(stateData["StartedAt"])
@@ -275,8 +258,7 @@ namespace Hangfire.Raven.Storage
{
var toReturn = GetJobs(from, count,
SucceededState.StateName,
(jsonJob, job, stateData) => new SucceededJobDto
{
(jsonJob, job, stateData) => new SucceededJobDto {
Job = job,
InSucceededState = true,
Result = stateData.ContainsKey("Result") ? stateData["Result"] : null,
@@ -296,13 +278,11 @@ namespace Hangfire.Raven.Storage
{
jobId.ThrowIfNull("jobId");
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var id = Repository.GetId(typeof(RavenJob), jobId);
var job = repository.Load<RavenJob>(id);
return new JobDetailsDto
{
return new JobDetailsDto {
CreatedAt = job.CreatedAt,
ExpireAt = repository.Advanced.GetExpire(job),
Job = job.Job.GetJob(),
@@ -313,16 +293,14 @@ namespace Hangfire.Raven.Storage
}
public IList<QueueWithTopEnqueuedJobsDto> Queues()
{
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var query = repository.Query<JobQueue>().ToList();
var results = from item in query
group item by item.Queue into g
let total = g.Count()
let fetched = g.Count(a => a.FetchedAt.HasValue)
select new QueueWithTopEnqueuedJobsDto()
{
select new QueueWithTopEnqueuedJobsDto() {
Name = g.Key,
Length = total - fetched,
Fetched = fetched,
@@ -335,14 +313,12 @@ namespace Hangfire.Raven.Storage
}
public IList<ServerDto> Servers()
{
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var servers = repository.Query<RavenServer>().ToList();
var query =
from server in servers
select new ServerDto
{
select new ServerDto {
Name = server.Id,
Heartbeat = server.LastHeartbeat,
Queues = server.Data.Queues.ToList(),
@@ -354,15 +330,14 @@ namespace Hangfire.Raven.Storage
}
}
private JobList<TDto> GetJobs<TDto>(
int from,
int count,
string stateName,
Func<RavenJob, Job, Dictionary<string, string>, TDto> selector)
{
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var jobs = repository.Query<RavenJob>().Where(a => a.StateData.Name == stateName)
.OrderBy(a => a.CreatedAt)
.Skip(from)
@@ -374,15 +349,13 @@ namespace Hangfire.Raven.Storage
}
private JobList<FetchedJobDto> FetchedJobs(IEnumerable<string> jobIds)
{
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var jobs = repository.Load<RavenJob>(
jobIds.Select(a => Repository.GetId(typeof(RavenJob), a))
)
.Where(a => a != null && a.StateData != null);
return DeserializeJobs(jobs, (jsonJob, job, stateData) => new FetchedJobDto
{
return DeserializeJobs(jobs, (jsonJob, job, stateData) => new FetchedJobDto {
Job = job,
State = jsonJob.StateData.Name,
FetchedAt = jsonJob.StateData.Name == ProcessingState.StateName
@@ -393,13 +366,11 @@ namespace Hangfire.Raven.Storage
}
private JobList<EnqueuedJobDto> EnqueuedJobs(IEnumerable<string> jobIds)
{
using (var repository = _storage.Repository.OpenSession())
{
using (var repository = _storage.Repository.OpenSession()) {
var jobs = repository.Load<RavenJob>(jobIds.Select(a => Repository.GetId(typeof(RavenJob), a)))
.Where(a => a != null && a.StateData != null);
return DeserializeJobs(jobs, (jsonJob, job, stateData) => new EnqueuedJobDto
{
return DeserializeJobs(jobs, (jsonJob, job, stateData) => new EnqueuedJobDto {
Job = job,
State = jsonJob.StateData.Name,
EnqueuedAt = jsonJob.StateData.Name == EnqueuedState.StateName
@@ -413,12 +384,9 @@ namespace Hangfire.Raven.Storage
private Job DeserializeJob(InvocationData invocationData)
{
try
{
try {
return invocationData.Deserialize();
}
catch (JobLoadException)
{
} catch (JobLoadException) {
return null;
}
}
@@ -428,11 +396,11 @@ namespace Hangfire.Raven.Storage
Func<RavenJob, Job, Dictionary<string, string>, TDto> selector)
{
var result = from job in jobs
let stateData = job.StateData.Data != null
? new Dictionary<string, string>(job.StateData.Data, StringComparer.OrdinalIgnoreCase)
: null
let dto = selector(job, job.Job.GetJob(), stateData)
select new KeyValuePair<string, TDto>(job.Id.Split(new char[] { '/' },2)[1], dto);
let stateData = job.StateData.Data != null
? new Dictionary<string, string>(job.StateData.Data, StringComparer.OrdinalIgnoreCase)
: null
let dto = selector(job, job.Job.GetJob(), stateData)
select new KeyValuePair<string, TDto>(job.Id.Split(new char[] { '/' }, 2)[1], dto);
return new JobList<TDto>(result);
}
@@ -13,7 +13,7 @@ namespace Hangfire.Raven.Storage
CountersAggregateInterval = TimeSpan.FromMinutes(5);
TransactionTimeout = TimeSpan.FromMinutes(1);
_clientId = Guid.NewGuid().ToString().Replace("-", String.Empty);
_clientId = Guid.NewGuid().ToString().Replace("-", string.Empty);
}
public TimeSpan InvisibilityTimeout { get; set; }
@@ -25,8 +25,7 @@ namespace Hangfire.Raven.Storage
public IEnumerable<string> QueueNames { get; set; }
public string ClientId
{
public string ClientId {
get { return _clientId; }
}
-15
View File
@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
-7
View File
@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Hangfire.Core" version="1.6.3" targetFramework="net45" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
<package id="RavenDB.Client" version="3.0.30115" targetFramework="net45" />
</packages>
+131
View File
@@ -0,0 +1,131 @@
{
"title": "Hangfire.Raven",
"version": "2.0.0",
"description": "RavenDB job storage for Hangfire",
"copyright": "Copyright @ 2016 Cady, LLC",
"authors": [
"Cady <contact@cady.io>"
],
"buildOptions": {
"allowUnsafe": true,
"debugType": "portable",
"preserveCompilationContext": true
},
"packOptions": {
"tags": [
"Hangfire",
"AspNet",
"MVC",
"OWIN",
"RavenDB",
"Long-Running",
"Background",
"Fire-And-Forget",
"Delayed",
"Recurring",
"Tasks",
"Jobs",
"Scheduler",
"Threading",
"Queues"
],
"iconUrl": "https://avatars2.githubusercontent.com/u/7880472?v=3&s=200",
"projectUrl": "https://github.com/cady-io/hangfire-ravendb",
"licenseUrl": "http://www.gnu.org/licenses/lgpl-3.0.html",
"owners": [
"Cady <contact@cady.io>"
],
"repository": {
"type": "git",
"url": "https://github.com/cady-io/hangfire-ravendb"
},
"summary": "RavenDB job storage for Hangfire"
},
"dependencies": {
"Hangfire.Core": "1.6.4",
"Newtonsoft.Json": "9.0.1"
},
"frameworks": {
"net45": {
"frameworkAssemblies": {
"System.Data": "4.0.0.0",
"System.Reflection": "4.0.0.0"
},
"dependencies": {
"RavenDB.Client": "3.5.0-rc-35169"
}
},
"net451": {
"dependencies": {
"Microsoft.Extensions.DependencyModel": "1.0.0",
"RavenDB.Client": "3.5.0-rc-35169",
"System.Data.Common": "4.1.0"
}
},
"net452": {
"dependencies": {
"Microsoft.Extensions.DependencyModel": "1.0.0",
"RavenDB.Client": "3.5.0-rc-35169",
"System.Data.Common": "4.1.0"
}
},
"net46": {
"dependencies": {
"Microsoft.Extensions.DependencyModel": "1.0.0",
"RavenDB.Client": "3.5.0-rc-35169",
"System.Data.Common": "4.1.0"
}
},
"net461": {
"dependencies": {
"Microsoft.Extensions.DependencyModel": "1.0.0",
"RavenDB.Client": "3.5.0-rc-35169",
"System.Data.Common": "4.1.0"
}
},
"dnx451": {
"dependencies": {
"Microsoft.Extensions.DependencyModel": "1.0.0",
"RavenDB.Client": "3.5.0-rc-35169",
"System.Data.Common": "4.1.0"
}
},
"dnx46": {
"dependencies": {
"Microsoft.Extensions.DependencyModel": "1.0.0",
"RavenDB.Client": "3.5.0-rc-35169",
"System.Data.Common": "4.1.0"
}
},
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"dnxcore50",
"portable-net45+win8"
],
"dependencies": {
"Microsoft.Extensions.DependencyModel": "1.0.0",
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"NETStandard.Library": "1.6.0",
"RavenDB.Client": "3.5.0-rc-35169",
"System.Data.Common": "4.1.0"
}
},
"netstandard1.6": {
"imports": [
"dotnet5.6",
"dnxcore50",
"portable-net45+win8"
],
"dependencies": {
"Microsoft.Extensions.DependencyModel": "1.0.0",
"NETStandard.Library": "1.6.0",
"RavenDB.Client": "3.5.0-rc-35169",
"System.Data.Common": "4.1.0"
}
}
}
}
File diff suppressed because it is too large Load Diff