Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Functions from scratch? #447

Closed
ndarilek opened this issue Dec 18, 2017 · 4 comments
Closed

Question: Functions from scratch? #447

ndarilek opened this issue Dec 18, 2017 · 4 comments
Labels

Comments

@ndarilek
Copy link

This project looks interesting, and I look forward to making things wih it! One thing I'm a bit confused about is how one goes about building a function from scratch, where a template isn't available. I.e. how would I build a function in Rust? What should my Dockerfile look like? Can I just use the official Rust image and ensure that my binary launches as soon as the container comes up?

I also gather that I simply read from stdin and output to stdout. This leaves me with several unanswered questions:

  • Can I read request headers somehow?
  • Can I change the content-type of my response to, say, output RSS/Atom feeds?
  • Related, can I output other headers to the client?
  • Can I change the status code of the response?

A "functions from scratch" guide might be a useful addition. If such a thing already exists, then please point me to it and apologies for missing it. Thanks!

@alexellis
Copy link
Member

Hi @ndarilek thanks for using OpenFaaS. We do actually have a template for Rust maintained by @ericstoekl, but I'll point you in the right location. We have answers for the questions you're asking in the documentation.

I'd start by reading the documentation in the TestDrive which explains some of this and the beginner guides too.

The reference documentation for the Function Watchdog is also likely to answer lots of your questions:

https://github.com/openfaas/faas/tree/master/watchdog

https://github.com/openfaas/faas-cli#templates

@ndarilek
Copy link
Author

ndarilek commented Dec 20, 2017 via email

@burtonr
Copy link
Contributor

burtonr commented Dec 27, 2017

Hi @ndarilek, the latest watchdog/gateway does supprt GET requests. Make sure you update your cli and Docker images to take advantage of the latest updates. It's a fast moving repo 😄

Also, the port 8080 is defined as environment variables for the gateway and watchdog. You can change them to whatever you'd like by mapping the ports in the docker-compose.yml file
as an example:

gateway:
        volumes:
            - "/var/run/docker.sock:/var/run/docker.sock"
        ports:
            - 8181:8080
image: functions/gateway:0.6.14

As for the "...didn't jump out at me..." we know the documentation is a bit spread out, but there is work underway to unify them into a documentation site. Please take a look and we welcome any input you may have: PR #274

@ndarilek
Copy link
Author

You're right, I was using an old binary. I'd copy-pasted the Rust template Dockerfile into my own, and it used 0.6.4. Updated that, and now things work as expected. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants