extended URL scheme

This commit is contained in:
ston1th 2020-06-03 23:45:54 +02:00
commit 0994baf5b0
4 changed files with 39 additions and 18 deletions

View file

@ -11,6 +11,7 @@ import (
var (
ErrNodesOffline = errors.New("one or more nodes are offline")
ErrNodesNotSearched = errors.New("one or more nodes could not be searched")
ErrEmptyID = errors.New("id is empty")
)
type NodeStatus string
@ -95,11 +96,15 @@ func (c *NodeClient) FindServerByName(ctx context.Context, name string) (s *Serv
}
func (c *NodeClient) FindServerByID(ctx context.Context, id string) (s *Server, err error) {
if id == "" {
err = ErrEmptyID
return
}
return c.FindServer(ctx, "", id)
}
func (c *NodeClient) FindServerByURL(ctx context.Context, url string) (s *Server, err error) {
_, id, err := ParseURL(url)
_, _, id, err := ParseURL(url)
if err != nil {
return
}