Skip to content

Instantly share code, notes, and snippets.

@steff-mueller
Created June 11, 2012 16:35
Show Gist options
  • Save steff-mueller/2911124 to your computer and use it in GitHub Desktop.
Save steff-mueller/2911124 to your computer and use it in GitHub Desktop.
ServiceStack | Async refactor?
public IAsyncService<TReq>
{
	Task<object> ExecuteAsync<TReq>(TReq req);
}
public class ServiceBase<TReq> : IAsyncService<TReq>
{
	...
	public Task<object> RunAsync(TReq req) { ... }
	...
}
[Route("/test", IsAsync = true)]
public class Test
{
}

public class TestService : ServiceBase<Test>
{
	public async override Task<object> RunAsync(TReq req)
	{
		var asyncIOResult1 = await IO.GetFileAsync("...");
		var result = await Analyzer.AnalyzeFileAsync(asyncIOResult1);
		return new TestResponse { Result = result };
	}
}

Do the same thing with REST services, ie IAsyncPostService etc

Same consistent style for IOneWayService - [Route("/test", IsOneWay = true)].

BTW we should also create IOneWayPostService etc (REST services)

Consistent == intuitive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment