forked from ravendb/ravendb
-
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.
- Loading branch information
1 parent
7adfcf9
commit c4f9395
Showing
18 changed files
with
456 additions
and
5 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/Raven.Client/Documents/Operations/ETL/Queue/AwsSqsConnectionSettings.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 @@ | ||
namespace Raven.Client.Documents.Operations.ETL.Queue; | ||
|
||
public sealed class AwsSqsConnectionSettings | ||
{ | ||
public Basic Basic { get; set; } | ||
|
||
//public Passwordless Passwordless { get; set; } | ||
|
||
public bool IsValidConnection() { return true; } // TODO djordje: implement | ||
} | ||
|
||
public class Basic | ||
{ | ||
public string AccessKey { get; set; } | ||
|
||
public string SecretKey { get; set; } | ||
|
||
public bool IsValid() | ||
{ | ||
return string.IsNullOrWhiteSpace(AccessKey) == false && | ||
string.IsNullOrWhiteSpace(AccessKey) == false; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -5,5 +5,6 @@ public enum QueueBrokerType | |
None, | ||
Kafka, | ||
RabbitMq, | ||
AzureQueueStorage | ||
AzureQueueStorage, | ||
AwsSqs | ||
} |
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
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
52 changes: 52 additions & 0 deletions
52
src/Raven.Server/Documents/ETL/Providers/Queue/AwsSqs/AwsSqsDocumentTransformer.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,52 @@ | ||
using Jint.Runtime.Interop; | ||
using Raven.Client.Documents.Operations.ETL; | ||
using Raven.Client.Documents.Operations.ETL.Queue; | ||
using Raven.Server.Documents.ETL.Providers.Queue.AzureQueueStorage; | ||
using Raven.Server.Documents.Patch; | ||
using Raven.Server.ServerWide.Context; | ||
|
||
namespace Raven.Server.Documents.ETL.Providers.Queue.AwsSqs; | ||
|
||
public sealed class AwsSqsDocumentTransformer<T> : QueueDocumentTransformer<T, AzureQueueStorageItem> | ||
where T : QueueItem | ||
{ | ||
public AwsSqsDocumentTransformer(Transformation transformation, DocumentDatabase database, | ||
DocumentsOperationContext context, QueueEtlConfiguration config) : base(transformation, database, context, | ||
config) | ||
{ | ||
} | ||
|
||
protected override void LoadToFunction(string queueName, ScriptRunnerResult document) | ||
{ | ||
LoadToFunction(queueName, document, null); | ||
} | ||
|
||
protected override void LoadToFunction(string queueName, ScriptRunnerResult document, CloudEventAttributes attributes) | ||
{ | ||
if (queueName == null) | ||
ThrowLoadParameterIsMandatory(nameof(queueName)); | ||
|
||
var result = document.TranslateToObject(Context); | ||
|
||
var queue = GetOrAdd(queueName); | ||
|
||
queue.Items.Add(new AzureQueueStorageItem(Current) { TransformationResult = result, Attributes = attributes }); | ||
} | ||
|
||
public override void Initialize(bool debugMode) | ||
{ | ||
base.Initialize(debugMode); | ||
|
||
DocumentScript.ScriptEngine.SetValue(Transformation.LoadTo, | ||
new ClrFunction(DocumentScript.ScriptEngine, Transformation.LoadTo, | ||
LoadToFunctionTranslatorWithAttributes)); | ||
|
||
foreach (var queueName in LoadToDestinations) | ||
{ | ||
var name = Transformation.LoadTo + queueName; | ||
|
||
DocumentScript.ScriptEngine.SetValue(name, new ClrFunction(DocumentScript.ScriptEngine, name, | ||
(self, args) => LoadToFunctionTranslatorWithAttributes(queueName, args))); | ||
} | ||
} | ||
} |
Oops, something went wrong.