From e23766e4d0bb04e7c084cc3a37fa8ecb265e5f43 Mon Sep 17 00:00:00 2001 From: Roberto De Ioris Date: Mon, 5 Nov 2012 10:37:07 +0100 Subject: [PATCH] added go complextest --- t/go/complextest.go | 57 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 t/go/complextest.go diff --git a/t/go/complextest.go b/t/go/complextest.go new file mode 100644 index 0000000000..ab9c74c46d --- /dev/null +++ b/t/go/complextest.go @@ -0,0 +1,57 @@ +package main + +import "uwsgi" +import "fmt" +import "net/http" +import "time" + +type App struct { + uwsgi.App +} + +func (app *App) Banner() { + fmt.Println("I am GO !!!") +} + +func (app *App) PostFork() { + if app.WorkerId() == 0 { + fmt.Println("PoSt FoRk on mule", app.MuleId(), "!!!") + } else { + fmt.Println("PoSt FoRk on worker", app.WorkerId(), "!!!") + } +} + +func (app *App) RequestHandler(w http.ResponseWriter, r *http.Request) { + app.Signal(17) + fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:]) + fmt.Fprintf(w, "

Hi there, I love %s!

", r.URL.Path[1:]) + fmt.Println("LOGSIZE: ", app.LogSize()) + go slow() +} + +func hello(signum int) { + fmt.Println("Ciao, 3 seconds elapsed or RequestHandler() called") +} + +func hello2(signum int) { + fmt.Println("I am an rb_timer running on mule", u.MuleId()) +} + +func slow() { + time.Sleep(8 * time.Second) + fmt.Println("8 seconds ELAPSED !!!") +} + +func (app *App) PostInit() { + app.RegisterSignal(17, "", hello) + app.AddTimer(17, 3) + + app.RegisterSignal(30, "mule1", hello2) + app.AddTimer(30, 5) +} + +var u App + +func main() { + uwsgi.Run(&u) +}