66 "strconv"
77 "time"
88
9+ "github.com/lithammer/shortuuid"
910 "github.com/serverledge-faas/serverledge/internal/config"
1011 "github.com/serverledge-faas/serverledge/utils"
11- "github.com/lithammer/shortuuid"
1212 _ "go.etcd.io/etcd/client/v3"
1313 clientv3 "go.etcd.io/etcd/client/v3"
1414 "golang.org/x/net/context"
@@ -17,14 +17,16 @@ import (
1717var BASEDIR = "registry"
1818var TTL = config .GetInt (config .REGISTRATION_TTL , 20 ) // lease time in Seconds
1919
20+ var RegisteredLocalIP string = "127.0.0.1"
21+
2022// getEtcdKey append to a given unique id the logical path depending on the Area.
2123// If it is called with an empty string it returns the base path for the current local Area.
2224func (r * Registry ) getEtcdKey (id string ) (key string ) {
2325 return fmt .Sprintf ("%s/%s/%s" , BASEDIR , r .Area , id )
2426}
2527
2628// RegisterToEtcd make a registration to the local Area; etcd put operation is performed
27- func (r * Registry ) RegisterToEtcd (hostport string ) (string , error ) {
29+ func (r * Registry ) RegisterToEtcd () (string , error ) {
2830 etcdClient , err := utils .GetEtcdClient ()
2931 if err != nil {
3032 log .Fatal (UnavailableClientErr )
@@ -41,6 +43,7 @@ func (r *Registry) RegisterToEtcd(hostport string) (string, error) {
4143 return "" , err
4244 }
4345
46+ hostport := fmt .Sprintf ("http://%s:%d" , RegisteredLocalIP , config .GetInt (config .API_PORT , 1323 ))
4447 log .Printf ("Registration key: %s\n " , r .Key )
4548 // save couple (id, hostport) to the correct Area-dir on etcd
4649 _ , err = etcdClient .Put (ctx , r .Key , hostport , clientv3 .WithLease (resp .ID ))
0 commit comments