Skip to content

Instantly share code, notes, and snippets.

@qushot

qushot/app.yaml Secret

Created September 15, 2017 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qushot/f2c9f8c8723bd554c3b7923dbbb83334 to your computer and use it in GitHub Desktop.
Save qushot/f2c9f8c8723bd554c3b7923dbbb83334 to your computer and use it in GitHub Desktop.
ファイアウォールルール確認用GAEアプリケーション(Cron, Taskqueue対応版)
application: YOUR_PROJECT_ID
version: X
runtime: go
api_version: go1.8
handlers:
- url: /.*
script: _go_app
cron:
- description: cron jobs
url: /cron
schedule: every 1 hours
package demo
import (
"fmt"
"net/http"
"google.golang.org/appengine"
"google.golang.org/appengine/log"
"google.golang.org/appengine/taskqueue"
)
func rootHandler(w http.ResponseWriter, r *http.Request) {
ctx := appengine.NewContext(r)
log.Infof(ctx, "Request from IP Address \"%v\"\n", r.RemoteAddr)
fmt.Fprintln(w, "hello")
t := taskqueue.NewPOSTTask("/task", nil)
taskqueue.Add(ctx, t, "myqueue")
}
func taskQueueHandler(w http.ResponseWriter, r *http.Request) {
ctx := appengine.NewContext(r)
log.Infof(ctx, "TaskQueue IP Address \"%v\"\n", r.RemoteAddr)
}
func cronHandler(w http.ResponseWriter, r *http.Request) {
ctx := appengine.NewContext(r)
log.Infof(ctx, "Cron IP Address \"%v\"\n", r.RemoteAddr)
}
func init() {
http.HandleFunc("/", rootHandler)
http.HandleFunc("/task", taskQueueHandler)
http.HandleFunc("/cron", cronHandler)
}
queue:
- name: myqueue
rate: 1/s
max_concurrent_requests: 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment