...

Source file src/discovery/config/config.go

Documentation: discovery/config

     1  /*
     2   * P2PFaaS - A framework for FaaS Load Balancing
     3   * Copyright (c) 2019. 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 config implements configuration of the service
    20  package config
    21  
    22  import (
    23  	"discovery/log"
    24  )
    25  
    26  const Version = "0.0.4b"
    27  
    28  const DataPath = "/data"
    29  const ConfigurationFileName = "p2p_faas-discovery.json"
    30  
    31  const GetParamIp = "p2pfaas-machine-ip"
    32  const GetParamName = "p2pfaas-machine-name"
    33  const GetParamGroupName = "p2pfaas-machine-group-name"
    34  
    35  const DefaultDataPath = "/data"
    36  const DefaultListeningHost = "0.0.0.0"
    37  const DefaultListeningPort = 19000
    38  const DefaultPollTime = 120      // seconds
    39  const DefaultPollTimeoutTime = 5 // seconds
    40  const DefaultIfaceName = "eth0"
    41  
    42  // DefaultMachineDeadPollsRemovingThreshold tells the number of times we need to poll the machine for removing it from the db
    43  const DefaultMachineDeadPollsRemovingThreshold = 20
    44  
    45  const EnvRunningEnvironment = "P2PFAAS_DEV_ENV"
    46  const EnvInitServers = "P2PFAAS_INIT_SERVERS"
    47  const EnvDataPath = "P2PFAAS_DATA_PATH"
    48  const EnvPollTime = "P2PFAAS_POLL_TIME"
    49  const EnvListeningHost = "P2PFAAS_LISTENING_HOST"
    50  const EnvListeningPort = "P2PFAAS_LISTENING_PORT"
    51  const EnvPollTimeout = "P2PFAAS_POLL_TIMEOUT"
    52  const EnvMachineDeadPollsRemovingThreshold = "P2PFAAS_MACHINE_DEAD_POLLS_THRESHOLD"
    53  const EnvDefaultIface = "P2PFAAS_DEFAULT_IFACE"
    54  
    55  const RunningEnvironmentProduction = "production"
    56  const RunningEnvironmentDevelopment = "development"
    57  
    58  // Configuration general parsed configuration
    59  var configurationDynamic *ConfigurationDynamic
    60  var configurationDynamicReadFromFile = false
    61  
    62  var configurationStatic *ConfigurationStatic
    63  
    64  func init() {
    65  	InitConfigurationStatic()
    66  	InitConfigurationDynamic()
    67  
    68  	log.Log.Info("Starting in %s environment", GetRunningEnvironment())
    69  	log.Log.Infof("Init with %s", GetConfigurationStaticString())
    70  	log.Log.Infof("Init with MachineIp=%s, MachineId=%s, MachineGroupName=%s, loadedFromFile=%t",
    71  		GetMachineIp(), GetMachineId(), GetMachineGroupName(), configurationDynamicReadFromFile)
    72  }
    73  
    74  func Start() {
    75  
    76  }
    77  

View as plain text