Оберточный сервер без использования облачных функций Google - PullRequest
0 голосов
/ 08 июня 2018

Я пытаюсь написать пользовательскую оболочку, используя функции без сервера и облачные функции Google.

const serverless = new Serverless({
    interactive: false,
    servicePath: "/Users/user/work/faas-artillery"
  })

  var options = {
    function: 'my-function',
    stage: 'my-stage',
    region: 'my-region'

  };
  //console.log(options)
  // Set the serverless artillery to use Google. 
  // This constructor then adds Google plugins to the serverless framework
  var googleIndex = new GoogleIndex(serverless, options);
  serverless.init();

  // Now find the GoogleInvoke by constructor name within the serverless 
  const invoke = serverless.pluginManager.plugins.find(
    plugin => Object.getPrototypeOf(plugin).constructor.name === 'GoogleInvoke' 
  )
  serverless.run()

При выполнении вышеупомянутой команды я получаю команду invoke not found.Есть ли способ, которым я могу назначить параметры CLI для без сервера.

1 Ответ

0 голосов
/ 08 июня 2018

Обещание присутствовало с методом serverless.init (), и нам пришлось бы ждать его завершения.

 let googleInvoke;
  let SLS_DEBUG
  SLS_DEBUG = process.env.SLS_DEBUG
  process.env.SLS_DEBUG = '*'
  // pretend that SLS was called.
  process.argv[1] = Serverless.dirname
  const serverless = new Serverless({
    interactive: false,
    servicePath: "/Users/user/work/faas-artillery"
  })

  var options = {
    function: 'my-function',
    stage: 'my-stage',
    region: 'my-region'

  };
  //console.log(options)
  // Set the serverless artillery to use Google. 
  // This constructor then adds Google plugins to the serverless framework
  var googleIndex = new GoogleIndex(serverless, options);
  serverless.init().then(() => {
    // Now find the GoogleInvoke by constructor name within the serverless 
    const invoke = serverless.pluginManager.plugins.find(
      plugin => Object.getPrototypeOf(plugin).constructor.name === 'GoogleInvoke' 
    )
  }).then(() => {
    serverless.run()
  });
...