Galliard is a modular, idiomatic, and extensible Bayeux protocol server library for Go.
It’s designed for building real-time, channel-based publish/subscribe systems—think chat, live dashboards, or event streaming.
Inspired by Faye and CometD, Galliard aims to be simple, robust, and easy to extend.
- Bayeux protocol: handshake, connect, subscribe, unsubscribe, publish, disconnect
- Channel-based pub/sub: subscribe and publish to any channel
- Thread-safe: fine-grained locking for high concurrency
- Minimal public API: just what you need, nothing you don’t
- Extensible: ready for server-side hooks, custom channels, and more
Here’s what’s ready and what’s coming soon:
- Bayeux protocol core (handshake, connect, subscribe, unsubscribe, publish, disconnect)
- Channel-based pub/sub
- Thread-safe session and channel management
- Per-session advice and protocol-compliant error handling
- Minimal, clean public API (
Server,NewServer,HandleMessage) - GoDoc comments and usage examples
- Server-side event hooks (
Subscribe,OnDisconnect, etc.) - Go Bayeux client package
- HTTP/WebSocket transport helpers
- More real-world examples and advanced documentation
Want to help or need a feature? Open an issue or PR!
go get github.com/charlinchui/galliardimport (
"github.com/charlinchui/galliard/server"
"github.com/charlinchui/galliard/message"
"fmt"
)
func main() {
srv := server.NewServer()
// Example: Handle a handshake
req := &message.BayeuxMessage{Channel: "/meta/handshake"}
resp := srv.HandleMessage(req)
fmt.Printf("Handshake response: %+v\n", resp)
}- Handshake:
Client sends/meta/handshake, receives aclientId. - Subscribe:
Client sends/meta/subscribewithclientIdand channel. - Publish:
Client sends a message to a channel. - Connect:
Client sends/meta/connectto receive messages (long-polling or WebSocket). - Unsubscribe/Disconnect:
Client can unsubscribe or disconnect gracefully.
galliard/
server/ # Bayeux server implementation (public API)
message/ # Bayeux message and advice types (public API)
internal/ # Internal packages (client, channel, utils)
type Server
The Bayeux server.func NewServer() *Server
Create a new server.func (s *Server) HandleMessage(msg *message.BayeuxMessage) *message.BayeuxMessage
Process a Bayeux message and get a response.type BayeuxMessage
The protocol message type (inmessagepackage).type Advice
Connection advice for clients (inmessagepackage).
- Server-side event hooks:
(e.g.,Subscribe,OnDisconnect) are planned for Go-side event handling. - Custom channels and business logic:
Can be implemented by extending the server or adding hooks. - Client package:
A Go Bayeux client is on the roadmap.
go test ./...Galliard is open to contributions!
If you have ideas, bug reports, or want to help with features, please open an issue or pull request.
Let’s make real-time Go apps easy and fun together.
MIT License
Galliard: Real-time, reliable, and readable pub/sub for Go.