Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
ekzyis | 8c0b262282 |
|
@ -53,6 +53,11 @@ func sseHandler(invSrc chan *lightning.Invoice) echo.HandlerFunc {
|
||||||
ticker := time.NewTicker(1 * time.Second)
|
ticker := time.NewTicker(1 * time.Second)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
i := 0
|
||||||
|
|
||||||
|
ticker2 := time.NewTicker(1 * time.Second)
|
||||||
|
defer ticker2.Stop()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-c.Request().Context().Done():
|
case <-c.Request().Context().Done():
|
||||||
|
@ -66,11 +71,19 @@ func sseHandler(invSrc chan *lightning.Invoice) echo.HandlerFunc {
|
||||||
if err := event.MarshalTo(w); err != nil {
|
if err := event.MarshalTo(w); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
case inv := <-invSrc:
|
case <-ticker2.C:
|
||||||
buf := templ.GetBuffer()
|
buf := templ.GetBuffer()
|
||||||
defer templ.ReleaseBuffer(buf)
|
defer templ.ReleaseBuffer(buf)
|
||||||
|
|
||||||
if err := components.Zap(inv).Render(c.Request().Context(), buf); err != nil {
|
inv := lightning.Invoice{
|
||||||
|
PaymentHash: fmt.Sprintf("test-%d", i),
|
||||||
|
Description: "test",
|
||||||
|
Msats: 1000,
|
||||||
|
CreatedAt: time.Now(),
|
||||||
|
ConfirmedAt: time.Now(),
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := components.Zap(&inv).Render(c.Request().Context(), buf); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +98,12 @@ func sseHandler(invSrc chan *lightning.Invoice) echo.HandlerFunc {
|
||||||
if err := event.MarshalTo(w); err != nil {
|
if err := event.MarshalTo(w); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
if i > 10 {
|
||||||
|
ticker2.Stop()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
w.Flush()
|
w.Flush()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue