From f89940b7f2e8196179dcf8d396dd54a506a62cf4 Mon Sep 17 00:00:00 2001 From: yangxiaodong Date: Wed, 24 May 2017 18:21:12 +0800 Subject: [PATCH] delete unuserd project. --- .../Cap.Consistency.Server.csproj | 43 ------ .../ConsistencyServer.cs | 63 -------- .../ConsistencyServerOptions.cs | 53 ------- .../IConsistencyServer.cs | 9 -- .../IConsistencyTrace.cs | 46 ------ src/Cap.Consistency.Server/IConsumer.cs | 20 --- .../Infrastructure/ConsistencyTrace.cs | 145 ------------------ .../Properties/AssemblyInfo.cs | 25 --- 8 files changed, 404 deletions(-) delete mode 100644 src/Cap.Consistency.Server/Cap.Consistency.Server.csproj delete mode 100644 src/Cap.Consistency.Server/ConsistencyServer.cs delete mode 100644 src/Cap.Consistency.Server/ConsistencyServerOptions.cs delete mode 100644 src/Cap.Consistency.Server/IConsistencyServer.cs delete mode 100644 src/Cap.Consistency.Server/IConsistencyTrace.cs delete mode 100644 src/Cap.Consistency.Server/IConsumer.cs delete mode 100644 src/Cap.Consistency.Server/Internal/Infrastructure/ConsistencyTrace.cs delete mode 100644 src/Cap.Consistency.Server/Properties/AssemblyInfo.cs diff --git a/src/Cap.Consistency.Server/Cap.Consistency.Server.csproj b/src/Cap.Consistency.Server/Cap.Consistency.Server.csproj deleted file mode 100644 index f5f73da..0000000 --- a/src/Cap.Consistency.Server/Cap.Consistency.Server.csproj +++ /dev/null @@ -1,43 +0,0 @@ - - - - netstandard1.6 - portable - Cap.Consistency.Server - Cap.Consistency.Server - 1.6.1 - $(PackageTargetFallback);dnxcore50 - false - false - false - false - false - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Cap.Consistency.Server/ConsistencyServer.cs b/src/Cap.Consistency.Server/ConsistencyServer.cs deleted file mode 100644 index b3d7f13..0000000 --- a/src/Cap.Consistency.Server/ConsistencyServer.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; -using System.Text; - -namespace Cap.Consistency.Server -{ - public class ConsistencyServer : IConsistencyServer - { - private Stack _disposables; - private readonly IApplicationLifetime _applicationLifetime; - private readonly ILogger _logger; - private readonly IConsumer _consumer; - - public ConsistencyServer(IOptions options, ILoggerFactory loggerFactory) - { - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - if (loggerFactory == null) - { - throw new ArgumentNullException(nameof(loggerFactory)); - } - - Options = options.Value ?? new ConsistencyServerOptions(); - - _logger = loggerFactory.CreateLogger(typeof(ConsistencyServer).GetTypeInfo().Namespace); - _consumer = Options.ApplicationServices.GetService(); - } - - public ConsistencyServerOptions Options { get; } - - - public void Run() { - //配置消费者组 - //var config = new Config() { GroupId = "example-csharp-consumer" }; - //using (var consumer = new EventConsumer(config, "127.0.0.1:9092")) { - - // //注册一个事件 - // consumer.OnMessage += (obj, msg) => - // { - // string text = Encoding.UTF8.GetString(msg.Payload, 0, msg.Payload.Length); - // Console.WriteLine($"Topic: {msg.Topic} Partition: {msg.Partition} Offset: {msg.Offset} {text}"); - // }; - - // //订阅一个或者多个Topic - // consumer.Subscribe(new[] { "testtopic" }); - - // //启动 - // consumer.Start(); - - // _logger.LogInformation("Started consumer..."); - - //} - } - } -} \ No newline at end of file diff --git a/src/Cap.Consistency.Server/ConsistencyServerOptions.cs b/src/Cap.Consistency.Server/ConsistencyServerOptions.cs deleted file mode 100644 index 8835694..0000000 --- a/src/Cap.Consistency.Server/ConsistencyServerOptions.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; - -namespace Cap.Consistency.Server -{ - public class ConsistencyServerOptions - { - /// - /// Enables the Consistency Server options callback to resolve and use services registered by the application during startup. - /// Typically initialized by . - /// - public IServiceProvider ApplicationServices { get; set; } - - /// - /// The amount of time after the server begins shutting down before connections will be forcefully closed. - /// Kestrel will wait for the duration of the timeout for any ongoing request processing to complete before - /// terminating the connection. No new connections or requests will be accepted during this time. - /// - /// - /// Defaults to 5 seconds. - /// - public TimeSpan ShutdownTimeout { get; set; } = TimeSpan.FromSeconds(5); - - /// - /// The number of libuv I/O threads used to process requests. - /// - /// - /// Defaults to half of rounded down and clamped between 1 and 16. - /// - public int ThreadCount { get; set; } = ProcessorThreadCount; - - private static int ProcessorThreadCount { - get { - // Actual core count would be a better number - // rather than logical cores which includes hyper-threaded cores. - // Divide by 2 for hyper-threading, and good defaults (still need threads to do webserving). - var threadCount = Environment.ProcessorCount >> 1; - - if (threadCount < 1) { - // Ensure shifted value is at least one - return 1; - } - - if (threadCount > 16) { - // Receive Side Scaling RSS Processor count currently maxes out at 16 - // would be better to check the NIC's current hardware queues; but xplat... - return 16; - } - - return threadCount; - } - } - } -} \ No newline at end of file diff --git a/src/Cap.Consistency.Server/IConsistencyServer.cs b/src/Cap.Consistency.Server/IConsistencyServer.cs deleted file mode 100644 index 4762c38..0000000 --- a/src/Cap.Consistency.Server/IConsistencyServer.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Cap.Consistency.Server -{ - public interface IConsistencyServer - { - ConsistencyServerOptions Options { get; } - - void Run(); - } -} \ No newline at end of file diff --git a/src/Cap.Consistency.Server/IConsistencyTrace.cs b/src/Cap.Consistency.Server/IConsistencyTrace.cs deleted file mode 100644 index 7103ac3..0000000 --- a/src/Cap.Consistency.Server/IConsistencyTrace.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using Microsoft.Extensions.Logging; - -namespace Cap.Consistency.Server -{ - public interface IConsistencyTrace : ILogger - { - void ConnectionStart(string connectionId); - - void ConnectionStop(string connectionId); - - void ConnectionRead(string connectionId, int count); - - void ConnectionPause(string connectionId); - - void ConnectionResume(string connectionId); - - void ConnectionReadFin(string connectionId); - - void ConnectionWriteFin(string connectionId); - - void ConnectionWroteFin(string connectionId, int status); - - void ConnectionKeepAlive(string connectionId); - - void ConnectionDisconnect(string connectionId); - - void ConnectionWrite(string connectionId, int count); - - void ConnectionWriteCallback(string connectionId, int status); - - void ConnectionError(string connectionId, Exception ex); - - void ConnectionReset(string connectionId); - - void RequestProcessingError(string connectionId, Exception ex); - - void ConnectionDisconnectedWrite(string connectionId, int count, Exception ex); - - void ConnectionHeadResponseBodyWrite(string connectionId, long count); - - void NotAllConnectionsClosedGracefully(); - - void ApplicationError(string connectionId, Exception ex); - } -} \ No newline at end of file diff --git a/src/Cap.Consistency.Server/IConsumer.cs b/src/Cap.Consistency.Server/IConsumer.cs deleted file mode 100644 index 4737859..0000000 --- a/src/Cap.Consistency.Server/IConsumer.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using Microsoft.AspNetCore.Hosting; - -namespace Cap.Consistency.Server -{ - public interface IConsumer : IDisposable - { - void Start(); - - void Start(int count); - - void Stop(); - - IConsistencyTrace Log { get; set; } - - ConsistencyServerOptions ServerOptions { get; set; } - - IApplicationLifetime AppLifetime { get; set; } - } -} \ No newline at end of file diff --git a/src/Cap.Consistency.Server/Internal/Infrastructure/ConsistencyTrace.cs b/src/Cap.Consistency.Server/Internal/Infrastructure/ConsistencyTrace.cs deleted file mode 100644 index cf88bc2..0000000 --- a/src/Cap.Consistency.Server/Internal/Infrastructure/ConsistencyTrace.cs +++ /dev/null @@ -1,145 +0,0 @@ -using System; -using Microsoft.Extensions.Logging; - -namespace Cap.Consistency.Server.Internal.Infrastructure -{ - /// - /// Summary description for KestrelTrace - /// - public class ConsistencyTrace : IConsistencyTrace - { - private static readonly Action _connectionStart; - private static readonly Action _connectionStop; - private static readonly Action _connectionPause; - private static readonly Action _connectionResume; - private static readonly Action _connectionReadFin; - private static readonly Action _connectionWriteFin; - private static readonly Action _connectionWroteFin; - private static readonly Action _connectionKeepAlive; - private static readonly Action _connectionDisconnect; - private static readonly Action _applicationError; - private static readonly Action _connectionError; - private static readonly Action _connectionDisconnectedWrite; - private static readonly Action _connectionHeadResponseBodyWrite; - private static readonly Action _notAllConnectionsClosedGracefully; - private static readonly Action _connectionReset; - private static readonly Action _requestProcessingError; - - protected readonly ILogger _logger; - - static ConsistencyTrace() { - _connectionStart = LoggerMessage.Define(LogLevel.Debug, 1, @"Connection id ""{ConnectionId}"" started."); - _connectionStop = LoggerMessage.Define(LogLevel.Debug, 2, @"Connection id ""{ConnectionId}"" stopped."); - // ConnectionRead: Reserved: 3 - _connectionPause = LoggerMessage.Define(LogLevel.Debug, 4, @"Connection id ""{ConnectionId}"" paused."); - _connectionResume = LoggerMessage.Define(LogLevel.Debug, 5, @"Connection id ""{ConnectionId}"" resumed."); - _connectionReadFin = LoggerMessage.Define(LogLevel.Debug, 6, @"Connection id ""{ConnectionId}"" received FIN."); - _connectionWriteFin = LoggerMessage.Define(LogLevel.Debug, 7, @"Connection id ""{ConnectionId}"" sending FIN."); - _connectionWroteFin = LoggerMessage.Define(LogLevel.Debug, 8, @"Connection id ""{ConnectionId}"" sent FIN with status ""{Status}""."); - _connectionKeepAlive = LoggerMessage.Define(LogLevel.Debug, 9, @"Connection id ""{ConnectionId}"" completed keep alive response."); - _connectionDisconnect = LoggerMessage.Define(LogLevel.Debug, 10, @"Connection id ""{ConnectionId}"" disconnecting."); - // ConnectionWrite: Reserved: 11 - // ConnectionWriteCallback: Reserved: 12 - _applicationError = LoggerMessage.Define(LogLevel.Error, 13, @"Connection id ""{ConnectionId}"": An unhandled exception was thrown by the application."); - _connectionError = LoggerMessage.Define(LogLevel.Information, 14, @"Connection id ""{ConnectionId}"" communication error."); - _connectionDisconnectedWrite = LoggerMessage.Define(LogLevel.Debug, 15, @"Connection id ""{ConnectionId}"" write of ""{count}"" bytes to disconnected client."); - _notAllConnectionsClosedGracefully = LoggerMessage.Define(LogLevel.Debug, 16, "Some connections failed to close gracefully during server shutdown."); - _connectionHeadResponseBodyWrite = LoggerMessage.Define(LogLevel.Debug, 18, @"Connection id ""{ConnectionId}"" write of ""{count}"" body bytes to non-body HEAD response."); - _connectionReset = LoggerMessage.Define(LogLevel.Debug, 19, @"Connection id ""{ConnectionId}"" reset."); - _requestProcessingError = LoggerMessage.Define(LogLevel.Information, 20, @"Connection id ""{ConnectionId}"" request processing ended abnormally."); - } - - public ConsistencyTrace(ILogger logger) { - _logger = logger; - } - - public virtual void ConnectionStart(string connectionId) { - _connectionStart(_logger, connectionId, null); - } - - public virtual void ConnectionStop(string connectionId) { - _connectionStop(_logger, connectionId, null); - } - - public virtual void ConnectionRead(string connectionId, int count) { - } - - public virtual void ConnectionPause(string connectionId) { - _connectionPause(_logger, connectionId, null); - } - - public virtual void ConnectionResume(string connectionId) { - _connectionResume(_logger, connectionId, null); - } - - public virtual void ConnectionReadFin(string connectionId) { - _connectionReadFin(_logger, connectionId, null); - } - - public virtual void ConnectionWriteFin(string connectionId) { - _connectionWriteFin(_logger, connectionId, null); - } - - public virtual void ConnectionWroteFin(string connectionId, int status) { - _connectionWroteFin(_logger, connectionId, status, null); - } - - public virtual void ConnectionKeepAlive(string connectionId) { - _connectionKeepAlive(_logger, connectionId, null); - } - - public virtual void ConnectionDisconnect(string connectionId) { - _connectionDisconnect(_logger, connectionId, null); - } - - public virtual void ConnectionWrite(string connectionId, int count) { - // Don't log for now since this could be *too* verbose. - // Reserved: Event ID 11 - } - - public virtual void ConnectionWriteCallback(string connectionId, int status) { - // Don't log for now since this could be *too* verbose. - // Reserved: Event ID 12 - } - - public virtual void ApplicationError(string connectionId, Exception ex) { - _applicationError(_logger, connectionId, ex); - } - - public virtual void ConnectionError(string connectionId, Exception ex) { - _connectionError(_logger, connectionId, ex); - } - - public virtual void ConnectionDisconnectedWrite(string connectionId, int count, Exception ex) { - _connectionDisconnectedWrite(_logger, connectionId, count, ex); - } - - public virtual void ConnectionHeadResponseBodyWrite(string connectionId, long count) { - _connectionHeadResponseBodyWrite(_logger, connectionId, count, null); - } - - public virtual void NotAllConnectionsClosedGracefully() { - _notAllConnectionsClosedGracefully(_logger, null); - } - - public virtual void ConnectionReset(string connectionId) { - _connectionReset(_logger, connectionId, null); - } - - public virtual void RequestProcessingError(string connectionId, Exception ex) { - _requestProcessingError(_logger, connectionId, ex); - } - - public virtual void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) { - _logger.Log(logLevel, eventId, state, exception, formatter); - } - - public virtual bool IsEnabled(LogLevel logLevel) { - return _logger.IsEnabled(logLevel); - } - - public virtual IDisposable BeginScope(TState state) { - return _logger.BeginScope(state); - } - } -} \ No newline at end of file diff --git a/src/Cap.Consistency.Server/Properties/AssemblyInfo.cs b/src/Cap.Consistency.Server/Properties/AssemblyInfo.cs deleted file mode 100644 index 48b41ba..0000000 --- a/src/Cap.Consistency.Server/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("Cap.Consistency.Server")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Cap.Consistency.Server")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly: Guid("55CF2C48-D390-40CF-8AD9-FA39F90E9217")] \ No newline at end of file