dispatch icon indicating copy to clipboard operation
dispatch copied to clipboard

Run a function locally for development / debugging

Open imikushin opened this issue 7 years ago • 2 comments
trafficstars

It'd be very nice to be able to run a function locally for development / debugging with a CLI command like this:

dispatch run ./bingo.js
  • [ ] Bug
  • [x] Feature
  • [ ] Enhancement

Details

The above command would spin up a local API server and expose the function as an HTTP endpoint.

Reloading the function on change would also be nice. But the most important part is to be able to spin up a function easily and quickly.

Context

Currently, to spin up a function, you have to deploy a few objects in Dispatch. To redeploy would mean to, first, delete those objects, and then create them back again. This slows down development.

Workaround

What I did while working on my demo was: write (and debug) a node.js server to host my function locally, so I could run and restart it quickly.

Possible Implementation

The CLI command should, perhaps, use docker to bind-mount the function source into the image (that would then be used to run the function when deployed) and run the resulting container locally. This would provide a fast start-up (and stop) time and quick development cycle.

Complexity

  • [ ] Low - Simple enhancement or bug fix, no architectural changes or refactoring
  • [x] Medium - Change requires some thought, but is relatively isolated
  • [ ] High - Significant architectural change or large refactor

Impact

  • [ ] Low - Annoyance, but does not impact business or functinality
  • [x] Medium - Issue can be worked around, but is causing pain
  • [ ] High - Blocker

imikushin avatar Jan 16 '18 19:01 imikushin

Didn't we also discuss having a --watch option in the CLI to auto reload function on save? I'd probably put a higher priority on that than "run", particularly as we don't want to require too much from the client (docker, etc). Also, it may be tricky integrating secrets, etc.

berndtj avatar Jan 29 '18 18:01 berndtj

@berndtj +1 on the Didn't we also discuss having a --watch option in the CLI. Discussed that with @kars7e before.

embano1 avatar Feb 01 '18 17:02 embano1