Closed gedw99 closed 7 months ago
I didn't know about that thanks for the reference.
I'm still not exactly sure how I want the integration to go. But basically I'd like some way to do live updates to an htmx page with SSE or websockets.
the caddy-nats-bridge is definitely not for what you want then.
You might like this one as it's designed to work with Pub sub systems. I use it because it supports web and fat golang apps. So she and http is all I need for networking then.
https://github.com/tmaxmax/go-sse is one of the many use libs that is designed to have a message broker under it like NATS, but it does not have it let.
https://github.com/r3labs/sse is mega popular one too with also have a golang client
I'd like to do it all within a template definition if possible, loosely basing it on this guide: https://thedevelopercafe.com/articles/server-sent-events-in-go-595ae2740c7a
{{define "SSE:GET /events"}}
{{$userid := .Req.Header.Get "Remote-User"}}
{{range $msg := .Subscribe (printf "user.%s.feed_counts" $userid)}}
id: {{$msg.Id}}
data: {{.Template "feed_count_component" ($msg) | toJson}}
{{-.Flush}}
{{end}}
{{end}}
This might require a different buffering strategy compared to what xtemplate does today.
sounds good
SSE is implemented now. You can see some examples in the integration/templates directory if you're curious what it looks like:
https://github.com/charbonnierg/caddy-nats for nats does auth call out
https://www.youtube.com/watch?v=Ds71axJRFm0&ab_channel=Synadia is excellent for showing how rot use the new stuff in ants 2.0. Auth Call out demo as well.
It's been a minute, but I pushed an early version of the nats provider to the next
branch, along with the skeleton of an IM demo:
https://github.com/infogulch/xtemplate/blob/next/test/templates/nats/index.html
It's been a minute, but I pushed an early version of the nats provider to the
next
branch, along with the skeleton of an IM demo:https://github.com/infogulch/xtemplate/blob/next/test/templates/nats/index.html
this looks like a really great start. I will have a play with this tonight.
The latest release adds nats and natskv providers, so I'm closing as completed. 🎉
I'm curious to hear feedback about it.
The way this is implemented makes it impossible to configure a nats kv and nats conn that use the same internal server from json or cli config. Not sure how to resolve this.
this might match up with your TODO requirements ?
https://github.com/sandstorm/caddy-nats-bridge