...

Source file src/scheduler/service_discovery/discovery.go

Documentation: scheduler/service_discovery

     1  /*
     2   * P2PFaaS - A framework for FaaS Load Balancing
     3   * Copyright (c) 2019 - 2022. Gabriele Proietti Mattia <pm.gabriele@outlook.com>
     4   *
     5   * This program is free software: you can redistribute it and/or modify
     6   * it under the terms of the GNU General Public License as published by
     7   * the Free Software Foundation, either version 3 of the License, or
     8   * (at your option) any later version.
     9   *
    10   * This program is distributed in the hope that it will be useful,
    11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13   * GNU General Public License for more details.
    14   *
    15   * You should have received a copy of the GNU General Public License
    16   * along with this program.  If not, see <https://www.gnu.org/licenses/>.
    17   */
    18  
    19  // Package service_discovery implements all functions that made possible the communication with the service_discovery service.
    20  //
    21  // The package when init checks if the service_discovery service is available for getting its configuration, if it is not then the
    22  // scheduler is not started and the check is done every 5 seconds.
    23  package service_discovery
    24  
    25  import (
    26  	s_config "scheduler/config"
    27  	"scheduler/log"
    28  	"time"
    29  )
    30  
    31  func init() {
    32  	// try to get service_discovery configuration
    33  	log.Log.Debugf("Trying to get configuration from service_discovery service")
    34  	for {
    35  		config, err := GetConfiguration()
    36  		if err != nil {
    37  			log.Log.Warningf("Cannot retrieve discovery configuration at %s:%d, retrying in 5 seconds...", s_config.GetServiceDiscoveryListeningHost(), s_config.GetServiceLearningListeningPort())
    38  			time.Sleep(5 * time.Second)
    39  			continue
    40  		}
    41  		Configuration = config
    42  		log.Log.Infof("Init machine as %s (%s) with service_discovery configuration ", Configuration.MachineId, Configuration.MachineIp)
    43  		break
    44  	}
    45  }
    46  
    47  func Start() {
    48  
    49  }
    50  

View as plain text