This repository has been archived by the owner on Feb 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Aggregated watcher hooks json config #11
- Loading branch information
Showing
14 changed files
with
344 additions
and
6 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
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
101 changes: 101 additions & 0 deletions
101
...arden.Spawn.Integrations.Console/ConsoleSpawnIntegrationAggregatedWatcherHooksResolver.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,101 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq.Expressions; | ||
using System.Threading.Tasks; | ||
using Warden.Spawn.Hooks; | ||
using Warden.Watchers; | ||
|
||
namespace Warden.Spawn.Integrations.Console | ||
{ | ||
public class ConsoleSpawnIntegrationAggregatedWatcherHooksResolver : IAggregatedWatcherHooksResolver | ||
{ | ||
private readonly ConsoleSpawnIntegrationConfiguration _integrationConfiguration; | ||
|
||
public ConsoleSpawnIntegrationAggregatedWatcherHooksResolver(ConsoleSpawnIntegrationConfiguration integrationConfiguration) | ||
{ | ||
_integrationConfiguration = integrationConfiguration; | ||
} | ||
|
||
public Expression<Action<IEnumerable<IWatcherCheck>>> OnStart() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Expression<Func<IEnumerable<IWatcherCheck>, Task>> OnStartAsync() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Expression<Action<IEnumerable<IWardenCheckResult>>> OnSuccess() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Expression<Func<IEnumerable<IWardenCheckResult>, Task>> OnSuccessAsync() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Expression<Action<IEnumerable<IWardenCheckResult>>> OnFirstSuccess() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Expression<Func<IEnumerable<IWardenCheckResult>, Task>> OnFirstSuccessAsync() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Expression<Action<IEnumerable<IWardenCheckResult>>> OnFailure() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Expression<Func<IEnumerable<IWardenCheckResult>, Task>> OnFailureAsync() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Expression<Action<IEnumerable<IWardenCheckResult>>> OnCompleted(object configuration) | ||
{ | ||
var config = configuration as ConsoleSpawnIntegrationHooksConfiguration; | ||
if (config == null) | ||
throw new InvalidOperationException(); | ||
|
||
var text = string.IsNullOrWhiteSpace(config.Text) ? _integrationConfiguration.DefaultText : config.Text; | ||
|
||
return x => System.Console.WriteLine(text); | ||
} | ||
|
||
public Expression<Func<IEnumerable<IWardenCheckResult>, Task>> OnCompletedAsync(object configuration) | ||
{ | ||
var config = configuration as ConsoleSpawnIntegrationHooksConfiguration; | ||
if (config == null) | ||
throw new InvalidOperationException(); | ||
|
||
var text = string.IsNullOrWhiteSpace(config.Text) ? _integrationConfiguration.DefaultText : config.Text; | ||
|
||
return x => Task.Factory.StartNew(() => System.Console.WriteLine(text)); | ||
} | ||
|
||
public Expression<Action<IEnumerable<Exception>>> OnError() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Expression<Func<IEnumerable<Exception>, Task>> OnErrorAsync() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Expression<Action<IEnumerable<Exception>>> OnFirstError() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Expression<Func<IEnumerable<Exception>, Task>> OnFirstErrorAsync() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
122 changes: 122 additions & 0 deletions
122
...s/Warden.Spawn.Integrations.SendGrid/SendGridIntegrationAggregatedWatcherHooksResolver.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,122 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Linq.Expressions; | ||
using System.Threading.Tasks; | ||
using Warden.Integrations.SendGrid; | ||
using Warden.Spawn.Hooks; | ||
using Warden.Watchers; | ||
|
||
namespace Warden.Spawn.Integrations.SendGrid | ||
{ | ||
public class SendGridIntegrationAggregatedWatcherHooksResolver : IAggregatedWatcherHooksResolver | ||
{ | ||
private readonly SendGridIntegration _integration; | ||
private readonly SendGridSpawnIntegrationConfiguration _integrationConfiguration; | ||
|
||
public SendGridIntegrationAggregatedWatcherHooksResolver(SendGridIntegration integration, | ||
SendGridSpawnIntegrationConfiguration integrationConfiguration) | ||
{ | ||
_integration = integration; | ||
_integrationConfiguration = integrationConfiguration; | ||
} | ||
|
||
public Expression<Action<IEnumerable<IWatcherCheck>>> OnStart() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Expression<Func<IEnumerable<IWatcherCheck>, Task>> OnStartAsync() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Expression<Action<IEnumerable<IWardenCheckResult>>> OnSuccess() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Expression<Func<IEnumerable<IWardenCheckResult>, Task>> OnSuccessAsync() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Expression<Action<IEnumerable<IWardenCheckResult>>> OnFirstSuccess() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Expression<Func<IEnumerable<IWardenCheckResult>, Task>> OnFirstSuccessAsync() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Expression<Action<IEnumerable<IWardenCheckResult>>> OnFailure() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Expression<Func<IEnumerable<IWardenCheckResult>, Task>> OnFailureAsync() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Expression<Action<IEnumerable<IWardenCheckResult>>> OnCompleted(object configuration) | ||
{ | ||
var config = configuration as SendGridSpawnIntegrationHooksConfiguration; | ||
if (config == null) | ||
throw new InvalidOperationException(); | ||
|
||
var subject = string.IsNullOrWhiteSpace(config.Subject) | ||
? _integrationConfiguration.DefaultSubject | ||
: config.Subject; | ||
var message = string.IsNullOrWhiteSpace(config.Message) | ||
? _integrationConfiguration.DefaultMessage | ||
: config.Message; | ||
var receivers = config.Receivers == null || !config.Receivers.Any() | ||
? _integrationConfiguration.DefaultReceivers | ||
: config.Receivers; | ||
|
||
return x => Task.Factory.StartNew(() => _integration.SendEmailAsync(subject, message, receivers.ToArray())); | ||
} | ||
|
||
public Expression<Func<IEnumerable<IWardenCheckResult>, Task>> OnCompletedAsync(object configuration) | ||
{ | ||
var config = configuration as SendGridSpawnIntegrationHooksConfiguration; | ||
if (config == null) | ||
throw new InvalidOperationException(); | ||
|
||
var subject = string.IsNullOrWhiteSpace(config.Subject) | ||
? _integrationConfiguration.DefaultSubject | ||
: config.Subject; | ||
var message = string.IsNullOrWhiteSpace(config.Message) | ||
? _integrationConfiguration.DefaultMessage | ||
: config.Message; | ||
var receivers = config.Receivers == null || !config.Receivers.Any() | ||
? _integrationConfiguration.DefaultReceivers | ||
: config.Receivers; | ||
|
||
return x => _integration.SendEmailAsync(subject, message, receivers.ToArray()); | ||
} | ||
|
||
public Expression<Action<IEnumerable<Exception>>> OnError() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Expression<Func<IEnumerable<Exception>, Task>> OnErrorAsync() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Expression<Action<IEnumerable<Exception>>> OnFirstError() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Expression<Func<IEnumerable<Exception>, Task>> OnFirstErrorAsync() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
Oops, something went wrong.