Moralis Jobs

2022-05-12 11:15 更新

有時您想執(zhí)行長時間運行的函數(shù),并且不想等待響應(yīng)。 ?Cloud Jobs? 就是為此而生的。

定義一個Job

在您的云功能中定義Job。

    Moralis.Cloud.job("myJob", (request) =>  {
      // params: passed in the job call
      // headers: from the request that triggered the job
      // log: the Moralis Server logger passed in the request
      // message: a function to update the status message of the job object
      const { params, headers, log, message } = request;
      message("I just started");
      return doSomethingVeryLong(request);
    });

安排Job

您可以通過單擊右上角的“Schedule a job”在儀表板的“Jobs”部分安排Job。

spaces_-MVStbACGLCycg7J5WQ2_uploads_git-blob-6f169bf7d2e538be9eb5c2f5f39d6ba1af18aeda_Moralis_dashboard_Schedule_Job

選擇描述、要運行的Job并在需要時提供參數(shù)

spaces_-MVStbACGLCycg7J5WQ2_uploads_git-blob-1bb4c06fc1325b08bcc9ba5cb074ec2ece435a7f_Moralis_dashboard_schedule_job_options

當(dāng)您配置好您的工作后,您可以通過按右下角的“Schedule”來確認它。


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號