mirror of
https://dev.narayana.im/narayana/telegabber.git
synced 2026-08-05 04:07:07 +00:00
20 lines
698 B
Go
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
|
|
}
|