migrate to integer ID

This commit is contained in:
ston1th 2021-11-28 11:50:56 +01:00
commit 7ff2a92118
4 changed files with 27 additions and 22 deletions

11
pool.go
View file

@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"net/http"
"strconv"
)
var (
@ -106,7 +105,7 @@ type poolMembers []poolMember
func (pms poolMembers) ServerList() (sl ServerRefList) {
for _, pm := range pms {
sl = append(sl, &ServerRef{
ID: strconv.Itoa(pm.ID),
ID: pm.ID,
Name: pm.Name,
Node: pm.Node,
})
@ -133,7 +132,7 @@ func (c *PoolClient) ListMembers(ctx context.Context, name string) (sl ServerRef
return
}
func (c *PoolClient) FindServer(ctx context.Context, poolname, servername, id string) (s *ServerRef, err error) {
func (c *PoolClient) FindServer(ctx context.Context, poolname, servername string, id int) (s *ServerRef, err error) {
var pools []string
if poolname != "" {
pools = append(pools, poolname)
@ -149,7 +148,7 @@ func (c *PoolClient) FindServer(ctx context.Context, poolname, servername, id st
return nil, err
}
for _, srv := range sl {
if id != "" && srv.ID == id {
if id != -1 && srv.ID == id {
srv.Pool = pool
return srv, nil
}
@ -163,10 +162,10 @@ func (c *PoolClient) FindServer(ctx context.Context, poolname, servername, id st
}
func (c *PoolClient) FindServerByName(ctx context.Context, poolname, servername string) (s *ServerRef, err error) {
return c.FindServer(ctx, poolname, servername, "")
return c.FindServer(ctx, poolname, servername, -1)
}
func (c *PoolClient) FindServerByID(ctx context.Context, poolname, id string) (s *ServerRef, err error) {
func (c *PoolClient) FindServerByID(ctx context.Context, poolname string, id int) (s *ServerRef, err error) {
return c.FindServer(ctx, poolname, "", id)
}