D-ASYNC CloudSharp is an extension to C# language that introduces new paradigms of service-oriented cloud programming. The new syntax removes the need to use or to create a framework for service APIs, inter-service communication, workflows, and state management.
The basic concepts define a serivce and its contract, most common communication primitives: query, command, event, event handler.
// A service API contract that is transpiled into an interface.servicecontract IUserService
{queryList<User> GetActiveUsers();commandvoid Register(stringname,stringemail);commandbool SuspendUser(stringuserId);eventEventHandler<User> UserRegistered;}// A service implementation that is transpiled into a class.serviceUserService: IUserService
{commandvoid Register(stringname,stringemail){varuser=newUser(name,email);// .....// Publish an event.publishUserRegistered(this,user);}}serviceRewardService{publicRewardService(IUserService userService){// Subscribe to an event of another service.subscribeOnUserRegistered to userService.UserRegistered;}// An event handler.handlerOnUserRegistered(objectsender,Useruser){// .....}}serviceOrderService{commandProcessOrder(Orderorder){// The variable is saved as a part of the execution state.persistedGuid transactionId =Guid.NewGuid();// Save execution state of this method when invoke the command.followProcessPayment(order,transactionId);try{followReserveItems(order);}catch(OutOfStockException){// Use saved transaction ID to guarantee idempotency.followCancelPayment(transactionId);throw;}followShipItems(order);}commandProcessPayment(Orderorder,GuidtransactionId){ .....}commandCancelPayment(GuidtransactionId){ .....}commandReserveItems(Orderorder){ .....}commandShipItems(Orderorder){ .....}}The ability to describe higher level concepts using the syntax of a programming language itself produces at least 5 times less code, makes the program more readable, saves a lot of time to understand and maintain a multi-service application.
