Skip to content

Commit

Permalink
added go complextest
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto De Ioris committed Nov 5, 2012
1 parent 6d9de4c commit e23766e
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions 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, "<h1>Hi there, I love %s!</h1>", 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)
}

0 comments on commit e23766e

Please sign in to comment.