Create a gist now

Instantly share code, notes, and snippets.

@qushot /app.yaml Secret
Created Sep 15, 2017

What would you like to do?
ファイアウォールルール確認用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