做机械一般做那个外贸网站,重庆市官网首页,跨境电商平台的特点,创建自由摄影师的网站内容查看oracle会话和进程在这篇文章中#xff0c;我将继续在Oracle Digital Assistant和Oracle Digital Assistant之上为FlexDeploy实现对话式UI的故事。 Fn项目 。 今天#xff0c;我将围绕聊天机器人工作的无服务器API迁移到云中#xff0c;因此整个解决方案都在云中工作我将继续在Oracle Digital Assistant和Oracle Digital Assistant之上为FlexDeploy实现对话式UI的故事。 Fn项目 。 今天我将围绕聊天机器人工作的无服务器API迁移到云中因此整个解决方案都在云中工作 该API是作为收集到Fn应用程序中的Fn函数集来实现的。 Fn的优点在于它只是一堆Docker容器它们可以同样在本地Docker引擎和云中某个位置的笔记本电脑上运行。 话虽如此我可以从任何云提供商因为它描述的运行K8S集群上我的FN应用在这里 。 但是今天不是那天。 今天我将在基于Fn的全新云服务Oracle Functions上运行我的无服务器API。 该服务尚不通用但是我参与了“有限可用性”计划因此我可以对其进行试用可以使用它并在其上发布博客。 在此解决方案中我必须摆脱这里实现的Fn Flow 并回到我原来的实现因为Oracle Functions还不支持Fn Flow。 我希望很快因为这实际上是最好的部分。 因此配置好我们的OCI环境并启动并运行Oracle Functions服务我不会在此处重新发布Oracle教程我们需要配置Fn CLI以便能够与该服务进行通信 fn create context oracle_fn --provider oracle
fn use context oracle_fn
fn update context oracle.compartment-id MY_COMPARTMENT_ID
fn update context api-url https://functions.us-phoenix-1.oraclecloud.com
fn update context registry phx.ocir.io/flexagonoraclecloud/flexagon-repo
fn update context oracle.profile oracle_fn 好的现在我们的Fn命令行界面正在与Oracle Functions对话。 下一步是在Oracle Functions控制台中创建一个应用程序 现在我们可以将Fn应用程序部署到Oracle Functions Eugenes-MacBook-Pro-3:fn fedor$ ls -l
total 8
-rw-r--r-- 1 fedor staff 12 Dec 4 15:41 app.yaml
drwxr-xr-x 5 fedor staff 160 Feb 9 15:24 createsnapshotfn
drwxr-xr-x 6 fedor staff 192 Feb 9 15:25 receiveFromBotFn
drwxr-xr-x 6 fedor staff 192 Feb 9 15:25 sendToBotFn
Eugenes-MacBook-Pro-3:fn fedor$
Eugenes-MacBook-Pro-3:fn fedor$
Eugenes-MacBook-Pro-3:fn fedor$ fn deploy --all 完成后我们可以在Oracle Functions控制台中观察该应用程序 下一步是更新聊天机器人和便携式计算机中的API网址以便调用云中的功能而不是先前的本地实现。 可以使用以下命令检索URL fn list triggers odaapp 到目前为止从我的笔记本电脑到Oracle Functions的迁移一直看起来非常简单。 但是这里有点痛苦。 为了使用http请求调用Oracle Functions中托管的函数 应该对请求进行签名以便它们可以通过身份验证。 调用签名函数调用的node.js实现如下所示 var fs require(fs);
var https require(https);
var os require(os);
var httpSignature require(http-signature);
var jsSHA require(jssha);var tenancyId ocid1.tenancy.oc1..aaaaaaaayonz5yhpr4vxqpbdof5rn7x5pfrlgjwjycwxasf4dkexiq;
var authUserId ocid1.user.oc1..aaaaaaaava2e3wd3cu6lew2sktd6by5hnz3d7prpgjho4oambterba;
var keyFingerprint 88:3e:71:bb:a5:ea:68:b7:56:fa:3e:5d:ea:45:60:10;
var privateKeyPath /Users/fedor/.oci/functions_open.pem;
var privateKey fs.readFileSync(privateKeyPath, ascii);
var identityDomain identity.us-ashburn-1.oraclecloud.com;function sign(request, options) {var apiKeyId options.tenancyId / options.userId / options.keyFingerprint;var headersToSign [host,date,(request-target)];var methodsThatRequireExtraHeaders [POST, PUT];if(methodsThatRequireExtraHeaders.indexOf(request.method.toUpperCase()) ! -1) {options.body options.body || ;var shaObj new jsSHA(SHA-256, TEXT);shaObj.update(options.body);request.setHeader(Content-Length, options.body.length);request.setHeader(x-content-sha256, shaObj.getHash(B64));headersToSign headersToSign.concat([content-type,content-length,x-content-sha256]);}httpSignature.sign(request, {key: options.privateKey,keyId: apiKeyId,headers: headersToSign});var newAuthHeaderValue request.getHeader(Authorization).replace(Signature , Signature version\1\,);request.setHeader(Authorization, newAuthHeaderValue);
}function handleRequest(callback) {return function(response) {var responseBody ;response.on(data, function(chunk) {responseBody chunk;});response.on(end, function() {callback(JSON.parse(responseBody));});}
}function createSnapshot(release) {var body release;var options {host: af4qyj7yhva.us-phoenix-1.functions.oci.oraclecloud.com,path: /t/createsnapshotfn,method: POST,headers: {Content-Type: application/text,}};var request https.request(options, handleRequest(function(data) {console.log(data);}));sign(request, {body: body,privateKey: privateKey,keyFingerprint: keyFingerprint,tenancyId: tenancyId,userId: authUserId});request.end(body);
}; 调用Oracle Functions中托管的无服务器API时 Oracle Digital Assistant定制组件和笔记本电脑上的侦听器组件应使用此方法。 而已 翻译自: https://www.javacodegeeks.com/2019/02/conversational-oracle-assistant-fn.html查看oracle会话和进程