telegabber/e2ee/registry.go
2026-07-28 19:10:01 -04:00

20 lines
698 B
Go

package e2ee
// backends is a process-wide registry of available Backend implementations,
// keyed by Backend.Name(). Backends self-register from an init() function
// in their own package (mirroring the self-registration idiom already used
// by xmpp/extensions for stanza payload types), so importing a backend
// package for its side effect is what makes it available here.
var backends = map[string]Backend{}
// Register adds b to the registry, keyed by b.Name(). Call from the
// backend package's own init().
func Register(b Backend) {
backends[b.Name()] = b
}
// Get looks up a registered backend by name.
func Get(name string) (Backend, bool) {
b, ok := backends[name]
return b, ok
}