MCPcopy
hub / github.com/ha/doozerd / evServer

Function evServer

src/pkg/web/web.go:67–100  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

65}
66
67func evServer(w http.ResponseWriter, r *http.Request) {
68 wevs := make(chan store.Event)
69 path := r.URL.Path[len("/$events"):]
70
71 glob, err := store.CompileGlob(path + "**")
72 if err != nil {
73 w.WriteHeader(400)
74 return
75 }
76
77 rev, _ := Store.Snap()
78
79 go func() {
80 walk(path, Store, wevs)
81 for {
82 ch, err := Store.Wait(glob, rev+1)
83 if err != nil {
84 break
85 }
86 ev, ok := <-ch
87 if !ok {
88 break
89 }
90 wevs <- ev
91 rev = ev.Rev
92 }
93 close(wevs)
94 }()
95
96 websocket.Handler(func(ws *websocket.Conn) {
97 send(ws, path, wevs)
98 ws.Close()
99 }).ServeHTTP(w, r)
100}
101
102func viewHtml(w http.ResponseWriter, r *http.Request) {
103 if !strings.HasSuffix(r.URL.Path, "/") {

Callers

nothing calls this directly

Calls 5

sendFunction · 0.85
SnapMethod · 0.80
WaitMethod · 0.80
ServeHTTPMethod · 0.80
walkFunction · 0.70

Tested by

no test coverage detected