하나의 인스턴스가있는 상태 비 저장 서비스 내에 WebApi 컨트롤러를 호스팅하고 있습니다. 서비스 인스턴스 (SF 런타임에서 생성 된 WebApiService 클래스의 인스턴스)는 멤버 필드로 일부 임시 상태를 유지하며 내부 (스레드로부터 안전한) 메서드를 통해 상태를 노출합니다. WebApi 컨트롤러는 해당 상태에 액세스하기 위해 메소드를 호출해야합니다.StatelessService 인스턴스에 액세스하는 WebApi 컨트롤러
WebApiService.cs:
-----------------
internal sealed class WebApiService : StatelessService
{
private int _state;
internal int GetState() { return this._state; }
ServiceController.cs:
---------------------
public class ServiceController : ApiController
{
public async Task<IHttpActionResult> GetStateAsync()
{
// Here I'd like to grab somehow the WebApiService instance
// and call its GetState internal method.
내 질문은 :
어떻게 컨트롤러는 WebApiService 인스턴스에 대한 참조를 얻을 수 있나요?
WebApiService 인스턴스를 정적 필드 (예 : WebAspiService 생성자)에 저장하는 것이 안전합니까?
그래서이 권리를 갖자. 당신은 국적이없는 서비스에서 상태를 구현하고 있습니까? –
예, 상태없는 서비스에서 일시적인 메모리 내 상태를 구현 중입니다! –