Commit 53542c44 authored by vicotor's avatar vicotor

update config

parent dd1bff0b
host="127.0.0.1"
remote_host=""
local_host="127.0.0.1"
port=10001
metrics_port = 28010
private_key = "E671C143A110C239B563F702E9F4017CA6B2B2912F675EED9AA4FED684EB30CC"
......
......@@ -36,7 +36,8 @@ type TickerConfig struct {
type Config struct {
PrivateKey string `json:"private_key" toml:"private_key"`
Host string `json:"host" toml:"host"`
RemoteHost string `json:"remote_host" toml:"remote_host"`
LocalHost string `json:"local_host" toml:"local_host"`
Port int `json:"port" toml:"port"`
//Endpoint string `json:"endpoint" toml:"endpoint"`
MetricPort int `json:"metrics_port" toml:"metrics_port"`
......@@ -68,7 +69,11 @@ func GetConfig() *Config {
return _cfg
}
func (conf *Config) PublicEndpoint() string {
return fmt.Sprintf("%s:%d", conf.Host, conf.Port)
return fmt.Sprintf("%s:%d", conf.RemoteHost, conf.Port)
}
func (conf *Config) LocalEndpoint() string {
return fmt.Sprintf("%s:%d", conf.LocalHost, conf.Port)
}
func (conf *Config) ApiEndpoint() string {
......
......@@ -88,7 +88,7 @@ func (s *RegistryService) registry(rdb *redis.Client) error {
addr := utils.PrivatekeyToHex(priv)
pubHex := utils.PubkeyToHex(&priv.PublicKey)
endpoint := fmt.Sprintf("%s:%d", s.conf.Host, s.conf.Port)
endpoint := s.conf.PublicEndpoint()
err = rdb.HSet(context.Background(), config.NODE_MANAGER_SET+addr, RegistryInfo{
Pubkey: pubHex,
......
......@@ -22,16 +22,16 @@ func (wm *WorkerManager) AddWorker(worker *Worker) error {
}
}
// add worker to redis queue
if err := wm.rdb.SAdd(context.Background(), config.WORKER_STATUS_PREFIX+worker.addr, config.GetConfig().PublicEndpoint()).Err(); err != nil {
if err := wm.rdb.SAdd(context.Background(), config.WORKER_STATUS_PREFIX+worker.addr, config.GetConfig().LocalEndpoint()).Err(); err != nil {
return err
}
return nil
}
func (wm *WorkerManager) ActiveWorker(worker *Worker) {
wm.rdb.SAdd(context.Background(), config.WORKER_STATUS_PREFIX+worker.addr, config.GetConfig().PublicEndpoint())
wm.rdb.SAdd(context.Background(), config.WORKER_STATUS_PREFIX+worker.addr, config.GetConfig().LocalEndpoint())
}
func (wm *WorkerManager) InActiveWorker(worker *Worker) {
wm.rdb.SRem(context.Background(), config.WORKER_STATUS_PREFIX+worker.addr, config.GetConfig().PublicEndpoint())
wm.rdb.SRem(context.Background(), config.WORKER_STATUS_PREFIX+worker.addr, config.GetConfig().LocalEndpoint())
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment