Cloud Functionsの紹介
-
Upload
takuya-ueda -
Category
Technology
-
view
940 -
download
2
Transcript of Cloud Functionsの紹介
![Page 1: Cloud Functionsの紹介](https://reader030.fdocuments.net/reader030/viewer/2022021507/58e4ab221a28abbb038b5623/html5/thumbnails/1.jpg)
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の紹介](https://reader030.fdocuments.net/reader030/viewer/2022021507/58e4ab221a28abbb038b5623/html5/thumbnails/2.jpg)
自己紹介
メルカリ/ソウゾウ
上田拓也twitter: @tenntenn■ コミュニティ活動
GCPUG Tokyo, Goビギナーズ, golang.tokyo,Go Conference
■ 業務GAE/Goでメルカリアッテを作ってますGoやGCPコミュニティを盛り上げる仕事Gopherを描く仕事(LINEスタンプ)
2
![Page 3: Cloud Functionsの紹介](https://reader030.fdocuments.net/reader030/viewer/2022021507/58e4ab221a28abbb038b5623/html5/thumbnails/3.jpg)
参考にしたセッション● Serverless computing options with Google
Cloud Platform● Building serverless applications with Google
Cloud Functions● Google Cloud Functions and Firebase● Extending the Google Assistant with Actions
on Google
3
※このスライド内でセッションで使われている図などを使ってます
![Page 4: Cloud Functionsの紹介](https://reader030.fdocuments.net/reader030/viewer/2022021507/58e4ab221a28abbb038b5623/html5/thumbnails/4.jpg)
4
Cloud Functionsオープンベータ!
https://cloud.google.com/functions/
![Page 5: Cloud Functionsの紹介](https://reader030.fdocuments.net/reader030/viewer/2022021507/58e4ab221a28abbb038b5623/html5/thumbnails/5.jpg)
Cloud Functions
5
● サーバレス● イベント駆動● ステートレス● アプリではなく単一の関数● Node.js
![Page 6: Cloud Functionsの紹介](https://reader030.fdocuments.net/reader030/viewer/2022021507/58e4ab221a28abbb038b5623/html5/thumbnails/6.jpg)
関数の種類
■ HTTP functions● HTTPSのリクエストがトリガー● 同期実行
■ Background functions● Cloud Pub/SubとCloud Storageがトリガー● 非同期実行
6
![Page 7: Cloud Functionsの紹介](https://reader030.fdocuments.net/reader030/viewer/2022021507/58e4ab221a28abbb038b5623/html5/thumbnails/7.jpg)
HTTP functions■ ExpressJSのreqとresを用いる
7
![Page 8: Cloud Functionsの紹介](https://reader030.fdocuments.net/reader030/viewer/2022021507/58e4ab221a28abbb038b5623/html5/thumbnails/8.jpg)
HTTP functionsのデプロイ
■ アップロードするバケットとトリガーを指定
8
![Page 9: Cloud Functionsの紹介](https://reader030.fdocuments.net/reader030/viewer/2022021507/58e4ab221a28abbb038b5623/html5/thumbnails/9.jpg)
Background functions■ 処理が終わったらcallbackを呼ぶ
9
Promiseも使える
![Page 10: Cloud Functionsの紹介](https://reader030.fdocuments.net/reader030/viewer/2022021507/58e4ab221a28abbb038b5623/html5/thumbnails/10.jpg)
Background functionsのデプロイ10
![Page 11: Cloud Functionsの紹介](https://reader030.fdocuments.net/reader030/viewer/2022021507/58e4ab221a28abbb038b5623/html5/thumbnails/11.jpg)
依存関係を記述する
■ package.jsonに書くだけ
11
npm installはCloud上で行われる
![Page 12: Cloud Functionsの紹介](https://reader030.fdocuments.net/reader030/viewer/2022021507/58e4ab221a28abbb038b5623/html5/thumbnails/12.jpg)
ログ
■ ログはStackdriver Loggingへ● console.logを使う
■ エラーはStackdriver Errorsへ● キャッチされない例外はエラーへ
12
![Page 13: Cloud Functionsの紹介](https://reader030.fdocuments.net/reader030/viewer/2022021507/58e4ab221a28abbb038b5623/html5/thumbnails/13.jpg)
モニタリング
■ 呼び出し数
● 関数の呼び出し回数
■ 実行時間
● 1回の呼び出しあたりの実行時間
■ メモリ使用量
● 1回の呼び出しあたりのメモリ使用量
13
![Page 14: Cloud Functionsの紹介](https://reader030.fdocuments.net/reader030/viewer/2022021507/58e4ab221a28abbb038b5623/html5/thumbnails/14.jpg)
Cloud Functionsの実行環境14
(Googleサービスは自動で認証される)
![Page 15: Cloud Functionsの紹介](https://reader030.fdocuments.net/reader030/viewer/2022021507/58e4ab221a28abbb038b5623/html5/thumbnails/15.jpg)
ローカルの開発環境
■ エミュレータが用意されている(アルファ)● https://github.com/GoogleCloudPlatform/cloud-functi
ons-emulator/
15
![Page 16: Cloud Functionsの紹介](https://reader030.fdocuments.net/reader030/viewer/2022021507/58e4ab221a28abbb038b5623/html5/thumbnails/16.jpg)
デモ
16
![Page 17: Cloud Functionsの紹介](https://reader030.fdocuments.net/reader030/viewer/2022021507/58e4ab221a28abbb038b5623/html5/thumbnails/17.jpg)
Cloud Functions デモ17
YouTubeで見る
![Page 18: Cloud Functionsの紹介](https://reader030.fdocuments.net/reader030/viewer/2022021507/58e4ab221a28abbb038b5623/html5/thumbnails/18.jpg)
ローカル開発環境 デモ18
YouTubeで見る
![Page 19: Cloud Functionsの紹介](https://reader030.fdocuments.net/reader030/viewer/2022021507/58e4ab221a28abbb038b5623/html5/thumbnails/19.jpg)
19
Thank you! twitter: @tenntenn Qiita: tenntennconnpass: tenntenn