Skip to content

Commit

Permalink
feat: add support for Go functions (#2929)
Browse files Browse the repository at this point in the history
* feat: add local functions proxy

* refactor: pass raw context to runtimes

* feat: add support for Go functions

* chore: fix linting errors

* chore: update shrinkwrap

* feat: use .exe extension for compiled binary on Windows

* feat: add check for Go installation

* chore: add pause call to test

* feat: add local functions proxy

* refactor: pass raw context to runtimes

* feat: add support for Go functions

* chore: fix linting errors

* feat: use .exe extension for compiled binary on Windows

* feat: add check for Go installation

* chore: add pause call to test

* chore: update shrinkwrap

* chore: update shrinkwrap
  • Loading branch information
eduardoboucas authored Jul 21, 2021
1 parent 08d03db commit 838e5bd
Show file tree
Hide file tree
Showing 9 changed files with 497 additions and 4 deletions.
291 changes: 291 additions & 0 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"@netlify/build": "^16.1.0",
"@netlify/config": "^13.0.0",
"@netlify/framework-info": "^5.7.2",
"@netlify/local-functions-proxy": "^0.1.0",
"@netlify/plugin-edge-handlers": "^1.11.22",
"@netlify/plugins-list": "^2.19.3",
"@netlify/routing-local-proxy": "^0.31.0",
Expand Down
14 changes: 14 additions & 0 deletions src/lib/functions/local-proxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { getBinaryPath: getFunctionsProxyPath } = require('@netlify/local-functions-proxy')
const execa = require('execa')

const runFunctionsProxy = ({ binaryPath, directory, name, requestData, timeout }) => {
const functionsProxyPath = getFunctionsProxyPath()

if (functionsProxyPath === null) {
throw new Error('Host machine does not support local functions proxy server')
}

return execa(functionsProxyPath, [JSON.stringify(requestData), binaryPath, directory, name, `${timeout}s`])
}

module.exports = { runFunctionsProxy }
6 changes: 5 additions & 1 deletion src/lib/functions/registry.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { env } = require('process')

const chalk = require('chalk')

const { NETLIFYDEVLOG, NETLIFYDEVERR } = require('../../utils/logo')
Expand Down Expand Up @@ -137,7 +139,9 @@ class FunctionsRegistry {

await Promise.all(directories.map((path) => this.prepareDirectoryScan(path)))

const functions = await this.listFunctions(directories)
const functions = await this.listFunctions(directories, {
featureFlags: { buildGoSource: env.NETLIFY_EXPERIMENTAL_BUILD_GO_SOURCE === 'true' },
})

// Before registering any functions, we look for any functions that were on
// the previous list but are missing from the new one. We unregister them.
Expand Down
Loading

1 comment on commit 838e5bd

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Benchmark results

Package size: 331 MB

Please sign in to comment.