Skip to content

Commit

Permalink
Code clean and travis fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Drawaes committed Mar 10, 2017
1 parent 37fef21 commit 67f3185
Show file tree
Hide file tree
Showing 31 changed files with 54 additions and 141 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ script:
# Start Consul
- ./consul agent -server -bootstrap-expect 1 -data-dir /tmp/consul -advertise=127.0.0.1 &
# Build sample
- dotnet test test/CondenserTests
- dotnet test test/Condenser.Tests.Integration
- dotnet test test/CondenserTests/CondenserTests.csproj
- dotnet test test/Condenser.Tests.Integration/Condenser.Tests.Integration.csproj
1 change: 0 additions & 1 deletion src/CondenserDotNet.Client/ITtlCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ public interface ITtlCheck
Task<bool> ReportPassingAsync();
Task<bool> ReportWarningAsync();
Task<bool> ReportFailAsync();

HealthCheck HealthCheck { get; }
}
}
5 changes: 1 addition & 4 deletions src/CondenserDotNet.Client/Leadership/LeaderRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ public class LeaderRegistry : ILeaderRegistry
private readonly IServiceManager _serviceManager;
private readonly Dictionary<string, LeaderWatcher> _leaderWatchers = new Dictionary<string, LeaderWatcher>(StringComparer.OrdinalIgnoreCase);

public LeaderRegistry(IServiceManager serviceManager)
{
_serviceManager = serviceManager;
}
public LeaderRegistry(IServiceManager serviceManager) => _serviceManager = serviceManager;

public ILeaderWatcher GetLeaderWatcher(string keyForLeadership)
{
Expand Down
5 changes: 1 addition & 4 deletions src/CondenserDotNet.Client/ServiceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ protected void Dispose(bool disposing)
}
}

~ServiceManager()
{
Dispose(false);
}
~ServiceManager() => Dispose(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ public NoServiceInstanceFoundException(string serviceName, Exception innerExcept
}

public string ServiceName { get;}

public override string ToString()
{
return Message;
}
public override string ToString() => Message;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ public class ServiceBasedHttpHandler : HttpClientHandler
{
private readonly IServiceRegistry _serviceRegistry;

public ServiceBasedHttpHandler(IServiceRegistry serviceRegistry)
{
_serviceRegistry = serviceRegistry;
}

public ServiceBasedHttpHandler(IServiceRegistry serviceRegistry) => _serviceRegistry = serviceRegistry;

protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
var currentUri = request.RequestUri;
Expand Down
5 changes: 1 addition & 4 deletions src/CondenserDotNet.Client/Services/ServiceRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ public void Dispose()
}
}

public ServiceBasedHttpHandler GetHttpHandler()
{
return new ServiceBasedHttpHandler(this);
}
public ServiceBasedHttpHandler GetHttpHandler() => new ServiceBasedHttpHandler(this);
}
}
5 changes: 1 addition & 4 deletions src/CondenserDotNet.Client/Services/ServiceWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ private async Task WatcherLoop(HttpClient client)
}
}

public void Dispose()
{
_cancelationToken.Cancel();
}
public void Dispose() => _cancelationToken.Cancel();
}
}
17 changes: 3 additions & 14 deletions src/CondenserDotNet.Configuration/ConfigurationRegistryProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,9 @@ public ConfigurationRegistryProvider(IConfigurationRegistry configurationRegistr
_configurationRegistry.AddWatchOnEntireConfig(Load);
}

public override bool TryGet(string key, out string value)
{
return _configurationRegistry.TryGetValue(key, out value);
}

public override void Set(string key, string value)
{
_configurationRegistry.SetKeyAsync(key, value).Wait();
}

public override void Load()
{
OnReload();
}
public override bool TryGet(string key, out string value) => _configurationRegistry.TryGetValue(key, out value);
public override void Set(string key, string value) => _configurationRegistry.SetKeyAsync(key, value).Wait();
public override void Load() => OnReload();

public override IEnumerable<string> GetChildKeys(IEnumerable<string> earlierKeys, string parentPath)
{
Expand Down
10 changes: 0 additions & 10 deletions src/CondenserDotNet.Configuration/GlobalSuppressions.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace CondenserDotNet.Configuration
{
public interface IConfigurationRegistry:IDisposable
public interface IConfigurationRegistry : IDisposable
{
string this[string key] { get; }
Task<bool> AddStaticKeyPathAsync(string keyPath);
Expand Down
2 changes: 1 addition & 1 deletion src/CondenserDotNet.Core/AsyncManualResetEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class AsyncManualResetEvent<T> where T : IEquatable<T>
{
private volatile TaskCompletionSource<T> m_tcs = new TaskCompletionSource<T>();

public Task<T> WaitAsync() { return m_tcs.Task; }
public Task<T> WaitAsync() => m_tcs.Task;

public void Set(T result)
{
Expand Down
5 changes: 1 addition & 4 deletions src/CondenserDotNet.Core/Consul/KeyValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ public class KeyValue
public string Session { get; set; }
public bool IsDerivedKey { get; set; }

public string ValueFromBase64()
{
return Encoding.UTF8.GetString(Convert.FromBase64String(Value));
}
public string ValueFromBase64() => Encoding.UTF8.GetString(Convert.FromBase64String(Value));
}
}
8 changes: 4 additions & 4 deletions src/CondenserDotNet.Core/DataContracts/InformationCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
{
public class InformationCheck
{
public string CheckID { get;set;}
public string Name { get;set;}
public string Status { get;set;}
public string Output { get;set;}
public string CheckID { get; set; }
public string Name { get; set; }
public string Status { get; set; }
public string Output { get; set; }
}
}
4 changes: 2 additions & 2 deletions src/CondenserDotNet.Core/DataContracts/InformationNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public class InformationNode
{
public string Node { get;set;}
public string Address { get;set;}
public string Node { get; set; }
public string Address { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{
public class InformationServiceSet
{
public InformationNode Node { get;set;}
public InformationService Service { get;set;}
public InformationCheck[] Checks { get;set;}
public InformationNode Node { get; set; }
public InformationService Service { get; set; }
public InformationCheck[] Checks { get; set; }
}
}
8 changes: 6 additions & 2 deletions src/CondenserDotNet.Core/HttpUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ public static class HttpUtils

static HttpUtils()
{
JsonSettings = new JsonSerializerSettings { ContractResolver = new DefaultContractResolver(), NullValueHandling = NullValueHandling.Ignore };
JsonSettings = new JsonSerializerSettings
{
ContractResolver = new DefaultContractResolver(),
NullValueHandling = NullValueHandling.Ignore
};
}

public static StringContent GetStringContent<T>(T objectForContent)
Expand All @@ -45,7 +49,7 @@ public static async Task<T> GetAsync<T>(this HttpClient client, string uri)

public static StringContent GetStringContent(string stringForContent)
{
if(stringForContent == null)
if (stringForContent == null)
{
return null;
}
Expand Down
5 changes: 1 addition & 4 deletions src/CondenserDotNet.Core/Routing/DefaultRouting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ public DefaultRouting(IEnumerable<IRoutingStrategy<T>> strategy,
}

public IRoutingStrategy<T> Default { get; private set; }
public void SetDefault(IRoutingStrategy<T> strategy)
{
Default = strategy;
}
public void SetDefault(IRoutingStrategy<T> strategy) => Default = strategy;
}
}
1 change: 0 additions & 1 deletion src/CondenserDotNet.Core/Routing/IDefaultRouting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
public interface IDefaultRouting<T>
{
IRoutingStrategy<T> Default { get; }

void SetDefault(IRoutingStrategy<T> strateg);
}
}
1 change: 0 additions & 1 deletion src/CondenserDotNet.Core/Routing/IRoutingStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ public interface IRoutingStrategy<T>
{
T RouteTo(List<T> services);
string Name { get; }

}
}
3 changes: 2 additions & 1 deletion src/CondenserDotNet.Core/Routing/RandomRouteNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ public class RandomRoutingStrategy<T> : IRoutingStrategy<T>
public T RouteTo(List<T> instances)
{
if ((instances != null) && (instances.Count > 0))
{
return instances[RandHelper.Next(0, instances.Count)];

}
return default(T);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ public T RouteTo(List<T> instances)
if (instances?.Count > 0)
{
var index = Interlocked.Increment(ref _index);

return instances[index%instances.Count];
return instances[index % instances.Count];
}
return default(T);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="$(AspNetVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(AspNetVersion)" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="$(AspNetVersion)" />
<PackageReference Include="System.Threading.Tasks" Version="4.3.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,12 @@ public BackToBackStream(byte firstByte, Stream innerStream)
}

public override bool CanRead => _innerStream.CanRead;

public override bool CanSeek => _innerStream.CanSeek;

public override bool CanWrite => _innerStream.CanWrite;

public override long Length => _innerStream.Length;

public override long Position { get => _innerStream.Position; set => _innerStream.Position = value; }

public override void Flush()
{
_innerStream.Flush();
}
public override void Flush() => _innerStream.Flush();

public override int Read(byte[] buffer, int offset, int count)
{
Expand All @@ -48,20 +41,10 @@ public override int Read(byte[] buffer, int offset, int count)
return _innerStream.Read(buffer, offset, count) + returnCount;
}

public override long Seek(long offset, SeekOrigin origin)
{
throw new NotImplementedException();
}

public override void SetLength(long value)
{
throw new NotImplementedException();
}

public override void Write(byte[] buffer, int offset, int count)
{
_innerStream.Write(buffer, offset, count);
}
public override long Seek(long offset, SeekOrigin origin) => throw new NotImplementedException();
public override void SetLength(long value) => throw new NotImplementedException();
public override void Write(byte[] buffer, int offset, int count) => _innerStream.Write(buffer, offset, count);
public override Task FlushAsync(CancellationToken cancellationToken) => _innerStream.FlushAsync(cancellationToken);

public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
{
Expand All @@ -76,11 +59,6 @@ public override Task<int> ReadAsync(byte[] buffer, int offset, int count, Cancel
return _innerStream.ReadAsync(buffer, offset, count, cancellationToken);
}

public override Task FlushAsync(CancellationToken cancellationToken)
{
return _innerStream.FlushAsync(cancellationToken);
}

public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
{
return _innerStream.WriteAsync(buffer, offset, count, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.Kestrel.Filter;
using Microsoft.AspNetCore.Server.Kestrel;

namespace CondenserDotNet.Middleware.ProtocolSwitcher
{
Expand Down Expand Up @@ -28,7 +29,7 @@ public async Task OnConnectionAsync(ConnectionFilterContext context)

if (firstByte[0] == 0x16)
{
context.Address = Microsoft.AspNetCore.Server.Kestrel.ServerAddress.FromUrl($"https://{context.Address.Host}:{context.Address.Port}");
context.Address = ServerAddress.FromUrl($"https://{context.Address.Host}:{context.Address.Port}");
}
var connection = context.Connection;
var back2Back = new BackToBackStream(firstByte[0], connection);
Expand Down
11 changes: 1 addition & 10 deletions src/CondenserDotNet.Middleware/TrailingHeaders/ChunkingStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,12 @@ public ChunkingStream()
}

public override bool CanRead => throw new NotImplementedException();

public override bool CanSeek => throw new NotImplementedException();

public override bool CanWrite => true;

public override long Length => throw new NotImplementedException();

public override long Position { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

public Stream InnerStream { get => _innerStream; set => _innerStream = value; }

public override void Flush()
{
_innerStream.Flush();
}
public override void Flush() => _innerStream.Flush();

public override Task FlushAsync(CancellationToken cancellationToken)
{
Expand Down
Loading

0 comments on commit 67f3185

Please sign in to comment.