dotnet / orleans

Cloud Native application framework for .NET
https://docs.microsoft.com/dotnet/orleans
MIT License
10.07k stars 2.03k forks source link

Can you add an example of using aop #7142

Closed ioer2008 closed 3 years ago

ioer2008 commented 3 years ago

我想在Orleans的服务端的ProductService的GetById方法添加一个aop,并使用redis根据key是否存在来返回redis里面的值,还是返回数据库中的值,但是使用autofac或者AspectCore,都无法成功实现aop,所以想请你们官方能否添加一个使用aop的实例?

I want to add an aop to the GetById method of ProductService on the server side of Orleans, and use redis to return the value in redis or in the database based on the existence of key, but using autofac or AspectCore can not successfully implement aop, so I would like to ask you whether you can add an instance that uses aop?

hankir commented 3 years ago

Try incoming call filter. https://dotnet.github.io/orleans/docs/grains/interceptors.html But maybe it should be two grains for GetId - RedisIdGrain and DBIdGrain. Grain with GetId route call to needed grain

ReubenBond commented 3 years ago

Interceptors are a good way to implement AOP, in my opinion.

Are you using some kind of AOP framework like PostSharp, @ioer2008, eg to rewrite method calls? If so, that should still work with Orleans: you would make it rewrite your grain class' method.