阅读(3673) (0)

Moralis Jobs

2022-05-12 09:21:36 更新

有时您想执行长时间运行的函数,并且不想等待响应。 ​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并在需要时提供参数

spaces_-MVStbACGLCycg7J5WQ2_uploads_git-blob-1bb4c06fc1325b08bcc9ba5cb074ec2ece435a7f_Moralis_dashboard_schedule_job_options

当您配置好您的工作后,您可以通过按右下角的“Schedule”来确认它。