softprops / serverless-rust

⚡ 🦀 a serverless framework plugin for rustlang applications
https://www.npmjs.com/package/serverless-rust
MIT License
548 stars 82 forks source link

document story for what offline development looks like #74

Open softprops opened 4 years ago

softprops commented 4 years ago

💡 Feature description

Local development keeps coming up as a common theme. Figure out and document the story for what this looks like, even if its just documenting how to set up serverless-offline.

💻 Basic example

add a second to the readme that outlines what is needed and how to do this with minimal friction

softprops commented 4 years ago

In theory if the provided runtime is support serverless-offline should "just work"

https://github.com/dherault/serverless-offline/blob/95ec5c45ff29521934f10e1ab690afa31ba2a981/src/config/supportedRuntimes.js#L53

zprobst commented 4 years ago

Trying to find a resolution to this myself.

Seems that the error message I keep getting is offline: Warning: found unsupported runtime 'rust' for function 'xzy'. Switching the order of the plugins does not seem to help. Though I am pretty sure offline needs to be after rust.

plugins:
  - serverless-rust
  - serverless-offline

Further confusing is that the source of this library re-writes the runtime as provided here so serverless offline should see it as provided not rust. Going to keep investigating.

zprobst commented 4 years ago

In fact, looking a little closer, it looks like serverless offline creates a representation of each lambda right after you run sls offline start here

To that end, it doesn't get re-written as the provided runtime until long after offline knows about its runtime it would seem. As one might imagine, I am not a genius at javascript seeing as I am spending time in the rust ecosystem so I could easily be wrong about that.

Maybe the approach is to do something similar in this repo where there is an internal list of rust functions that are rewritten as provided as soon as the plugin is loaded. Then later in the build function, you simply see if the lambda in question is one of the previously found rust functions and build it as we currently do.

softprops commented 4 years ago

I almost got this working with serverless offline --useDocker with the pull linked above. however I'm on a mac an the volume serverless offline was mounting wasn't permitted on a mac.

softprops commented 4 years ago

Linked issue for ref https://github.com/dherault/serverless-offline/issues/1041