Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • Experiment/NewBuild
  • Hotfix/1796-projectDdos
  • Issue/1910-MigrationtoNET6.0
  • Issue/2309-docs
  • Product/1287-dotnet5Sharepoint
  • Product/407-net5migration
  • Sprint/2021-01
  • Sprint/2021-03
  • Sprint/2022-01
  • Topic/1226-configLibraryMigration
  • Topic/1334-dotnet5migration
  • dev
  • gitkeep
  • master
  • v1.0.0
  • v1.1.0
  • v1.2.0
  • v1.2.1
  • v1.3.0
  • v1.3.1
  • v1.4.0
  • v1.5.0
  • v1.6.0
  • v2.0.0
  • v2.1.0
  • v2.1.1
26 results

Target

Select target project
  • coscine/backend/libraries/configuration
1 result
Select Git revision
  • Experiment/NewBuild
  • Hotfix/1796-projectDdos
  • Issue/1910-MigrationtoNET6.0
  • Issue/2309-docs
  • Product/1287-dotnet5Sharepoint
  • Product/407-net5migration
  • Sprint/2021-01
  • Sprint/2021-03
  • Sprint/2022-01
  • Topic/1226-configLibraryMigration
  • Topic/1334-dotnet5migration
  • dev
  • gitkeep
  • master
  • v1.0.0
  • v1.1.0
  • v1.2.0
  • v1.2.1
  • v1.3.0
  • v1.3.1
  • v1.4.0
  • v1.5.0
  • v1.6.0
  • v2.0.0
  • v2.1.0
  • v2.1.1
26 results
Show changes
Commits on Source (6)
......@@ -40,6 +40,7 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
......
......@@ -17,7 +17,6 @@ namespace Coscine.Configuration.Tests
[Test]
public void ConsulConfigurationAsyncTest()
{
DefaultTester.ConfigurationAsyncTest(_configuration);
}
......
......@@ -9,8 +9,8 @@ using System.Reflection;
[assembly: AssemblyDescription("Configuration.Tests is a part of the CoScInE group.")]
[assembly: AssemblyCompany("IT Center, RWTH Aachen University")]
[assembly: AssemblyProduct("Configuration.Tests")]
[assembly: AssemblyVersion("1.3.1.0")]
[assembly: AssemblyFileVersion("1.3.1.0")]
[assembly: AssemblyInformationalVersion("1.3.1.0")]
[assembly: AssemblyVersion("1.4.0.0")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: AssemblyInformationalVersion("1.4.0.0")]
[assembly: AssemblyCopyright("2019 IT Center, RWTH Aachen University")]
......@@ -31,7 +31,7 @@ namespace Coscine.Configuration
Value = value
};
using (var client = new ConsulClient())
using (var client = new ConsulClient(Configuration))
{
var putAttempt = await client.KV.Put(putPair);
......@@ -39,9 +39,27 @@ namespace Coscine.Configuration
}
}
public bool PutAndWait(string key, byte[] value)
{
var putPair = new KVPair(key)
{
Value = value
};
using (var client = new ConsulClient(Configuration))
{
var putAttempt = client.KV.Put(putPair);
putAttempt.Wait();
return putAttempt.Result.Response;
}
}
public async Task<byte[]> GetAsync(string key)
{
using (var client = new ConsulClient())
using (var client = new ConsulClient(Configuration))
{
var getPair = await client.KV.Get(key);
......@@ -57,6 +75,26 @@ namespace Coscine.Configuration
}
}
public byte[] GetAndWait(string key)
{
using (var client = new ConsulClient(Configuration))
{
var getPair = client.KV.Get(key);
getPair.Wait();
if (getPair.Result.Response?.Value != null)
{
return getPair.Result.Response.Value;
}
else
{
return null;
}
}
}
public async Task<string> GetStringAsync(string key)
{
var value = await GetAsync(key);
......@@ -70,24 +108,57 @@ namespace Coscine.Configuration
}
}
public string GetStringAndWait(string key)
{
var value = GetAndWait(key);
if (value != null)
{
return Encoding.UTF8.GetString(value, 0, value.Length);
}
else
{
return null;
}
}
public async Task<string[]> KeysAsync(string prefix)
{
using (var client = new ConsulClient())
using (var client = new ConsulClient(Configuration))
{
var keys = await client.KV.Keys(prefix);
return keys.Response;
}
}
public string[] KeysAndWait(string prefix)
{
using (var client = new ConsulClient(Configuration))
{
var keys = client.KV.Keys(prefix);
keys.Wait();
return keys.Result.Response;
}
}
public async Task<bool> DeleteAsync(string key)
{
using (var client = new ConsulClient())
using (var client = new ConsulClient(Configuration))
{
var deleteRequest = await client.KV.Delete(key);
return deleteRequest.Response;
}
}
public bool DeleteAndWait(string key)
{
using (var client = new ConsulClient(Configuration))
{
var deleteRequest = client.KV.Delete(key);
deleteRequest.Wait();
return deleteRequest.Result.Response;
}
}
public bool Put(string key, string value)
{
return PutAsync(key, value).GetAwaiter().GetResult();
......
......@@ -34,6 +34,11 @@ namespace Coscine.Configuration
return true;
}
public bool DeleteAndWait(string key)
{
return Delete(key);
}
public Task<bool> DeleteAsync(string key)
{
return Task.Factory.StartNew(() =>
......@@ -55,6 +60,11 @@ namespace Coscine.Configuration
}
}
public byte[] GetAndWait(string key)
{
return Get(key);
}
public Task<byte[]> GetAsync(string key)
{
return Task.Factory.StartNew(() =>
......@@ -75,6 +85,11 @@ namespace Coscine.Configuration
}
}
public string GetStringAndWait(string key)
{
return GetString(key);
}
public Task<string> GetStringAsync(string key)
{
return Task.Factory.StartNew(() =>
......@@ -97,6 +112,11 @@ namespace Coscine.Configuration
return filteredKeys.ToArray();
}
public string[] KeysAndWait(string prefix)
{
return Keys(prefix);
}
public Task<string[]> KeysAsync(string prefix)
{
return Task.Factory.StartNew(() =>
......@@ -123,6 +143,11 @@ namespace Coscine.Configuration
return Put(key, new System.Text.ASCIIEncoding().GetString(value));
}
public bool PutAndWait(string key, byte[] value)
{
return Put(key, value);
}
public Task<bool> PutAsync(string key, string value)
{
return Task.Factory.StartNew(() =>
......
......@@ -8,14 +8,24 @@ namespace Coscine.Configuration
Task<bool> PutAsync(string key, byte[] value);
bool PutAndWait(string key, byte[] value);
Task<byte[]> GetAsync(string key);
byte[] GetAndWait(string key);
Task<string> GetStringAsync(string key);
string GetStringAndWait(string key);
Task<string[]> KeysAsync(string prefix);
string[] KeysAndWait(string prefix);
Task<bool> DeleteAsync(string key);
bool DeleteAndWait(string key);
bool Put(string key, string value);
bool Put(string key, byte[] value);
......
......@@ -9,8 +9,8 @@ using System.Reflection;
[assembly: AssemblyDescription("Configuration is a part of the CoScInE group.")]
[assembly: AssemblyCompany("IT Center, RWTH Aachen University")]
[assembly: AssemblyProduct("Configuration")]
[assembly: AssemblyVersion("1.3.1.0")]
[assembly: AssemblyFileVersion("1.3.1.0")]
[assembly: AssemblyInformationalVersion("1.3.1.0")]
[assembly: AssemblyVersion("1.4.0.0")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: AssemblyInformationalVersion("1.4.0.0")]
[assembly: AssemblyCopyright("2019 IT Center, RWTH Aachen University")]