...

Package service_discovery

import "scheduler/service_discovery"
Overview
Index

Overview ▾

Package service_discovery implements all functions that made possible the communication with the service_discovery service.

The package when init checks if the service_discovery service is available for getting its configuration, if it is not then the scheduler is not started and the check is done every 5 seconds.

func GetCachedMachineNumber

func GetCachedMachineNumber() int64

GetCachedMachineNumber returns the number of machines of the last call to machine list

func GetCachedMachinesIpsList

func GetCachedMachinesIpsList() ([]string, error)

func GetMachineIpAtIndex

func GetMachineIpAtIndex(i int64, cached bool) (string, error)

GetMachineIpAtIndex returns the machine ip at index i

func GetMachinesIpsList

func GetMachinesIpsList() ([]string, error)

GetMachinesIpsList get the list of known server by asking the backend stack-service that is running in the same machine of this service

func GetNRandomMachines

func GetNRandomMachines(n uint, cached bool) ([]string, error)

GetNRandomMachines returns N different random servers (ip addresses) from the list

func GetPeerDescriptor

func GetPeerDescriptor(timings *types.Timings) types.PeersListMember

GetPeerDescriptor Generates the PeerListMember for the current node

func Start

func Start()

type ErrorCannotGetServerList

type ErrorCannotGetServerList struct {
    // contains filtered or unexported fields
}

func (ErrorCannotGetServerList) Error

func (e ErrorCannotGetServerList) Error() string

type Machine

type Machine struct {
    ID        int64  `json:"_id" bson:"_id"`
    IP        string `json:"ip" bson:"ip"`
    Name      string `json:"name" bson:"name"`
    GroupName string `json:"group_name" bson:"group_name"`
    // Ping tells the ping, in seconds, of the last poll
    Ping float64 `json:"ping" bson:"ping"` // ms
    // LastUpdate tells the time of the last update
    LastUpdate int64 `json:"last_update" bson:"last_update"`
    // Alive tells if the machine can currently be returned in the list of machine that we known. This parameter is set
    // to false is the machine has been just added or it timed out
    Alive bool `json:"alive" bson:"alive"` // set to not alive when the machine has to be polled
    // DeadPolls tells the number of consecutive times the machine timed out. This is set to 0 when the machine replies
    // correctly
    DeadPolls uint `json:"dead_polls" bson:"dead_polls"`
}

type ServiceConfiguration

type ServiceConfiguration struct {
    MachineIp       string   `json:"machine_ip" bson:"machine_ip"`
    MachineId       string   `json:"machine_id" bson:"machine_id"`
    MachineFogNetId string   `json:"machine_fog_net_id" bson:"machine_fog_net_id"`
    InitServers     []string `json:"init_servers" bson:"init_servers"`
}
var Configuration *ServiceConfiguration

func GetConfiguration

func GetConfiguration() (*ServiceConfiguration, error)