lith il y a 4 ans
Parent
commit
0f43a8e766
16 fichiers modifiés avec 58 ajouts et 16 suppressions
  1. 2 0
      dotnet/Library/Sers/Sers.Core/Sers.Core/Module/Message/ApiMessage.cs
  2. 3 0
      dotnet/Library/Sers/Sers.Core/Sers.Core/Module/PubSub/Controller/SubscriberController.cs
  3. 3 1
      dotnet/Library/Sers/Sers.Core/Sers.Core/Module/PubSub/EndpointManage.cs
  4. 2 0
      dotnet/Library/Sers/Sers.Core/Sers.Core/Module/PubSub/HotPlugSubscriber.cs
  5. 3 0
      dotnet/Library/Sers/Sers.Core/Sers.Core/Module/PubSub/MessageCenterService.cs
  6. 10 4
      dotnet/Library/Sers/Sers.Core/Sers.Core/Module/PubSub/MessageClient.cs
  7. 6 2
      dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/Base/ApiLoadBalancingMng_RESTful.cs
  8. 5 4
      dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/Base/Extensions/ApiNodeExtensions.cs
  9. 5 1
      dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/Base/Extensions/ServiceStationExtensions.cs
  10. 3 0
      dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/Base/Model/LoadBalancingForApiNode.cs
  11. 4 1
      dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/RateLimit/FixedWindow.cs
  12. 3 0
      dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/RateLimit/RateLimitMng.cs
  13. 2 0
      dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/Service/SersEvent/SersEventService.cs
  14. 2 0
      dotnet/ServiceCenter/Sers.ServiceCenter/Sers.ServiceCenter/ApiCenter/ApiCenterService.cs
  15. 2 1
      dotnet/ServiceCenter/Sers.ServiceCenter/Sers.ServiceCenter/Entity/ApiNode.cs
  16. 3 2
      dotnet/ServiceCenter/Sers.ServiceCenter/Sers.ServiceCenter/Entity/ServiceStation.cs

+ 2 - 0
dotnet/Library/Sers/Sers.Core/Sers.Core/Module/Message/ApiMessage.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.Runtime.CompilerServices;
 using Sers.Core.Module.Rpc;
 using Vit.Extensions;
 
@@ -41,6 +42,7 @@ namespace Sers.Core.Module.Message
             }
         }
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public void RpcContextData_OriData_Set(RpcContextData rpcData)
         {
             rpcContextData_OriData = rpcData.ToBytes().BytesToArraySegmentByte();

+ 3 - 0
dotnet/Library/Sers/Sers.Core/Sers.Core/Module/PubSub/Controller/SubscriberController.cs

@@ -1,6 +1,7 @@
 using Vit.Core.Module.Log;
 using System;
 using Vit.Extensions;
+using System.Runtime.CompilerServices;
 
 namespace Sers.Core.Module.PubSub.Controller
 {
@@ -14,6 +15,7 @@ namespace Sers.Core.Module.PubSub.Controller
         public string msgTitle { get; protected set; }
 
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public void OnGetMessage(ArraySegment<byte> msgBody)
         {
             T t;
@@ -40,6 +42,7 @@ namespace Sers.Core.Module.PubSub.Controller
         }
 
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public abstract void Handle(T msgBody);
 
       

+ 3 - 1
dotnet/Library/Sers/Sers.Core/Sers.Core/Module/PubSub/EndpointManage.cs

@@ -2,7 +2,7 @@
 using System;
 using System.Collections.Concurrent;
 using System.Threading.Tasks;
-
+using System.Runtime.CompilerServices;
 
 namespace Sers.Core.Module.PubSub
 {
@@ -23,6 +23,7 @@ namespace Sers.Core.Module.PubSub
         ConcurrentDictionary<string, ConcurrentDictionary<int, ISubscriber>> subscriberMap = new ConcurrentDictionary<string, ConcurrentDictionary<int, ISubscriber>>();
 
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         void Message_Consumer(string msgTitle, ArraySegment<byte> msgData)
         {
             if (!subscriberMap.TryGetValue(msgTitle, out var subscriberList)) return;
@@ -78,6 +79,7 @@ namespace Sers.Core.Module.PubSub
             }     
         }
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public void Message_Publish(string msgTitle, ArraySegment<byte> msgData)
         {
             MessageClient.Instance.Message_Publish(msgTitle, msgData);

+ 2 - 0
dotnet/Library/Sers/Sers.Core/Sers.Core/Module/PubSub/HotPlugSubscriber.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Runtime.CompilerServices;
 using Vit.Extensions;
 
 namespace Sers.Core.Module.PubSub
@@ -37,6 +38,7 @@ namespace Sers.Core.Module.PubSub
             
         }
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         void ISubscriber.OnGetMessage(ArraySegment<byte> msgBody)
         {
             OnGetMessage?.Invoke(msgBody);

+ 3 - 0
dotnet/Library/Sers/Sers.Core/Sers.Core/Module/PubSub/MessageCenterService.cs

@@ -6,6 +6,7 @@ using System.Linq;
 using Sers.Core.CL.MessageOrganize;
 using Vit.Core.Module.Log;
 using Sers.Core.Module.Message;
+using System.Runtime.CompilerServices;
 
 namespace Sers.Core.Module.PubSub
 {
@@ -23,6 +24,7 @@ namespace Sers.Core.Module.PubSub
             }
         }
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public void OnGetMessage(IOrganizeConnection  conn, ArraySegment<byte> messageData)
         {
             SersFile frame = new SersFile().Unpack(messageData);
@@ -65,6 +67,7 @@ namespace Sers.Core.Module.PubSub
         /// </summary>
         ConcurrentDictionary<string, ConcurrentDictionary<int, IOrganizeConnection >> subscriberMap = new ConcurrentDictionary<string, ConcurrentDictionary<int, IOrganizeConnection >>();
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         void Publish(string msgTitle,ArraySegment<byte> msgData)
         {
             if (!subscriberMap.TryGetValue(msgTitle, out var connList)) return;   

+ 10 - 4
dotnet/Library/Sers/Sers.Core/Sers.Core/Module/PubSub/MessageClient.cs

@@ -7,6 +7,7 @@ using Vit.Extensions;
 using System.Collections.Concurrent;
 using Sers.Core.CL.MessageOrganize;
 using Vit.Core.Util.Pipelines;
+using System.Runtime.CompilerServices;
 
 namespace Sers.Core.Module.PubSub
 {
@@ -14,8 +15,9 @@ namespace Sers.Core.Module.PubSub
     {
         public static readonly MessageClient Instance = new MessageClient();
 
-        
 
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public void OnGetMessage(IOrganizeConnection conn,ArraySegment<byte> messageData)
         {
             SersFile frame = new SersFile().Unpack(messageData);
@@ -72,8 +74,9 @@ namespace Sers.Core.Module.PubSub
  
 
         #region 延迟发送队列
-        readonly ConcurrentQueue<Vit.Core.Util.Pipelines.ByteData> msgFrameToSend = new ConcurrentQueue<Vit.Core.Util.Pipelines.ByteData>();       
-       
+        readonly ConcurrentQueue<Vit.Core.Util.Pipelines.ByteData> msgFrameToSend = new ConcurrentQueue<Vit.Core.Util.Pipelines.ByteData>();
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         void SendFrame(Vit.Core.Util.Pipelines.ByteData frame)
         {
             if (null == _OnSendMessage)
@@ -90,8 +93,9 @@ namespace Sers.Core.Module.PubSub
                
 
         internal Action<string, ArraySegment<byte>> Message_Consumer { get; set; }
-         
 
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public void Message_Publish(string msgTitle, ArraySegment<byte> msgData)
         {
             //publish,msgTitle,msgData 
@@ -127,12 +131,14 @@ namespace Sers.Core.Module.PubSub
 
         #region static 
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static void Publish(string msgTitle, object msgBody)
         {
             Instance.Message_Publish(msgTitle, msgBody.SerializeToArraySegmentByte());
         }
 
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static void Publish(string msgTitle, byte[] msgBody)
         {
             Instance.Message_Publish(msgTitle, msgBody.BytesToArraySegmentByte());

+ 6 - 2
dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/Base/ApiLoadBalancingMng_RESTful.cs

@@ -1,6 +1,7 @@
 using Sers.Core.Module.Api.RouteMap;
 using Sers.Core.Module.Rpc;
 using Sers.ServiceCenter.Entity;
+using System.Runtime.CompilerServices;
 using Vit.Extensions;
 
 namespace Sers.Gover.Base
@@ -15,6 +16,7 @@ namespace Sers.Gover.Base
         /// </summary>
         /// <param name="apiNode"></param>
         /// <returns></returns>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         static string GetHttpMethod(ApiNode apiNode)
         {
             var method = apiNode.apiDesc?.HttpMethodGet()?.ToUpper();
@@ -22,7 +24,7 @@ namespace Sers.Gover.Base
             return method;
         }
 
-         
+
 
         /// <summary>
         /// 通过负载均衡算法 获取可调用的ApiNode
@@ -30,6 +32,7 @@ namespace Sers.Gover.Base
         /// <param name="rpcData"></param>
         /// <param name="routeType"></param>
         /// <returns></returns>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public override ApiNode GetCurApiNodeByLoadBalancing(RpcContextData rpcData, out ERouteType routeType)
         {
             var method= rpcData.http.method?.ToUpper();
@@ -63,9 +66,10 @@ namespace Sers.Gover.Base
             return null;
         }
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         protected override string GetApiRoute(ApiNode apiNode)
         {
-            var route=  "/"+GetHttpMethod(apiNode) + apiNode.apiDesc.route;
+            var route = "/" + GetHttpMethod(apiNode) + apiNode.apiDesc.route;
 
             return route;
         }

+ 5 - 4
dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/Base/Extensions/ApiNodeExtensions.cs

@@ -1,4 +1,5 @@
 using System.Collections.Generic;
+using System.Runtime.CompilerServices;
 using Sers.Gover.Base;
 using Sers.Gover.Base.Model;
 using Sers.ServiceCenter.Entity;
@@ -8,7 +9,8 @@ namespace Vit.Extensions
     public static partial class ApiNodeExtensions
     {
 
-       
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static EServiceStationStatus  Status_Get(this ApiNode data)
         {
             return data?.GetDataByConvert<EServiceStationStatus?>("Status")?? EServiceStationStatus.暂停;
@@ -16,12 +18,11 @@ namespace Vit.Extensions
 
 
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static void Status_Set(this ApiNode data, EServiceStationStatus value)
         {
             data?.SetData("Status", value);
-        }
-
-      
+        }      
 
 
 

+ 5 - 1
dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/Base/Extensions/ServiceStationExtensions.cs

@@ -1,5 +1,6 @@
 using System.Collections.Generic;
 using System.Linq;
+using System.Runtime.CompilerServices;
 using Sers.Gover.Base.Model;
 using Sers.ServiceCenter.Entity;
 
@@ -8,11 +9,14 @@ namespace Vit.Extensions
     public static partial class ServiceStationExtensions
     {
 
-       
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static EServiceStationStatus? Status_Get(this ServiceStation data)
         {
             return data?.GetDataByConvert<EServiceStationStatus?>("Status");
         }
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static void Status_Set(this ServiceStation data, EServiceStationStatus value)
         {
             data?.SetData("Status", value);

+ 3 - 0
dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/Base/Model/LoadBalancingForApiNode.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.Runtime.CompilerServices;
 using System.Threading;
 using Sers.Core.Module.Api.ApiDesc;
 using Sers.ServiceCenter.Entity;
@@ -25,6 +26,8 @@ namespace Sers.Gover.Base.Model
        
 
         int curIndex = -1;
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public ApiNode GetCurApiNodeBalancing()
         {
             //TODO: 负载均衡的实现

+ 4 - 1
dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/RateLimit/FixedWindow.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Runtime.CompilerServices;
 using System.Threading;
 using Sers.Core.Module.Message;
 using Sers.Core.Module.Rpc;
@@ -45,10 +46,11 @@ namespace Sers.Gover.RateLimit
 
         private int reqCount = 0;
         private long timeStampStart=0;
-        private long timeStampEnd=0;       
+        private long timeStampEnd=0;
 
 
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public SsError BeforeLoadBalancing(RpcContextData rpcData, ApiMessage requestMessage)
         {
             //以_开始的系统节点不限流 
@@ -89,6 +91,7 @@ namespace Sers.Gover.RateLimit
             }
         }
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public SsError BeforeCallRemoteApi(RpcContextData rpcData, ApiMessage requestMessage, ApiNode apiNode)
         {
             return null;

+ 3 - 0
dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/RateLimit/RateLimitMng.cs

@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Concurrent;
 using System.Linq;
+using System.Runtime.CompilerServices;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 using Sers.Core.Module.Message;
@@ -96,6 +97,7 @@ namespace Sers.Gover.RateLimit
         /// <param name="rpcData"></param>
         /// <param name="requestMessage"></param>
         /// <returns></returns>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public SsError BeforeLoadBalancing(RpcContextData rpcData, ApiMessage requestMessage)
         {
             foreach (var rateLimit in limits)
@@ -115,6 +117,7 @@ namespace Sers.Gover.RateLimit
         /// <param name="requestMessage"></param>
         /// <param name="apiNode"></param>
         /// <returns></returns>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public SsError BeforeCallRemoteApi(RpcContextData rpcData, ApiMessage requestMessage,ApiNode apiNode)
         {
             foreach (var rateLimit in limits)

+ 2 - 0
dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/Service/SersEvent/SersEventService.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Runtime.CompilerServices;
 using Sers.Core.Module.PubSub;
 using Vit.Core.Module.Log;
 
@@ -16,6 +17,7 @@ namespace Sers.Gover.Service.SersEvent
         public const string Event_ServiceStation_Remove = "Remove";
 
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static void Publish(string eventName,object msgBody)
         {
             try

+ 2 - 0
dotnet/ServiceCenter/Sers.ServiceCenter/Sers.ServiceCenter/ApiCenter/ApiCenterService.cs

@@ -32,6 +32,8 @@ namespace Sers.ServiceCenter.ApiCenter
         [JsonIgnore]
         public Action<RpcContextData, ApiMessage> BeforeCallApi;
 
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public abstract void CallApiAsync(ApiMessage requestMessage, Object sender, Action<object, Vit.Core.Util.Pipelines.ByteData> callback);
 
 

+ 2 - 1
dotnet/ServiceCenter/Sers.ServiceCenter/Sers.ServiceCenter/Entity/ApiNode.cs

@@ -1,5 +1,5 @@
 using System;
-using System.Collections.Generic;
+using System.Runtime.CompilerServices;
 using Newtonsoft.Json;
 using Sers.Core.Module.Api.ApiDesc;
 using Sers.Core.Module.Counter;
@@ -34,6 +34,7 @@ namespace Sers.ServiceCenter.Entity
         #endregion
 
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public void CallApiAsync(RpcContextData rpcContextData, ApiMessage reqMessage, Object sender,  Action<object, Vit.Core.Util.Pipelines.ByteData> callback)
         {
             //count

+ 3 - 2
dotnet/ServiceCenter/Sers.ServiceCenter/Sers.ServiceCenter/Entity/ServiceStation.cs

@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Runtime.CompilerServices;
 using Newtonsoft.Json;
 using Sers.Core.CL.MessageOrganize;
 using Sers.Core.Module.Counter;
@@ -9,7 +10,6 @@ using Sers.Core.Module.Message;
 using Sers.Hardware.Env;
 using Sers.Hardware.Usage;
 using Vit.Core.Util.Extensible;
-using Vit.Core.Util.Pipelines;
 using Vit.Extensions;
 
 namespace Sers.ServiceCenter.Entity
@@ -97,7 +97,8 @@ namespace Sers.ServiceCenter.Entity
             return String.Join(",", stationNames); 
         }
 
-     
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public void SendRequestAsync(Object sender, ApiMessage apiReqMessage, Action<object, Vit.Core.Util.Pipelines.ByteData> callback)
         {
             connection.SendRequestAsync(sender,apiReqMessage.Package(), callback);