Coder Social home page Coder Social logo

cloudfunc's Introduction

CloudFunc

GoDoc

CloudFunc is a command line tool (cli) that deploys Google Cloud Functions with ease. It uses node.js shim to wrap the Go binary as the Cloud Functions only support Node at the moment.

Only us-central region is supported while Google Cloud Functions are in Beta

Installation

Tested on Golang 1.8

Please follow gcloud sdk installation notes in case you don't have the gcloud command.

You will also need to update and install beta features at the moment

gcloud components update &&
gcloud components install beta

Finally download the cloudfunc with its SDK

go get -u github.com/flowup/cloudfunc/...

Code Example

This code example shows a simple cloud function that sends back whatever JSON it receives.

package main

import (
	"github.com/flowup/cloudfunc/api"
)

func main() {
	var input map[string]interface{} = make(map[string]interface{})
	
	cloudFunction := api.NewCloudFunc()
	req, err := cloudFunction.GetRequest()
	if err != nil {
		panic(err)
	}
	
	err = req.BindBody(&input)
	if err != nil {
		panic(err)
	}

	cloudFunction.SendResponse(&input)
}

Usage

Single deploy command is exposed by the cloudfunc. This allows to target a folder with main package that will be deployed to cloud functions. Name of the function will be derived from the name of the folder.

You need to also target the storage bucket that will be used to store contents of your function

cloudfunc deploy myfunction --bucket mybucket

Where:

  • myfunction is the folder with your function
  • mybucket is the name of your gcloud bucket

Configuration

Additional configurations can be done using function.json file within your function main package (look at the /examples folder).

{
  "name": "myfunctionname",
  "bucket": "mybucketname",
  "memory": 128,
  "timeout": 3
}

In case your bucket is specified within the function.json file, you can simply deploy with:

cloudfunc deploy example # where example is your function folder

SDK

There are two IO functions provided by github.com/flowup/cloudfunc/api:

// GetInput accepts an interface and unmarshalls the function input using json.Unmarshal
func GetInput(i interface{}) error {}
// Send marshalls given interface using json.Marshal and sends it back as a function output
// If the interface can't be serialized, it will be returned as a pure string
func Send(i interface{}) error

cloudfunc's People

Contributors

kubaj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cloudfunc's Issues

Add support for cloud pub/sub

Cloudfunc should allow users to create functions that will be triggered by the pub/sub system. The node.js implementation can be found here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.