Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nara/remove queing #1023

Merged
merged 11 commits into from
Jul 30, 2020
116 changes: 29 additions & 87 deletions src/Microsoft.InsightsGenerator/Workflow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,105 +12,47 @@ namespace Microsoft.InsightsGenerator
{
public class Workflow
{
private readonly ConcurrentQueue<object> _siggenQueue = new ConcurrentQueue<object>();

private readonly ConcurrentQueue<DataArray> _rulesQueue = new ConcurrentQueue<DataArray>();
public async Task<string> ProcessInputData(DataArray rulesData,
CancellationToken cancellationToken = new CancellationToken())
{
// added cancellationToken just in case for future
cancellationToken.ThrowIfCancellationRequested();

private static Workflow _instance;
//Get the signature result
SignatureGenerator siggen = new SignatureGenerator(rulesData);

// Lock synchronization object
private static readonly object syncLock = new object();
string insights = null;


public static Workflow Instance(CancellationToken cancellationToken = new CancellationToken())
{
// Uses lazy initialization. thread safe for now.
if (_instance == null)
await Task.Run(() =>
{
lock (syncLock)
try
{

if (_instance == null)
DataTransformer transformer = new DataTransformer();
transformer.Transform(rulesData);
SignatureGeneratorResult result = siggen.Learn();
// call the rules engine processor
if (result?.Insights == null)
{
_instance = new Workflow();
_instance.ProcessInputData(cancellationToken).ConfigureAwait(false);
Console.WriteLine("Failure in generating insights, Input not recognized!");
}
else
{
insights = RulesEngine.FindMatchedTemplate(result.Insights, rulesData);
Console.WriteLine(
$"Good News! Insights generator has provided you the chart text: \n{insights}\n");
}
}
}

return _instance;
}

public void IngestSiggen(object input)
{
if (_instance == null)
{
throw new ApplicationException("Please initialize the singleton class using Workflow.getInstance() and call _instance.IngestSiggen");
}

if (input == null)
{
throw new ArgumentException("Unable to ingest Siggen. Input object is null.");
}
_instance._siggenQueue.Enqueue(input);
}

public void IngestRules(DataArray input)
{
if (_instance == null)
{
throw new ApplicationException("Please initialize the singleton class using Workflow.getInstance() and call _instance.IngestRules");
}

if (input == null)
{
throw new ArgumentException(" Unable to ingest Rules. Input object is null.");
}
_instance._rulesQueue.Enqueue(input);
}

private async Task ProcessInputData(CancellationToken cancellationToken)
{

cancellationToken.ThrowIfCancellationRequested();

//while (!cancellationToken.IsCancellationRequested)
//{
// bool siggenInput = _instance._siggenQueue.TryDequeue(out object siggen);

// if (siggenInput && siggen != null)
// {
// // call the siggen processor
// }
// else
// {
// await Task.Delay(TimeSpan.FromMinutes(1), cancellationToken).ConfigureAwait(false);
// }
//}

bool rulesInput = _instance._rulesQueue.TryDequeue(out DataArray rulesData);

if (rulesInput && rulesData != null)
{
//Get the signature result
SignatureGenerator siggen = new SignatureGenerator(rulesData);
SignatureGeneratorResult result = siggen.Learn();
// call the rules engine processor
if (result?.Insights == null)
{
Console.WriteLine("Failure in generating insights, Input not recognized!");
}
else
catch (Exception ex)
{
string insights = RulesEngine.FindMatchedTemplate(result.Insights, rulesData);
Console.WriteLine($"Good News! Insights generator has provided you the chart text: \n{insights}\n");
Console.WriteLine(ex.ToString());
throw;
}

}
else
{
//await Task.Delay(TimeSpan.FromMinutes(1), cancellationToken).ConfigureAwait(false);
}

}, cancellationToken);

return insights;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2321,13 +2321,13 @@
</trans-unit>
<trans-unit id="ExportBacpacTaskName">
<source>Export bacpac</source>
<target state="translated">BACPAC exportieren</target>
<target state="translated">BACPAC-Datei exportieren</target>
<note>
</note>
</trans-unit>
<trans-unit id="ImportBacpacTaskName">
<source>Import bacpac</source>
<target state="translated">BACPAC importieren</target>
<target state="translated">BACPAC-Datei importieren</target>
<note>
</note>
</trans-unit>
Expand Down Expand Up @@ -2391,6 +2391,36 @@
<note>.
Parameters: 0 - filePath (string) </note>
</trans-unit>
<trans-unit id="ConnectionServiceConnStringInvalidColumnEncryptionSetting">
<source>Invalid value '{0}' for ComlumEncryption. Valid values are 'Enabled' and 'Disabled'.</source>
<target state="translated">Ungültiger Wert "{0}" für ColumnEncryption. Gültige Werte sind "Enabled" und "Disabled".</target>
<note>.
Parameters: 0 - columnEncryptionSetting (string) </note>
</trans-unit>
<trans-unit id="ConnectionServiceConnStringInvalidEnclaveAttestationProtocol">
<source>Invalid value '{0}' for EnclaveAttestationProtocol. Valid values are 'AAS' and 'HGS'.</source>
<target state="translated">Ungültiger Wert "{0}" für EnclaveAttestationProtocol. Gültige Werte sind "AAS" und "HGS".</target>
<note>.
Parameters: 0 - enclaveAttestationProtocol (string) </note>
</trans-unit>
<trans-unit id="ConnectionServiceConnStringInvalidAlwaysEncryptedOptionCombination">
<source>The Attestation Protocol and Enclave Attestation URL requires Always Encrypted to be set to Enabled.</source>
<target state="translated">Für das Nachweisprotokoll und die Enclave-Nachweis-URL muss Always Encrypted auf "Enabled" festgelegt sein.</target>
<note>
</note>
</trans-unit>
<trans-unit id="SqlCmdExitOnError">
<source>An error was encountered during execution of batch. Exiting.</source>
<target state="translated">Fehler bei der Batchausführung. Der Vorgang wird beendet.</target>
<note>
</note>
</trans-unit>
<trans-unit id="SqlCmdUnsupportedToken">
<source>Encountered unsupported token {0}</source>
<target state="translated">Es wurde ein nicht unterstütztes Token "{0}" gefunden.</target>
<note>
</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -2391,6 +2391,36 @@
<note>.
Parameters: 0 - filePath (string) </note>
</trans-unit>
<trans-unit id="ConnectionServiceConnStringInvalidColumnEncryptionSetting">
<source>Invalid value '{0}' for ComlumEncryption. Valid values are 'Enabled' and 'Disabled'.</source>
<target state="translated">El valor "{0}" no es válido para ComlumEncryption. Los valores válidos son "Enabled" y "Disabled".</target>
<note>.
Parameters: 0 - columnEncryptionSetting (string) </note>
</trans-unit>
<trans-unit id="ConnectionServiceConnStringInvalidEnclaveAttestationProtocol">
<source>Invalid value '{0}' for EnclaveAttestationProtocol. Valid values are 'AAS' and 'HGS'.</source>
<target state="translated">El valor "{0}" no es válido para EnclaveAttestationProtocol. Los valores válidos son "AAS" y "HGS".</target>
<note>.
Parameters: 0 - enclaveAttestationProtocol (string) </note>
</trans-unit>
<trans-unit id="ConnectionServiceConnStringInvalidAlwaysEncryptedOptionCombination">
<source>The Attestation Protocol and Enclave Attestation URL requires Always Encrypted to be set to Enabled.</source>
<target state="translated">El protocolo de atestación y la dirección URL de atestación de enclave requieren que Always Encrypted esté habilitado.</target>
<note>
</note>
</trans-unit>
<trans-unit id="SqlCmdExitOnError">
<source>An error was encountered during execution of batch. Exiting.</source>
<target state="translated">Error durante la ejecución del lote. Saliendo.</target>
<note>
</note>
</trans-unit>
<trans-unit id="SqlCmdUnsupportedToken">
<source>Encountered unsupported token {0}</source>
<target state="translated">Se ha encontrado un token no admitido {0}</target>
<note>
</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -2391,6 +2391,36 @@
<note>.
Parameters: 0 - filePath (string) </note>
</trans-unit>
<trans-unit id="ConnectionServiceConnStringInvalidColumnEncryptionSetting">
<source>Invalid value '{0}' for ComlumEncryption. Valid values are 'Enabled' and 'Disabled'.</source>
<target state="translated">Valeur « {0} » non valide pour ComlumEncryption. Les valeurs valides sont « Enabled » et « Disabled ».</target>
<note>.
Parameters: 0 - columnEncryptionSetting (string) </note>
</trans-unit>
<trans-unit id="ConnectionServiceConnStringInvalidEnclaveAttestationProtocol">
<source>Invalid value '{0}' for EnclaveAttestationProtocol. Valid values are 'AAS' and 'HGS'.</source>
<target state="translated">Valeur « {0} » non valide pour EnclaveAttestationProtocol. Les valeurs valides sont « AAS » et « HGS ».</target>
<note>.
Parameters: 0 - enclaveAttestationProtocol (string) </note>
</trans-unit>
<trans-unit id="ConnectionServiceConnStringInvalidAlwaysEncryptedOptionCombination">
<source>The Attestation Protocol and Enclave Attestation URL requires Always Encrypted to be set to Enabled.</source>
<target state="translated">Le protocole d'attestation et l'URL d'attestation d'enclave exigent l'activation d'Always Encrypted.</target>
<note>
</note>
</trans-unit>
<trans-unit id="SqlCmdExitOnError">
<source>An error was encountered during execution of batch. Exiting.</source>
<target state="translated">Une erreur s'est produite durant l'exécution du lot. Fermeture en cours.</target>
<note>
</note>
</trans-unit>
<trans-unit id="SqlCmdUnsupportedToken">
<source>Encountered unsupported token {0}</source>
<target state="translated">Jeton non pris en charge détecté ({0})</target>
<note>
</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -2391,6 +2391,36 @@
<note>.
Parameters: 0 - filePath (string) </note>
</trans-unit>
<trans-unit id="ConnectionServiceConnStringInvalidColumnEncryptionSetting">
<source>Invalid value '{0}' for ComlumEncryption. Valid values are 'Enabled' and 'Disabled'.</source>
<target state="translated">Il valore '{0}' non è valido per ComlumEncryption. I valori validi sono 'Enabled' e 'Disabled'.</target>
<note>.
Parameters: 0 - columnEncryptionSetting (string) </note>
</trans-unit>
<trans-unit id="ConnectionServiceConnStringInvalidEnclaveAttestationProtocol">
<source>Invalid value '{0}' for EnclaveAttestationProtocol. Valid values are 'AAS' and 'HGS'.</source>
<target state="translated">Il valore '{0}' non è valido per EnclaveAttestationProtocol. I valori validi sono 'AAS' e 'HGS'.</target>
<note>.
Parameters: 0 - enclaveAttestationProtocol (string) </note>
</trans-unit>
<trans-unit id="ConnectionServiceConnStringInvalidAlwaysEncryptedOptionCombination">
<source>The Attestation Protocol and Enclave Attestation URL requires Always Encrypted to be set to Enabled.</source>
<target state="translated">Il protocollo di attestazione e l'URL di attestazione dell'enclave richiedono che Always Encrypted sia impostato su Abilitato.</target>
<note>
</note>
</trans-unit>
<trans-unit id="SqlCmdExitOnError">
<source>An error was encountered during execution of batch. Exiting.</source>
<target state="translated">Si è verificato un errore durante l'esecuzione del batch. Chiusura in corso.</target>
<note>
</note>
</trans-unit>
<trans-unit id="SqlCmdUnsupportedToken">
<source>Encountered unsupported token {0}</source>
<target state="translated">È stato rilevato il token {0} non supportato</target>
<note>
</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -2391,6 +2391,36 @@
<note>.
Parameters: 0 - filePath (string) </note>
</trans-unit>
<trans-unit id="ConnectionServiceConnStringInvalidColumnEncryptionSetting">
<source>Invalid value '{0}' for ComlumEncryption. Valid values are 'Enabled' and 'Disabled'.</source>
<target state="translated">ComlumEncryption の値 '{0}' が無効です。有効な値は 'Enabled' と 'Disabled' です。</target>
<note>.
Parameters: 0 - columnEncryptionSetting (string) </note>
</trans-unit>
<trans-unit id="ConnectionServiceConnStringInvalidEnclaveAttestationProtocol">
<source>Invalid value '{0}' for EnclaveAttestationProtocol. Valid values are 'AAS' and 'HGS'.</source>
<target state="translated">EnclaveAttestationProtocol の値 '{0}' が無効です。有効な値は、'AAS' と 'HGS' です。</target>
<note>.
Parameters: 0 - enclaveAttestationProtocol (string) </note>
</trans-unit>
<trans-unit id="ConnectionServiceConnStringInvalidAlwaysEncryptedOptionCombination">
<source>The Attestation Protocol and Enclave Attestation URL requires Always Encrypted to be set to Enabled.</source>
<target state="translated">構成証明プロトコルおよびエンクレーブ構成証明の URL では、Always Encrypted を Enabled に設定することが必要です。</target>
<note>
</note>
</trans-unit>
<trans-unit id="SqlCmdExitOnError">
<source>An error was encountered during execution of batch. Exiting.</source>
<target state="translated">バッチの実行中にエラーが発生しました。終了します。</target>
<note>
</note>
</trans-unit>
<trans-unit id="SqlCmdUnsupportedToken">
<source>Encountered unsupported token {0}</source>
<target state="translated">サポートされていないトークン {0} が見つかりました</target>
<note>
</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -1898,7 +1898,7 @@
</trans-unit>
<trans-unit id="EditDataValueTooLarge">
<source>Value {0} is too large to fit in column of type {1}</source>
<target state="translated">값 {0}이 너무 커서 {1} 유형의 열에 맞지 않습니다.</target>
<target state="translated">값 {0}이(가) 너무 커서 {1} 유형의 열에 맞지 않습니다.</target>
<note>.
Parameters: 0 - value (string), 1 - columnType (string) </note>
</trans-unit>
Expand Down Expand Up @@ -2391,6 +2391,36 @@
<note>.
Parameters: 0 - filePath (string) </note>
</trans-unit>
<trans-unit id="ConnectionServiceConnStringInvalidColumnEncryptionSetting">
<source>Invalid value '{0}' for ComlumEncryption. Valid values are 'Enabled' and 'Disabled'.</source>
<target state="translated">ComlumEncryption에 대한 '{0}' 값이 잘못되었습니다. 유효한 값은 'Enabled' 및 'Disabled'입니다.</target>
<note>.
Parameters: 0 - columnEncryptionSetting (string) </note>
</trans-unit>
<trans-unit id="ConnectionServiceConnStringInvalidEnclaveAttestationProtocol">
<source>Invalid value '{0}' for EnclaveAttestationProtocol. Valid values are 'AAS' and 'HGS'.</source>
<target state="translated">EnclaveAttestationProtocol에 대한 '{0}' 값이 잘못되었습니다. 유효한 값은 'AAS' 및 'HGS'입니다.</target>
<note>.
Parameters: 0 - enclaveAttestationProtocol (string) </note>
</trans-unit>
<trans-unit id="ConnectionServiceConnStringInvalidAlwaysEncryptedOptionCombination">
<source>The Attestation Protocol and Enclave Attestation URL requires Always Encrypted to be set to Enabled.</source>
<target state="translated">증명 프로토콜 및 enclave 증명 URL을 사용하려면 Always Encrypted를 Enabled(사용)로 설정해야 합니다.</target>
<note>
</note>
</trans-unit>
<trans-unit id="SqlCmdExitOnError">
<source>An error was encountered during execution of batch. Exiting.</source>
<target state="translated">일괄 처리를 실행하는 동안 오류가 발생하여 종료합니다.</target>
<note>
</note>
</trans-unit>
<trans-unit id="SqlCmdUnsupportedToken">
<source>Encountered unsupported token {0}</source>
<target state="translated">지원되지 않는 {0} 토큰이 발생했습니다.</target>
<note>
</note>
</trans-unit>
</body>
</file>
</xliff>
Loading