Service Fabric Remoting to WebApi



我们正在运行一些无状态可靠服务,并且使用反向代理(http://localhost:19081/{app}/{svc}/bleh(的服务到服务通信时遇到性能问题。 在不涉及细节的情况下,我们正在研究使用远程处理,如下所述:https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-reliable-services-communication-remoting

但是,我很难弄清楚如何在服务类型类中公开 API 方法,因为它们目前存在于我们的控制器中。控制器通过依赖注入获得所需的存储库实例等,所以我正在研究如何在没有某种冗余实例或循环依赖的情况下完成这项工作。

我坐在这里盯着"PersonService.cs"上的这个:

internal sealed class PersonService: StatelessService, IPersonService
{
        public PersonService(StatelessServiceContext context)
            : base(context)
        { }
        ...
        public PersonResponse GetPersonFromDb()
        {
          //lost here :(
        }

我的控制器工作正常,有:

public PersonController(IPersonRepository personRepository)
{
  _personRepository = personRepository;
}
   ...
public IActionResult GetPerson()
{
    var personResponse = _dbRepository.GetPerson();
    return new ObjectResult(personResponse);
}

D:

您不能将存储库传递给您的服务,类似于这样吗?

public PersonService(StatelessServiceContext context, IPersonRepository personRepository)
            : base(context)
{
   _personRepository = personRepository;
}
public PersonResponse GetPersonFromDb()
{
    var personResponse = _personRepository.GetPerson();
    return personResponse;
}

最新更新