forked from NuGet/NuGetGallery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Got a backup job working! Now on to Async Completion management
- Loading branch information
1 parent
3a720ed
commit 8ce9577
Showing
28 changed files
with
636 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Data; | ||
using System.Data.SqlClient; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Dapper | ||
{ | ||
public static class DapperExtensions | ||
{ | ||
public static Task ExecuteAsync(this SqlConnection connection, string sql) | ||
{ | ||
SqlCommand cmd = connection.CreateCommand(); | ||
cmd.CommandText = sql; | ||
cmd.CommandType = CommandType.Text; | ||
return cmd.ExecuteNonQueryAsync(); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/NuGetGallery.Backend/Helpers/DateTimeOffsetExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace System | ||
{ | ||
public static class DateTimeOffsetExtensions | ||
{ | ||
public static bool IsOlderThan(this DateTimeOffset self, TimeSpan age) | ||
{ | ||
return (DateTimeOffset.UtcNow - self) > age; | ||
} | ||
|
||
public static bool IsYoungerThan(this DateTimeOffset self, TimeSpan age) | ||
{ | ||
return (DateTimeOffset.UtcNow - self) < age; | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/NuGetGallery.Backend/Helpers/SqlConnectionStringBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace System.Data.SqlClient | ||
{ | ||
public static class SqlConnectionStringBuilderExtensions | ||
{ | ||
public static SqlConnectionStringBuilder ChangeDatabase(this SqlConnectionStringBuilder self, string newDatabaseName) | ||
{ | ||
return new SqlConnectionStringBuilder(self.ConnectionString) | ||
{ | ||
InitialCatalog = newDatabaseName | ||
}; | ||
} | ||
|
||
public static Task<SqlConnection> ConnectTo(this SqlConnectionStringBuilder self) | ||
{ | ||
return ConnectTo(self.ConnectionString); | ||
} | ||
|
||
public static Task<SqlConnection> ConnectToMaster(this SqlConnectionStringBuilder self) | ||
{ | ||
return ConnectTo(self, "master"); | ||
} | ||
|
||
public static Task<SqlConnection> ConnectTo(this SqlConnectionStringBuilder self, string databaseName) | ||
{ | ||
var newConnectionString = new SqlConnectionStringBuilder(self.ConnectionString) | ||
{ | ||
InitialCatalog = databaseName | ||
}; | ||
return ConnectTo(newConnectionString.ConnectionString); | ||
} | ||
|
||
private static async Task<SqlConnection> ConnectTo(string connection) | ||
{ | ||
var c = new SqlConnection(connection); | ||
await c.OpenAsync().ConfigureAwait(continueOnCapturedContext: false); | ||
return c; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/NuGetGallery.Backend/Infrastructure/JobInvocationContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using NuGetGallery.Backend.Monitoring; | ||
using NuGetGallery.Jobs; | ||
|
||
namespace NuGetGallery.Backend | ||
{ | ||
public class JobInvocationContext | ||
{ | ||
public JobInvocation Invocation { get; private set; } | ||
public BackendConfiguration Config { get; private set; } | ||
public BackendMonitoringHub Monitor { get; private set; } | ||
|
||
public JobInvocationContext(JobInvocation invocation, BackendConfiguration config, BackendMonitoringHub monitor) | ||
{ | ||
Invocation = invocation; | ||
Config = config; | ||
Monitor = monitor; | ||
} | ||
} | ||
} |
Oops, something went wrong.