Compare commits
	
		
			No commits in common. "72734c7faa5cb6e704f4a469f95ff7980ce27d3e" and "5d5b893948493044a83d1218b8cebe512cded59a" have entirely different histories.
		
	
	
		
			72734c7faa
			...
			5d5b893948
		
	
		
| @ -16,7 +16,7 @@ | |||||||
| 
 | 
 | ||||||
|       vrnp-static = pkgs.buildGoModule { |       vrnp-static = pkgs.buildGoModule { | ||||||
|         pname = "vrnp"; |         pname = "vrnp"; | ||||||
|         version = "0.0.8"; |         version = "0.0.7"; | ||||||
|         vendorHash = null; |         vendorHash = null; | ||||||
| 
 | 
 | ||||||
|         # For building the package, we use only the files not ignored by Git as inputs. |         # For building the package, we use only the files not ignored by Git as inputs. | ||||||
|  | |||||||
							
								
								
									
										22
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								main.go
									
									
									
									
									
								
							| @ -51,12 +51,6 @@ type EFAClient interface { | |||||||
| 	BuildRequest(string) (*http.Request, error) | 	BuildRequest(string) (*http.Request, error) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| var allEfaClients []EFAClient = []EFAClient{ |  | ||||||
| 	BwegtEFAClient{}, |  | ||||||
| 	VRNEFAClient{}, |  | ||||||
| 	KVVEFAClient{}, |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| type VRNEFAClient struct { | type VRNEFAClient struct { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -187,7 +181,7 @@ type Departure struct { | |||||||
| 	Symbol    string `json:"symbol"` | 	Symbol    string `json:"symbol"` | ||||||
| 	Direction string `json:"direction"` | 	Direction string `json:"direction"` | ||||||
| 	Leaving   string `json:"leaving"` | 	Leaving   string `json:"leaving"` | ||||||
| 	Countdown int    `json:"-"` | 	Countdown int | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func ParseDepartures(response DMResponse, allowedPlatform *string) (Departures, error) { | func ParseDepartures(response DMResponse, allowedPlatform *string) (Departures, error) { | ||||||
| @ -246,18 +240,15 @@ func ParseDepartures(response DMResponse, allowedPlatform *string) (Departures, | |||||||
| func main() { | func main() { | ||||||
| 	password := os.Getenv("VRNP_PASSWORD") | 	password := os.Getenv("VRNP_PASSWORD") | ||||||
| 	if len(password) == 0 { | 	if len(password) == 0 { | ||||||
| 		log.Fatal("Required environment variable VRNP_PASSWORD is not set") | 		panic("Required environment variable VRNP_PASSWORD is not set") | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	clientAllowlist := strings.Split(os.Getenv("VRNP_CLIENT_ALLOWLIST"), ",") |  | ||||||
| 
 |  | ||||||
| 	// Use round-robin to send incoming requests to different servers | 	// Use round-robin to send incoming requests to different servers | ||||||
| 	var efaClient atomic.Uint64 | 	var efaClient atomic.Uint64 | ||||||
| 	var efaClients []EFAClient | 	efaClients := []EFAClient{ | ||||||
| 	for _, efaClient := range allEfaClients { | 		BwegtEFAClient{}, | ||||||
| 		if len(clientAllowlist) != 0 && slices.Contains(clientAllowlist, efaClient.GetName()) { | 		VRNEFAClient{}, | ||||||
| 			efaClients = append(efaClients, efaClient) | 		KVVEFAClient{}, | ||||||
| 		} |  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	http.HandleFunc("/departures", func(w http.ResponseWriter, r *http.Request) { | 	http.HandleFunc("/departures", func(w http.ResponseWriter, r *http.Request) { | ||||||
| @ -282,6 +273,7 @@ func main() { | |||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		c := efaClients[(efaClient.Add(1) - 1) % uint64(len(efaClients))] | 		c := efaClients[(efaClient.Add(1) - 1) % uint64(len(efaClients))] | ||||||
|  | 		log.Print(c.GetName()) | ||||||
| 		ds, err := FetchDepartures(c, stopId) | 		ds, err := FetchDepartures(c, stopId) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			http.Error(w, err.Error(), http.StatusInternalServerError) | 			http.Error(w, err.Error(), http.StatusInternalServerError) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user