Jelajahi Sumber

add comments to exported funcs

Abhishek Kondur 2 tahun lalu
induk
melakukan
b618a8f81d
2 mengubah file dengan 19 tambahan dan 12 penghapusan
  1. 4 2
      logic/timer.go
  2. 15 10
      servercfg/serverconf.go

+ 4 - 2
logic/timer.go

@@ -15,6 +15,9 @@ import (
 // How long to wait before sending telemetry to server (24 hours)
 const timer_hours_between_runs = 24
 
+// HookManagerCh - channel to add any new hooks
+var HookManagerCh = make(chan models.HookDetails, 2)
+
 // == Public ==
 
 // TimerCheckpoint - Checks if 24 hours has passed since telemetry was last sent. If so, sends telemetry data to posthog
@@ -43,8 +46,7 @@ func AddHook(ifaceToAdd interface{}) {
 	timeHooks = append(timeHooks, ifaceToAdd)
 }
 
-var HookManagerCh = make(chan models.HookDetails, 2)
-
+// StartHookManager - listens on `HookManagerCh` to run any hook
 func StartHookManager(ctx context.Context, wg *sync.WaitGroup) {
 	defer wg.Done()
 	for {

+ 15 - 10
servercfg/serverconf.go

@@ -693,16 +693,6 @@ func GetStunPort() int {
 	return port
 }
 
-func GetUserLimit() int {
-	var userslimit int
-	if os.Getenv("USERS_LIMIT") != "" {
-		userslimit, _ = strconv.Atoi(os.Getenv("USERS_LIMIT"))
-	} else {
-		userslimit = config.Config.Server.UsersLimit
-	}
-	return userslimit
-}
-
 // GetTurnPort - Get the port to run the turn server on
 func GetTurnPort() int {
 	port := 3479 //default
@@ -752,6 +742,18 @@ func IsProxyEnabled() bool {
 	return enabled
 }
 
+// GetNetworkLimit - fetches free tier limits on users
+func GetUserLimit() int {
+	var userslimit int
+	if os.Getenv("USERS_LIMIT") != "" {
+		userslimit, _ = strconv.Atoi(os.Getenv("USERS_LIMIT"))
+	} else {
+		userslimit = config.Config.Server.UsersLimit
+	}
+	return userslimit
+}
+
+// GetNetworkLimit - fetches free tier limits on networks
 func GetNetworkLimit() int {
 	var networkslimit int
 	if os.Getenv("NETWORKS_LIMIT") != "" {
@@ -762,6 +764,7 @@ func GetNetworkLimit() int {
 	return networkslimit
 }
 
+// GetClientLimit - fetches free tier limits on ext. clients
 func GetClientLimit() int {
 	var clientsLimit int
 	if os.Getenv("CLIENTS_LIMIT") != "" {
@@ -772,6 +775,7 @@ func GetClientLimit() int {
 	return clientsLimit
 }
 
+// GetHostLimit - fetches free tier limits on hosts
 func GetHostLimit() int {
 	var hostsLimit int
 	if os.Getenv("HOSTS_LIMIT") != "" {
@@ -782,6 +786,7 @@ func GetHostLimit() int {
 	return hostsLimit
 }
 
+// DeployedByOperator - returns true if the instance is deployed by netmaker operator
 func DeployedByOperator() bool {
 	if os.Getenv("DEPLOYED_BY_OPERATOR") != "" {
 		return os.Getenv("DEPLOYED_BY_OPERATOR") == "true"