amazingly simple serverless go

14

Click here to load reader

Upload: yun-zhi-lin

Post on 28-Jan-2018

955 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Amazingly Simple Serverless Go

Amazingly Simple Serverless GoSeptember 2017 Golang Meetup Yun Zhi Lin, Microservices Architect

Page 2: Amazingly Simple Serverless Go

1

2

3

Why Go + Serverless

(Gopher) Event Driven Architecture

Demo and Examples

Page 3: Amazingly Simple Serverless Go

Why SLS GolangWhy

Page 4: Amazingly Simple Serverless Go

People want Golang!

But got .Net Core instead

Page 5: Amazingly Simple Serverless Go

Why Serverless Framework?

The most versatile out of all golang enabled serverless libraries

Framework Provider Languages Golang Shim Infrastructure

Apex AWS Node

Golang

Node Partial

GoSparta AWS Golang Node Partial

Serverless

Framework

AWS

Azure

Google

Openwhisk

Kubeless

Python

Node

Java

.Net

Python Full

- Dev friendly

YML

- Ops friendly CF

Page 6: Amazingly Simple Serverless Go

Secret Sauce – EAWSY Shim

Eawsy’s Shim is 2nd

fastest way to run AWS Lambda from cold starts

Page 7: Amazingly Simple Serverless Go

(Gopher)Event Driven Architecture

Page 8: Amazingly Simple Serverless Go

Life prior to Microservices and Gophers

Mobile Backend

Frontend

Page 9: Amazingly Simple Serverless Go

Life after Event Driven Microservices, with Gophers!

2 Docker Go MicroServices + 14 Go Lambdas

SSO SCVJAMstack JAMstack

Page 10: Amazingly Simple Serverless Go

Demo & Examples

Page 11: Amazingly Simple Serverless Go

Kinesis Event Source

Go code serverless.yml

func DataLogger(

evt *kinesisstreamsevt.Event)(

interface{}, error) {

rs := evt.Records

for r := range rs {

log.Println(r)

}

return evt.String(), nil

}

functions:

logger:

handler:

handler.DataLogger

events:

- stream:

${env:AWS_KINESIS_ARN}

Page 12: Amazingly Simple Serverless Go

Go Net with API Gateway

Go code serverless.yml

functions:

crud:

handler: handler.Handler

events:

- http:

path: todos

method: post

cors: true

- http:

path: todos

method: get

cors: true

- http:

path: todos/{id}

method: get

cors: true

func setUpMux() *mux.Router {

r := mux.NewRouter()

r.HandleFunc("/todos", create)

.Methods(http.MethodPost)

r.HandleFunc("/todos", list)

.Methods(http.MethodGet)

r.HandleFunc("/todos/{id}", read)

.Methods(http.MethodGet)

return r

}

Page 13: Amazingly Simple Serverless Go

Demo

Page 14: Amazingly Simple Serverless Go

Credits and Road Map

This library would not be possible without the help of:

• @cristm from HereMaps

• Serverless.com and Eawsy.com

• @flemay from amaysim for the awesome logo

Coming soon:

• dynamodb example with localstack

• Event Gateway and FDK

• Azure integration