19
The Go gopher was designed by Renée French . The gopher stickers was made by Takuya Ueda. Licensed under the Creative Commons 3.0 Attributions license. Cloud Functionsの紹介 2017/04/01(土) @Next ’17 Extended - Tokyo

Cloud Functionsの紹介

Embed Size (px)

Citation preview

Page 1: Cloud Functionsの紹介

The Go gopher was designed by Renée French.The gopher stickers was made by Takuya Ueda.Licensed under the Creative Commons 3.0 Attributions license.

Cloud Functionsの紹介

2017/04/01(土)@Next ’17 Extended - Tokyo

Page 2: Cloud Functionsの紹介

自己紹介

メルカリ/ソウゾウ

上田拓也twitter: @tenntenn■ コミュニティ活動

GCPUG Tokyo, Goビギナーズ, golang.tokyo,Go Conference

■ 業務GAE/Goでメルカリアッテを作ってますGoやGCPコミュニティを盛り上げる仕事Gopherを描く仕事(LINEスタンプ)

2

Page 4: Cloud Functionsの紹介

4

Cloud Functionsオープンベータ!

https://cloud.google.com/functions/

Page 5: Cloud Functionsの紹介

Cloud Functions

5

● サーバレス● イベント駆動● ステートレス● アプリではなく単一の関数● Node.js

Page 6: Cloud Functionsの紹介

関数の種類

■ HTTP functions● HTTPSのリクエストがトリガー● 同期実行

■ Background functions● Cloud Pub/SubとCloud Storageがトリガー● 非同期実行

6

Page 7: Cloud Functionsの紹介

HTTP functions■ ExpressJSのreqとresを用いる

7

Page 8: Cloud Functionsの紹介

HTTP functionsのデプロイ

■ アップロードするバケットとトリガーを指定

8

Page 9: Cloud Functionsの紹介

Background functions■ 処理が終わったらcallbackを呼ぶ

9

Promiseも使える

Page 10: Cloud Functionsの紹介

Background functionsのデプロイ10

Page 11: Cloud Functionsの紹介

依存関係を記述する

■ package.jsonに書くだけ

11

npm installはCloud上で行われる

Page 12: Cloud Functionsの紹介

ログ

■ ログはStackdriver Loggingへ● console.logを使う

■ エラーはStackdriver Errorsへ● キャッチされない例外はエラーへ

12

Page 13: Cloud Functionsの紹介

モニタリング

■ 呼び出し数

● 関数の呼び出し回数

■ 実行時間

● 1回の呼び出しあたりの実行時間

■ メモリ使用量

● 1回の呼び出しあたりのメモリ使用量

13

Page 14: Cloud Functionsの紹介

Cloud Functionsの実行環境14

(Googleサービスは自動で認証される)

Page 15: Cloud Functionsの紹介

ローカルの開発環境

■ エミュレータが用意されている(アルファ)● https://github.com/GoogleCloudPlatform/cloud-functi

ons-emulator/

15

Page 16: Cloud Functionsの紹介

デモ

16

Page 19: Cloud Functionsの紹介

19

Thank you! twitter: @tenntenn Qiita: tenntennconnpass: tenntenn