Multiple builds for multiple services

I am not sure how to organize my project. I have a solution with several services. eg. ShoppingCart, UrlShortener. However, AppHostBase can only accept one assembly. I am also interested in separating issues and future use cases if it separates the front-end assemblies from the ServiceModel assembly. Should my domain model know about the interface (maybe client requirements?), Then at least the namespace will not be filled with unnecessary DTO, etc.

So, now I see this as such, each of which is separate assemblies / projects:

MyApp.RestServices.ShoppingCartService.Interface MyApp.RestServices.ShoppingCartService.ServiceModel MyApp.RestServices.UrlShorteningService.Interface MyApp.RestServices.UrlShorteningService.ServiceModel 

I am confused by the fact that when registering AppHost you can configure only one assembly.

 public AppHost() : base("MyApp REST services", typeof(MyApp.RestServices.ShoppingCartService.Interface).Assembly) {} 

In my case, I want separate assemblies for different services, for example. Short Position Service, Shopping Basket Service. I do not want all of them to be in the same project.

 public AppHost() : base("MyApp REST services", new[]{ typeof(MyApp.RestServices.ShoppingCartService.Interface).Assembly, typeof(MyApp.RestServices.Interface.ShoppingCartService).Assembly} ) {} 

I am really brand new, so I can lose a lot, but I want it to be right for a long time when I keep learning.

+4
source share
1 answer

ServiceStack accepts params Assembly[] in the AppHostBase constructor, i.e.

 protected AppHostBase( string serviceName, params Assembly[] assembliesWithServices) {...} 

That means you can tell ServiceStack to scan multiple assemblies with

 public AppHost() : base("MyApp REST services", typeof(MyApp.RestServices.ShoppingCartService.Interface).Assembly, typeof(MyApp.RestServices.Interface.ShoppingCartService).Assembly) {...} 
+3
source

Source: https://habr.com/ru/post/1444634/


All Articles