3 Commits
Author SHA1 Message Date
paul addc90d856 Bump version
Build image / build-image (push) Successful in 2m58s
2025-04-25 13:39:17 +02:00
paul d23be3062a Merge pull request 'Send EFA requests to multiple servers' (#2) from feature/multiple-servers into main
Reviewed-on: #2
2025-04-25 13:38:30 +02:00
paul 740b654be6 Add bwegt efa client 2025-04-25 13:37:01 +02:00
2 changed files with 34 additions and 1 deletions
+1 -1
View File
@@ -16,7 +16,7 @@
vrnp-static = pkgs.buildGoModule { vrnp-static = pkgs.buildGoModule {
pname = "vrnp"; pname = "vrnp";
version = "0.0.5"; version = "0.0.6";
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.
+33
View File
@@ -111,6 +111,38 @@ func (c KVVEFAClient) BuildRequest(stopId string) (*http.Request, error) {
return req, nil return req, nil
} }
type BwegtEFAClient struct {
}
func (c BwegtEFAClient) GetName() string {
return "bwegt"
}
func (c BwegtEFAClient) BuildRequest(stopId string) (*http.Request, error) {
// Create request object
req, err := http.NewRequest("GET", "https://www.bwegt.de/bwegt-efa/XML_DM_REQUEST", nil)
if err != nil {
return nil, err
}
// Configure our request
query := url.Values{}
query.Set("coordOutputFormat", "EPSG:4326")
query.Set("depType", "stopEvents")
query.Set("includeCompleteStopSeq", "0")
query.Set("limit", "10")
query.Set("locationServerActive", "0")
query.Set("mode", "direct")
query.Set("name_dm", stopId)
query.Set("outputFormat", "json")
query.Set("type_dm", "stop")
query.Set("useOnlyStops", "1")
query.Set("useRealtime", "1")
req.URL.RawQuery = query.Encode()
return req, nil
}
func FetchDepartures(c EFAClient, stopId string) (DMResponse, error) { func FetchDepartures(c EFAClient, stopId string) (DMResponse, error) {
req, err := c.BuildRequest(stopId) req, err := c.BuildRequest(stopId)
if err != nil { if err != nil {
@@ -206,6 +238,7 @@ func main() {
// 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
efaClients := []EFAClient{ efaClients := []EFAClient{
BwegtEFAClient{},
VRNEFAClient{}, VRNEFAClient{},
KVVEFAClient{}, KVVEFAClient{},
} }