Skip to content

sevenTiny/Chameleon.FaaS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chameleon.FaaS

(Function as a Service)函数即服务框架是一组灵活,可靠,动态伸缩,支持多语言,沙箱化的脚本服务框架。借助该框架的能力,客户端无需关心业务脚本的运行环境,机器部署,服务扩容等基础设施。而将关注点聚焦在核心功能脚本的编写以及功能脚本的触发时机这两点上。

(Function as a Service)The Function as a Service function is a flexible, reliable, dynamic,mul-language, and sandboxed script service framework. With the capabilities of the framework, the client does not need to care about the operating environment of the business script, machine deployment, service expansion and other infrastructure. Focus on the writing of core function scripts and the timing of triggering function scripts.

FaaS框架的核心是“动态脚本引擎”,该引擎提供了一种在运行时编译,加载,执行代码脚本的能力。通过这种能力,可以将存储在数据库、磁盘等文件系统的脚本代码实时获取并编译加载到内存中执行。

At the heart of the FaaS framework is the "Dynamic Scripting Engine", which provides the ability to compile, load, and execute code scripts at runtime. Through this capability, script code stored in a file system such as a database or a disk can be acquired and compiled into memory for execution in real time.

动态编译的能力可以轻松应用在PaaS、FaaS、沙箱、插件化等场景,最大限度地满足“动态”、“热插拔”的需求。

The ability to dynamically compile can be easily applied to scenarios such as PaaS, FaaS, sandboxing, and plug-in to maximize the need for "dynamic" and "hot swap".

示例代码 Example

该代码可以在 src\dotnet\Tests\Test.Bamboo.ScriptEngine.CSharp 项目的 Demo.cs 文件中找到
This code can be found in the Demo.cs file of the src\dotnet\Tests\Test.Bamboo.ScriptEngine.CSharp project.

[Fact]
public void Execute()
{
    IDynamicScriptEngine scriptEngineProvider = new CSharpDynamicScriptEngine();
    DynamicScript script = new DynamicScript();
    script.TenantId = 0;
    script.Language = DynamicScriptLanguage.CSharp;
    script.Script =
    @"
    using System;
    public class Test
    {
        public int GetA(int a)
        {
            return a;
        }
    }
    ";
    script.ClassFullName = "Test";
    script.FunctionName = "GetA";
    script.Parameters = new object[] { 111 };
    var result = scriptEngineProvider.Run<int>(script);
    Assert.True(result.IsSuccess);
    Assert.Equal(111, result.Data);
}

支持模式 Support mode

  1. SDK Nuget 本地模式 | Nuget SDK local mode
  2. RPC远程调用模式 | Rpc remote execute mode
  3. Restful Api远程调用模式 | Restful api request mode
  4. 定时任务模式 | Timed task mode

使用方式

About

Function as a Service 函数即服务框架

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published