SFaaSOnOrleans is a Stateful Function as a Service (SFaaS) platform on top of Microsoft Orleans.
- .NET Framework 7
- IDE: Visual Studio or VSCode
Orleans framework provides facilities to program distributed applications at scale using the virtual actor model. We highly recommend starting from the Orleans Documentation to further understand the model.
As any real-world application, we need to make sure the server is up and running before any client interation. Therefore, in the project's root folder, run the following command:
dotnet run --project Server
This command will start up the Orleans server (aka silo).
Next, we can initialize the client program. In another console, run:
dotnet run --project DynamicCodeApi
In this programming task, you build upon the application scenario and your Kafka processing logic from your previous assignment. You are asked to design and implement a SFaaS platform on top of Orleans. You are provided with basic APIs to register and call functions and the remaining functionalities must be implemented.
Refer to the assignment description in Absalon for a complete
Your client program offers an HTTP server so you can perform basic operations in your SFaaS platform. Swagger UI can also support you interacting with the APIs through http://localhost:5244/swagger.
To register a simple function, submit a POST request (http://localhost:5244/register) with the following payload:
{
"FunctionName": "AddNumbers",
"Code": "return (System.Int64)args[0] + (System.Int64)args[1];"
}
To invoke a function, submit a POST request (http://localhost:5244/test) with the following payload:
{
"FunctionName": "AddNumbers",
"Parameters": [10, 20]
}
To register a function that operates with state, make sure Redis is up and running and submit a POST request (http://localhost:5244/register) with the following payload:
{
"FunctionName": "TestRedis",
"Code": "
kvs.PutString(\"test\",\"test\");
return kvs.GetString(\"test\");
"
}
Then invoke it:
{
"FunctionName": "TestRedis",
"Parameters": []
}
In case you need to operate with value objects other than strings, make sure to indicate the type when calling the state API:
{
"FunctionName": "TestRedisTyped",
"Code": "
kvs.Put<int>(\"testInt\",1);
return kvs.Get<int>(\"testInt\");
"
}
{
"FunctionName": "TestRedisTyped",
"Parameters": []
}
Q: There are compilation errors
A: Make sure you have installed .NET Framework 7 correctly. Besides, make sure you have not modified the original code.
Q: How to debug?
A: Use an IDEA. For instance, to open the project in Visual Studio, make sure to select the BDSOnlineShop.sln as the solution file, so Visual Studio will recognize the solution as a whole and allow you to debug your application.
Q: The project is throwing exceptions.
A: You are supposed to complete the application according to the assignment description, removing the exceptions thrown in the way.