blob: 59557bb091d92e9a4bb102415812d18e269b99e1 [file] [log] [blame]
(window.webpackJsonp=window.webpackJsonp||[]).push([[81],{425:function(e,t,r){"use strict";r.r(t);var o=r(11),n=Object(o.a)({},(function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[r("h1",{attrs:{id:"adding-executors"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#adding-executors"}},[e._v("#")]),e._v(" Adding Executors")]),e._v(" "),r("p",[e._v("Teaclave supports several function executors currently: "),r("code",[e._v("builtin")]),e._v(", "),r("code",[e._v("mesapy")]),e._v(" and\n"),r("code",[e._v("wamr")]),e._v(" (WebAssembly Micro Runtime). For more information about current function\nexecutors, please check "),r("RouterLink",{attrs:{to:"/teaclave/executor/"}},[e._v("this link")]),e._v(".")],1),e._v(" "),r("p",[e._v("However, sometimes platform providers may found current executors built in\nTeaclave are not applicable for hosting some services, and they want to use\ntheir own executor or an executor shipped by the third-party to execute their\ncode (for example, written languages other than Python or WASM). They can then\nmodify Teaclave's source code to add a customized executor to run their\nfunctions.")]),e._v(" "),r("h2",{attrs:{id:"steps-of-adding-a-new-executor"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#steps-of-adding-a-new-executor"}},[e._v("#")]),e._v(" Steps of Adding a New Executor")]),e._v(" "),r("p",[e._v("Executors can be either linked to Teaclave as a third-party library (e.g. Mesapy\nexecutor) or built in Teaclave itself (e.g. builtin executor). The source code\nof either type is located at "),r("code",[e._v("executor/src/")]),e._v(". The general steps for adding a\ncustom executor can be summarized in the following steps:")]),e._v(" "),r("ol",[r("li",[e._v("Create a public executor unit struct and implement the "),r("code",[e._v("TeaclaveExecutor")]),e._v(" trait.")]),e._v(" "),r("li",[e._v("Re-export your new executor in "),r("code",[e._v("executor/src/lib.rs")]),e._v(" to make it callable.")]),e._v(" "),r("li",[e._v("Add enums in "),r("code",[e._v("ExecutorType")]),e._v(" and "),r("code",[e._v("Executor")]),e._v(" (in "),r("code",[e._v("types/src/worker.rs")]),e._v("), as\nwell as corresponding logics for handling the added enums.")]),e._v(" "),r("li",[e._v("Import and register the added executor in "),r("code",[e._v("worker/src/worker.rs")]),e._v(".")]),e._v(" "),r("li",[e._v("(Optional) Add unit test to your customized executor")])]),e._v(" "),r("h3",{attrs:{id:"linking-related-libraries"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#linking-related-libraries"}},[e._v("#")]),e._v(" Linking Related Libraries")]),e._v(" "),r("p",[e._v("If the custom executor is embedded or ported to Teaclave, "),r("code",[e._v("extern")]),e._v(" functions\nmight be introduced into Teaclave and thus you also need to tell the build\nsystem where to find the library containing these external functions. You may\nadd this library in the linking command at script\n"),r("code",[e._v("cmake/scripts/sgx_link_sign.sh")]),e._v(". The linker will try to find the library in\n"),r("code",[e._v("${TEACLAVE_OUT_DIR}")]),e._v(", which is be parsed to "),r("code",[e._v("build/intermediate")]),e._v(" in build\nphase. Besides, you can also add several lines to generate or download the\nlibrary in "),r("code",[e._v("CMakeList.txt")]),e._v(".")]),e._v(" "),r("h2",{attrs:{id:"invoking-the-new-executor"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#invoking-the-new-executor"}},[e._v("#")]),e._v(" Invoking the New Executor")]),e._v(" "),r("p",[e._v("Just call the API and remember to set "),r("code",[e._v("executor_type")]),e._v(" to your new executor\ntype's name (the string used in "),r("code",[e._v("ExecutorType::try_from")]),e._v(" match case) when\ncalling "),r("code",[e._v("register_function")]),e._v(", and set the "),r("code",[e._v("executor")]),e._v(" to the executor's name\ncorrespondingly.")])])}),[],!1,null,null,null);t.default=n.exports}}]);