This commit is contained in:
matst80
2024-11-07 22:57:18 +01:00
parent 0f23ae0e9a
commit ae421674d2
9 changed files with 542 additions and 112 deletions

25
server-registry.go Normal file
View File

@@ -0,0 +1,25 @@
package main
import "fmt"
type Registry interface {
Register(address string, id string) error
Get(id string) (*string, error)
}
type MemoryRegistry struct {
registry map[string]string
}
func (r *MemoryRegistry) Register(address string, id string) error {
r.registry[id] = address
return nil
}
func (r *MemoryRegistry) Get(id string) (*string, error) {
addr, ok := r.registry[id]
if !ok {
return nil, fmt.Errorf("id not found")
}
return &addr, nil
}