package main
import (
"fmt"
"http"
"log"
"time"
)
func main() {
http.HandleFunc("/test/", feed)
if err := http.ListenAndServe("127.0.0.1:8080", nil); err != nil {
log.Print(err)
}
}
func feed(w http.ResponseWriter, r *http.Request) {
ch := time.Tick(10000000000)
chunkedw := http.NewChunkedWriter(w)
fmt.Fprintf(chunkedw, "Goconntest welcomes you! Your Id: %s\n",
r.URL.String())
for N := 1; ; N++ {
<-ch
n, err := fmt.Fprintf(chunkedw, "Chunk %d for id %s\n", N,
r.URL.String())
if err != nil {
log.Print(err)
break
} else if n == 0 {
log.Print("Nothing written")
break
}
}
chunkedw.Close()
}
--
Fabian
What do you mean? It's quite easy to implement comet-style http
handlers in Go already.
Or are you referring to the Channels API?
Andrew
> What do you mean? It's quite easy to implement comet-style httpCan you elaborate on that? Are there any examples of implementing
> handlers in Go already.
comet-style http in Go?
What are the limitations of running an app
like that on appengine-go?
Here's a complete framework for doing comet-style stuff in Go:
https://github.com/madari/go-socket.io
I could put together a quick example just using the Go standard
libraries, if you're really interested.
> What are the limitations of running an app
> like that on appengine-go?
>
> I'm interesting in building a web app using Go and the Channels API,
> but in the meantime comet-style http should work.
As Brad said, App Engine doesn't support streaming responses so the
comet technique won't work.
Don't worry, the Channel API for Go will be available soon.
Andrew
Thanks Andrew for that link! Due to probably very unfortunate choices, none of
my search patterns found that package for me.
--
Fabian
On Jun 22, 2011 7:40 AM, "murz" <mmurr...@gmail.com> wrote:
> > Don't worry, the Channel API for Go will be available soon.
>
> Any clue as to when it will be available?
It's available now.
Dave.