Skip to content

Commit

Permalink
优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
liuhll committed Aug 22, 2024
1 parent e6b6291 commit cb31061
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 17 deletions.
8 changes: 4 additions & 4 deletions framework/src/Silky.Core/IEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ TOptions GetOptions<TOptions>(string optionName)
where TOptions : class, new();


T Resolve<T>(IServiceScope scope = null) where T : class;
T Resolve<T>() where T : class;

object Resolve(Type type, IServiceScope scope = null);
object ResolveNamed(string name, Type type, IServiceScope scope = null);
object Resolve(Type type);
object ResolveNamed(string name, Type type);

object ResolveServiceInstance(string? serviceKey, Type serviceType);

T ResolveNamed<T>(string name,IServiceScope scope = null);
T ResolveNamed<T>(string name);

IEnumerable<T> ResolveAll<T>();

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

namespace Silky.Core.Runtime.Rpc
{
public class DefaultRpcContextAccessor : IRpcContextAccessor, IScopedDependency
public class DefaultRpcContextAccessor : IRpcContextAccessor, ISingletonDependency
{
private static AsyncLocal<RpcContextHolder> _rpcContextCurrent = new();

Expand Down
2 changes: 1 addition & 1 deletion framework/src/Silky.Core/Runtime/Rpc/RpcContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,10 @@ public IDictionary<string, string> GetResponseHeaders()

public void Reset()
{
EngineContext.DisposeUnmanagedObjects();
invokeAttachments.Clear();
resultAttachments.Clear();
transAttachments.Clear();
rpcContextThreadLocal.Value = null;
}
}
}
16 changes: 8 additions & 8 deletions framework/src/Silky.Core/SilkyEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,20 @@ void IEngine.ConfigureRequestPipeline(IApplicationBuilder application)
}
}

public T Resolve<T>(IServiceScope scope = null) where T : class
public T Resolve<T>() where T : class
{
return (T)Resolve(typeof(T), scope);
return (T)Resolve(typeof(T));
}

public object Resolve(Type type, IServiceScope scope = null)
public object Resolve(Type type)
{
var sp = GetServiceProvider(scope);
var sp = GetServiceProvider();
return sp?.GetService(type);
}

public object ResolveNamed(string name, Type type, IServiceScope scope = null)
public object ResolveNamed(string name, Type type)
{
var sp = GetServiceProvider(scope);
var sp = GetServiceProvider();
return sp?.GetAutofacRoot().ResolveNamed(name, type);
}

Expand All @@ -194,9 +194,9 @@ public object ResolveServiceInstance(string? serviceKey, Type serviceType)
return instance;
}

public T ResolveNamed<T>(string name, IServiceScope scope = null)
public T ResolveNamed<T>(string name)
{
return (T)ResolveNamed(name, typeof(T), scope);
return (T)ResolveNamed(name, typeof(T));
}

public IEnumerable<T> ResolveAll<T>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="nacos-sdk-csharp" Version="1.3.*" />
<PackageReference Include="nacos-sdk-csharp" Version="1.3.8" />
</ItemGroup>

</Project>
2 changes: 0 additions & 2 deletions framework/src/Silky.Rpc/RpcModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ await messageReceivedHandler.Handle(remoteInvokeMessage, ct,
await sender.SendMessageAsync(resultTransportMessage);
serverDiagnosticListener.TracingAfter(tracingTimestamp, message.Id,
remoteInvokeMessage.ServiceEntryId, result);
EngineContext.DisposeUnmanagedObjects();
}
finally
{
Expand Down

0 comments on commit cb31061

Please sign in to comment.