stuffs
This commit is contained in:
25
server-registry.go
Normal file
25
server-registry.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user