SlideShare uma empresa Scribd logo
1 de 51
Google Cloud Endpoints
with Golang
@soundTricker318
http://goo.gl/ZpUOs
どこの人?
http://www.bfts.co.jp
何やってる?
https://www.flickr.com/photos/centralasian/ (CC)
電
車
プ
ロ
グ
ラ
マ
話す事
http://creativecommons.org/licenses/by/3.0/us
https://github.com/mholt/golang-graphics/blob/master/official/talks.png
Google Cloud Endpoints
with
Golang
Google
Cloud
Endpoints
https://developers.google.com/appengine/docs/java/endpoints/
What?
Google
Cloud
Endpoints?
https://developers.google.com/appengine/docs/java/endpoints/
What?
Google
Cloud
Endpoints?
AppEngine上に
バックエンドAPIを
簡単に作成する仕組
https://developers.google.com/appengine/docs/java/endpoints/
What?
Google
Cloud
Endpoints?
作成したAPIに対する
クライアントライブラリを
自動生成
使える言語
Google
Cloud
Endpoints?
サーバサイド
使える言語
Google
Cloud
Endpoints?
サーバサイド
Python
Pythonで
Cloud Endpointsの
事例をあまりみないので
どっかLTとかするとウケそう
使える言語
Google
Cloud
Endpoints?
サーバサイド
Java
事例もよく見るので
始めるのは楽かも
JAX-RSに似てる
でも結構違う
http://www.flickr.com/photos/andypiper/
使え…..
Google
Cloud
Endpoints?
サーバサイド
PHP
過去にDeveloper Liveで
簡単なバージョンが実装されるも
その後詳細不明…
https://www.youtube.com/watch?v=yue4
rcGJU
使える言語
Google
Cloud
Endpoints?
サーバサイド
Go
Googleが
直接サポートしているわけではなく、
サードパーティフレームワークを
使う(後述) 個人的には好き
http://www.flickr.com/photos/andybons/
使える言語
Google
Cloud
Endpoints?
クライアント
クライアント
Google
Cloud
Endpoints?
自動生成ライブラリ
Android
Cloud Endpointsと
触ったことが無い( ー`дー´)キリッ
https://www.flickr.com/photos/etnyk/
クライアント
Google
Cloud
Endpoints?
自動生成ライブラリ
iPhone
持ってない( ー`дー´)キリッ
https://www.flickr.com/photos/reticulating/
クライアント
Google
Cloud
Endpoints?
自動生成ライブラリ
JavaScript
自動生成できる、
Google API client for JavaScript経由で
利用時に作成されたものが使える
感じ?
No
Image
クライアント
Google
Cloud
Endpoints?
自動生成ライブラリ
Dart
サードパーティ製
Dartを含めて自分で好きな言語の
クライアントLibrary Genは作れる
Google
Cloud
Endpoints
T
サーバサイド
Google
Cloud
Endpoints
T
サーバサイド
Google
Cloud
Endpoints
T
環境
• Appengine Go SDK
• MacユーザはbrewからでもOK
• 最近はGoogle Cloud SDK推奨
$ curl
https://dl.google.com/dl/cloudsdk/release
/install_google_cloud_sdk.bash | bash
サーバサイド
Google
Cloud
Endpoints
T
ライブラリインストール
• go-endpointsを使います
• Cloud Endpoinsフレームワーク
$ go get github.com/crhym3/go-
endpoints/endpoints
※インストール時にエラーが出ますが気にしないでください。
サーバサイド
Google
Cloud
Endpoints
T
ライブラリインストール(非必須)
• Datastore周りはgoonがオヌヌメ
• NDBみたいなもの
$ go get github.com/mjibson/goon
※インストール時にエラーが出ますが気にしないでください。
サーバサイド
Google
Cloud
Endpoints
T
サーバサイド
Google
Cloud
Endpoints
T
実装
• 4段階
1. 通信用構造体を作成
2. サービス(実処理部)を作成
3. サービスを登録
4. app.yamlを登録
• 詳しくは↓ or →
http://goo.gl/gBrZAD
サーバサイド
Google
Cloud
Endpoints
T
通信用構造体(struct)を作成
• go-endpointsが自動で
JSON←→Struct変換してくれます。
サーバサイド
Google
Cloud
Endpoints
T
通信用構造体(struct)を作成
Datastore格納兼JSON通信用
サーバサイド
Google
Cloud
Endpoints
T
通信用構造体(struct)を作成
JSON Arrayでやりとりする場合は別の構
造体が必要
サーバサイド
Google
Cloud
Endpoints
T
通信用構造体(struct)を作成
QueryString、URL ParamもStructで表現
注釈を付けれる
サーバサイド
Google
Cloud
Endpoints
T
サービス(実処理)を作成
• 単純なメソッドを定義します。
• go-endpointsが変換したstructを
引数に渡してくれます。
サーバサイド
Google
Cloud
Endpoints
T
サービス(実処理)を作成
サーバサイド
Google
Cloud
Endpoints
T
脇道:goon
• goonはGo版NDBみたいなもの
• GAE/GのDatastore周りを楽にしてく
れる
• Key系の検索は全てin-memory,
Memcacheにキャッシュ/検索
サーバサイド
Google
Cloud
Endpoints
T
脇道:goon
goon無し
type Group struct {
Id int64 `datastore:"-" goon:"id"`
Name string
}
n := goon.NewGoon(r)
g := &Group{Name: "name"}
err := n.Put(g)
サーバサイド
Google
Cloud
Endpoints
T
脇道:goon
goon有り
サーバサイド
Google
Cloud
Endpoints
T
サービスを登録
• サービスをgo-endpontsに登録
サーバサイド
Google
Cloud
Endpoints
T
サーバサイド
Google
Cloud
Endpoints
T
app.yamlで設定
• go-endpontsが動くようにします。
application: gpc-ja-night-27-go-endpoints
version: v1
runtime: go
api_version: go1
handlers:
- url: /.*
script: _go_app
# ここが絶対に必要
- url: /_ah/spi/.*
script: _go_app
サーバサイド
Google
Cloud
Endpoints
T
起動
• appengine go SDK経由
$ goapp serve
サーバサイド
Google
Cloud
Endpoints
T
テスト
• http://localhost:8080/_ah/api/explor
er
とかに行けば試せる
サーバサイド
Google
Cloud
Endpoints
T
テスト
サーバサイド
Google
Cloud
Endpoints
T
リリース
• goapp deployでリリース
$ goapp deploy
Google
Cloud
Endpoints
T
http://goo.gl/248Dh3
使い所?
Google
Cloud
Endpoints
T
メリット
• 爆速スピンアップ
• 処理に集中できる
• テストしやすい気がする
gcp ja night #27 Google Cloud Endpoints with Golang

Mais conteúdo relacionado

Mais procurados

"Kongゲートウェイ2.5リリース" Kong Konnectアップデート オンラインミートアップ :kong 製品整理、優位性
"Kongゲートウェイ2.5リリース" Kong Konnectアップデート オンラインミートアップ :kong 製品整理、優位性"Kongゲートウェイ2.5リリース" Kong Konnectアップデート オンラインミートアップ :kong 製品整理、優位性
"Kongゲートウェイ2.5リリース" Kong Konnectアップデート オンラインミートアップ :kong 製品整理、優位性
Junji Nishihara
 

Mais procurados (20)

2021/03/19 パブリッククラウドを活かす運用プロセス自動化
2021/03/19 パブリッククラウドを活かす運用プロセス自動化2021/03/19 パブリッククラウドを活かす運用プロセス自動化
2021/03/19 パブリッククラウドを活かす運用プロセス自動化
 
Microsoft Graph APIを活用した社内アプリケーション開発
Microsoft Graph APIを活用した社内アプリケーション開発Microsoft Graph APIを活用した社内アプリケーション開発
Microsoft Graph APIを活用した社内アプリケーション開発
 
Power Automate for desktopとGoogle Apps Scriptの連携について
Power Automate for desktopとGoogle Apps Scriptの連携についてPower Automate for desktopとGoogle Apps Scriptの連携について
Power Automate for desktopとGoogle Apps Scriptの連携について
 
Introduction to extensions and other useful features for developing apps usin...
Introduction to extensions and other useful features for developing apps usin...Introduction to extensions and other useful features for developing apps usin...
Introduction to extensions and other useful features for developing apps usin...
 
Transfer Learning & API Azure
Transfer Learning & API AzureTransfer Learning & API Azure
Transfer Learning & API Azure
 
30min Serverless xTuber
30min Serverless xTuber30min Serverless xTuber
30min Serverless xTuber
 
2020/12/03 SaaS を正しい方向へ加速するフィードバックループ
2020/12/03 SaaS を正しい方向へ加速するフィードバックループ2020/12/03 SaaS を正しい方向へ加速するフィードバックループ
2020/12/03 SaaS を正しい方向へ加速するフィードバックループ
 
Machine configoperatorのちょっとイイかもしれない話
Machine configoperatorのちょっとイイかもしれない話 Machine configoperatorのちょっとイイかもしれない話
Machine configoperatorのちょっとイイかもしれない話
 
20180616 業務システムをAppServiceで運用しよう #きたあず #jazug
20180616 業務システムをAppServiceで運用しよう #きたあず #jazug20180616 業務システムをAppServiceで運用しよう #きたあず #jazug
20180616 業務システムをAppServiceで運用しよう #きたあず #jazug
 
Salesforce Lightning をやってみてあれこれ
Salesforce Lightning をやってみてあれこれSalesforce Lightning をやってみてあれこれ
Salesforce Lightning をやってみてあれこれ
 
Five Steps to Culture Change を日本語で解説する 2020/11/06
Five Steps to Culture Change を日本語で解説する 2020/11/06Five Steps to Culture Change を日本語で解説する 2020/11/06
Five Steps to Culture Change を日本語で解説する 2020/11/06
 
.NET の過去、現在、そして未来 ~ .NET 最新アップデート
.NET の過去、現在、そして未来 ~ .NET 最新アップデート.NET の過去、現在、そして未来 ~ .NET 最新アップデート
.NET の過去、現在、そして未来 ~ .NET 最新アップデート
 
Application development with c#, .net 6, blazor web assembly, asp.net web api...
Application development with c#, .net 6, blazor web assembly, asp.net web api...Application development with c#, .net 6, blazor web assembly, asp.net web api...
Application development with c#, .net 6, blazor web assembly, asp.net web api...
 
GitHub Actions で CI/CD
GitHub Actions で CI/CDGitHub Actions で CI/CD
GitHub Actions で CI/CD
 
仮想サーバは、もう不要?!今からIoTやるなら 「サーバレス・コンピューティング」
仮想サーバは、もう不要?!今からIoTやるなら「サーバレス・コンピューティング」仮想サーバは、もう不要?!今からIoTやるなら「サーバレス・コンピューティング」
仮想サーバは、もう不要?!今からIoTやるなら 「サーバレス・コンピューティング」
 
"Kongゲートウェイ2.5リリース" Kong Konnectアップデート オンラインミートアップ :kong 製品整理、優位性
"Kongゲートウェイ2.5リリース" Kong Konnectアップデート オンラインミートアップ :kong 製品整理、優位性"Kongゲートウェイ2.5リリース" Kong Konnectアップデート オンラインミートアップ :kong 製品整理、優位性
"Kongゲートウェイ2.5リリース" Kong Konnectアップデート オンラインミートアップ :kong 製品整理、優位性
 
AWSで開発するサーバレスAPIバックエンド
AWSで開発するサーバレスAPIバックエンドAWSで開発するサーバレスAPIバックエンド
AWSで開発するサーバレスAPIバックエンド
 
Introducing Elastic 8.1 Release - More Integration, Faster Indexing Speed, Lo...
Introducing Elastic 8.1 Release - More Integration, Faster Indexing Speed, Lo...Introducing Elastic 8.1 Release - More Integration, Faster Indexing Speed, Lo...
Introducing Elastic 8.1 Release - More Integration, Faster Indexing Speed, Lo...
 
Kong 概要
Kong 概要Kong 概要
Kong 概要
 
レガシー Web からの脱却 ~ 開発者が次に目指すべき Web アプリの姿とは?
レガシー Web からの脱却 ~ 開発者が次に目指すべき Web アプリの姿とは?レガシー Web からの脱却 ~ 開発者が次に目指すべき Web アプリの姿とは?
レガシー Web からの脱却 ~ 開発者が次に目指すべき Web アプリの姿とは?
 

Semelhante a gcp ja night #27 Google Cloud Endpoints with Golang

Dart flightschool cloudendpoint with dart
Dart flightschool cloudendpoint with dartDart flightschool cloudendpoint with dart
Dart flightschool cloudendpoint with dart
啓介 大橋
 
cli.go と cli-init で高速にコマンドラインツールを開発する / The command-line tool developed at hi...
cli.go と cli-init で高速にコマンドラインツールを開発する / The command-line tool developed at hi...cli.go と cli-init で高速にコマンドラインツールを開発する / The command-line tool developed at hi...
cli.go と cli-init で高速にコマンドラインツールを開発する / The command-line tool developed at hi...
Hidenori Takeshita
 

Semelhante a gcp ja night #27 Google Cloud Endpoints with Golang (20)

Dart flightschool cloudendpoint with dart
Dart flightschool cloudendpoint with dartDart flightschool cloudendpoint with dart
Dart flightschool cloudendpoint with dart
 
GDG Shikoku 2013
GDG Shikoku 2013GDG Shikoku 2013
GDG Shikoku 2013
 
[Cloud OnAir] クラウド移行でここは外せない絶対条件、Google Cloud Platform のセキュリティについて全て話します! (e-...
[Cloud OnAir] クラウド移行でここは外せない絶対条件、Google Cloud Platform のセキュリティについて全て話します! (e-...[Cloud OnAir] クラウド移行でここは外せない絶対条件、Google Cloud Platform のセキュリティについて全て話します! (e-...
[Cloud OnAir] クラウド移行でここは外せない絶対条件、Google Cloud Platform のセキュリティについて全て話します! (e-...
 
Google+APIをさわってみる。
Google+APIをさわってみる。Google+APIをさわってみる。
Google+APIをさわってみる。
 
cli.go と cli-init で高速にコマンドラインツールを開発する / The command-line tool developed at hi...
cli.go と cli-init で高速にコマンドラインツールを開発する / The command-line tool developed at hi...cli.go と cli-init で高速にコマンドラインツールを開発する / The command-line tool developed at hi...
cli.go と cli-init で高速にコマンドラインツールを開発する / The command-line tool developed at hi...
 
20111203 gdd2011フィードバック 公開用
20111203 gdd2011フィードバック 公開用20111203 gdd2011フィードバック 公開用
20111203 gdd2011フィードバック 公開用
 
Google I/O 2013に行ったついでにラスベガス戦果報告
Google I/O 2013に行ったついでにラスベガス戦果報告Google I/O 2013に行ったついでにラスベガス戦果報告
Google I/O 2013に行ったついでにラスベガス戦果報告
 
PhoneGapでWebアプリをスマホアプリ化
PhoneGapでWebアプリをスマホアプリ化PhoneGapでWebアプリをスマホアプリ化
PhoneGapでWebアプリをスマホアプリ化
 
Chrome Apps & Chromeウェブストア概要
Chrome Apps & Chromeウェブストア概要Chrome Apps & Chromeウェブストア概要
Chrome Apps & Chromeウェブストア概要
 
Dartでサーバレスサービス
DartでサーバレスサービスDartでサーバレスサービス
Dartでサーバレスサービス
 
Google I/O 2021 Flutter 全体報告
Google I/O 2021 Flutter 全体報告Google I/O 2021 Flutter 全体報告
Google I/O 2021 Flutter 全体報告
 
Google Cloud Platform は何がすごいのか?
Google Cloud Platform は何がすごいのか?Google Cloud Platform は何がすごいのか?
Google Cloud Platform は何がすごいのか?
 
.NET 最新ロードマップと今押さえておきたい技術要素
.NET 最新ロードマップと今押さえておきたい技術要素.NET 最新ロードマップと今押さえておきたい技術要素
.NET 最新ロードマップと今押さえておきたい技術要素
 
HTML5 のお話
HTML5 のお話HTML5 のお話
HTML5 のお話
 
DroidKaigi 2018 - Dialogflow for Android
DroidKaigi 2018 - Dialogflow for AndroidDroidKaigi 2018 - Dialogflow for Android
DroidKaigi 2018 - Dialogflow for Android
 
いまさら聞けない!HTML5超入門
いまさら聞けない!HTML5超入門いまさら聞けない!HTML5超入門
いまさら聞けない!HTML5超入門
 
Google for モバイル アプリ - コンテナ技術と Google Compute Engine で実現するクラウド時代のアプリ実行環境
Google for モバイル アプリ - コンテナ技術と Google Compute Engine で実現するクラウド時代のアプリ実行環境Google for モバイル アプリ - コンテナ技術と Google Compute Engine で実現するクラウド時代のアプリ実行環境
Google for モバイル アプリ - コンテナ技術と Google Compute Engine で実現するクラウド時代のアプリ実行環境
 
Goで作って配布するAzureコマンドラインユーティリティ
Goで作って配布するAzureコマンドラインユーティリティGoで作って配布するAzureコマンドラインユーティリティ
Goで作って配布するAzureコマンドラインユーティリティ
 
Angular 4がやってくる!? 新機能ダイジェスト
Angular 4がやってくる!? 新機能ダイジェストAngular 4がやってくる!? 新機能ダイジェスト
Angular 4がやってくる!? 新機能ダイジェスト
 
Namespace API を用いたマルチテナント型 Web アプリの実践
Namespace API を用いたマルチテナント型 Web アプリの実践Namespace API を用いたマルチテナント型 Web アプリの実践
Namespace API を用いたマルチテナント型 Web アプリの実践
 

Mais de 啓介 大橋 (7)

App Dojo 2017 12月 - VUI in your app with Dialogflow -
App Dojo 2017 12月 - VUI in your app with Dialogflow -App Dojo 2017 12月 - VUI in your app with Dialogflow -
App Dojo 2017 12月 - VUI in your app with Dialogflow -
 
GCPUG Shonan GAS & GAE
GCPUG Shonan GAS & GAEGCPUG Shonan GAS & GAE
GCPUG Shonan GAS & GAE
 
Dockerハンズオン
DockerハンズオンDockerハンズオン
Dockerハンズオン
 
Fusion360 meetup vol2 LT
Fusion360 meetup vol2 LTFusion360 meetup vol2 LT
Fusion360 meetup vol2 LT
 
パフォーマンスの良いGASの書き方 Best Practice
パフォーマンスの良いGASの書き方 Best Practiceパフォーマンスの良いGASの書き方 Best Practice
パフォーマンスの良いGASの書き方 Best Practice
 
Google Apps Scriptとは? Add-onとは?
Google Apps Scriptとは? Add-onとは?Google Apps Scriptとは? Add-onとは?
Google Apps Scriptとは? Add-onとは?
 
Tokyo gas #5_whatsnewinappsscript_公開用
Tokyo gas #5_whatsnewinappsscript_公開用Tokyo gas #5_whatsnewinappsscript_公開用
Tokyo gas #5_whatsnewinappsscript_公開用
 

gcp ja night #27 Google Cloud Endpoints with Golang