github.com/m-lab/locate@v0.17.6/static/configs.go (about)

     1  // Package static contains static information for the locate service.
     2  package static
     3  
     4  import (
     5  	"net/url"
     6  	"time"
     7  )
     8  
     9  // Constants used by the locate service, clients, and target servers accepting
    10  // access tokens issued by the locate service.
    11  const (
    12  	IssuerLocate               = "locate"
    13  	AudienceLocate             = "locate"
    14  	IssuerMonitoring           = "monitoring"
    15  	SubjectMonitoring          = "monitoring"
    16  	WebsocketBufferSize        = 1 << 10 // 1024 bytes.
    17  	WebsocketReadDeadline      = 30 * time.Second
    18  	BackoffInitialInterval     = time.Second
    19  	BackoffRandomizationFactor = 0.5
    20  	BackoffMultiplier          = 2
    21  	BackoffMaxInterval         = 5 * time.Minute
    22  	BackoffMaxElapsedTime      = 0
    23  	HealthEndpointTimeout      = 5 * time.Second
    24  	HeartbeatPeriod            = 10 * time.Second
    25  	MemorystoreExportPeriod    = 10 * time.Second
    26  	PrometheusCheckPeriod      = time.Minute
    27  	RedisKeyExpirySecs         = 30
    28  	RegistrationLoadMin        = 3 * time.Hour
    29  	RegistrationLoadExpected   = 12 * time.Hour
    30  	RegistrationLoadMax        = 24 * time.Hour
    31  	EarthHalfCircumferenceKm   = 20038
    32  	EarlyExitParameter         = "early_exit"
    33  	EarlyExitDefaultValue      = "250"
    34  	MaxCwndGainParameter       = "max_cwnd_gain"
    35  	MaxElapsedTimeParameter    = "max_elapsed_time"
    36  	CountryParameter           = "country"
    37  	SiteParameter              = "site"
    38  	StrictParameter            = "strict"
    39  	OrgParameter               = "org"
    40  	MachineTypeParameter       = "machine-type"
    41  )
    42  
    43  // URL creates inline url.URLs.
    44  func URL(scheme, port, path string) url.URL {
    45  	return url.URL{
    46  		Scheme: scheme,
    47  		Host:   port,
    48  		Path:   path,
    49  	}
    50  }
    51  
    52  // ServiceParams is a map of common parameters passed in by services (as URL params)
    53  // with corresponding probabilities set by the Locate.
    54  var ServiceParams = map[string]float64{
    55  	EarlyExitParameter:      0.9,
    56  	MaxCwndGainParameter:    1,
    57  	MaxElapsedTimeParameter: 1,
    58  	CountryParameter:        1,
    59  	SiteParameter:           1,
    60  	StrictParameter:         1,
    61  	OrgParameter:            1,
    62  	MachineTypeParameter:    1,
    63  }
    64  
    65  // Configs is a temporary, static mapping of service names and their set of
    66  // associated ports. Ultimately, this will be discovered dynamically as
    67  // service heartbeats register with the locate service.
    68  var Configs = map[string]Ports{
    69  	"ndt/ndt7": {
    70  		URL("ws", "", "/ndt/v7/upload"),
    71  		URL("ws", "", "/ndt/v7/download"),
    72  		URL("wss", "", "/ndt/v7/upload"),
    73  		URL("wss", "", "/ndt/v7/download"),
    74  	},
    75  	"ndt/ndt5": {
    76  		// TODO: should we report the raw port? Should we use the envelope
    77  		// service in a focused configuration? Should we retire the raw protocol?
    78  		// TODO: change ws port to 3002.
    79  		URL("ws", ":3001", "/ndt_protocol"),
    80  		URL("wss", ":3010", "/ndt_protocol"),
    81  	},
    82  	"neubot/dash": {
    83  		URL("https", "", "/negotiate/dash"),
    84  	},
    85  	"wehe/replay": {
    86  		URL("wss", ":4443", "/v0/envelope/access"),
    87  	},
    88  	"iperf3/test": {
    89  		URL("wss", "", "/v0/envelope/access"),
    90  	},
    91  }
    92  
    93  // Ports maps names to URLs.
    94  type Ports []url.URL
    95  
    96  // LegacyServices associates legacy mlab-ns experiment target names with their
    97  // v2 equivalent.
    98  var LegacyServices = map[string]string{
    99  	"neubot/dash": "neubot",
   100  	"wehe/replay": "wehe", // TODO: replace with heartbeat health.
   101  	"iperf3/test": "ndt7", // TODO: replace with heartbeat health.
   102  	"ndt/ndt5":    "ndt_ssl",
   103  	"ndt/ndt7":    "ndt7",
   104  }