Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement SIRI Lite #6284

Merged

Conversation

leonardehrenfried
Copy link
Member

@leonardehrenfried leonardehrenfried commented Nov 27, 2024

Summary

Implements the SIRI Light flavour (as opposed to the request/response one that Entur and Skanetrafiken uses). This means that the entire SIRI feed is downloaded in a single GET request.

Issue

Closes #6263

Documentation

The new updater is fully documented and I took the liberty to make all references to SIRI consistent in the docs.

Unit tests

Some added, but it's mostly wiring. I'm happy to add more if requested but generally we don't test the HTTP layer a lot.

cc @rcavaliere @Jouca

@leonardehrenfried leonardehrenfried added New Feature Real-Time Update The issue/PR is related to RealTime updates labels Nov 27, 2024
@leonardehrenfried leonardehrenfried requested a review from a team as a code owner November 27, 2024 12:51
@leonardehrenfried leonardehrenfried force-pushed the siri-light branch 2 times, most recently from 6afe592 to bf2fcf2 Compare November 27, 2024 12:56
Copy link

codecov bot commented Nov 27, 2024

Codecov Report

Attention: Patch coverage is 36.87500% with 101 lines in your changes missing coverage. Please review.

Project coverage is 69.80%. Comparing base (cd254bf) to head (de1e23d).
Report is 184 commits behind head on dev-2.x.

Files with missing lines Patch % Lines
...ater/siri/updater/configure/SiriUpdaterModule.java 0.00% 42 Missing ⚠️
...i/updater/lite/SiriETLiteHttpTripUpdateSource.java 0.00% 21 Missing ⚠️
...planner/updater/configure/UpdaterConfigurator.java 0.00% 8 Missing and 2 partials ⚠️
...ripplanner/updater/siri/updater/SiriETUpdater.java 0.00% 9 Missing ⚠️
...ripplanner/updater/siri/updater/SiriSXUpdater.java 0.00% 7 Missing ⚠️
...dater/siri/updater/SiriETHttpTripUpdateSource.java 0.00% 3 Missing ⚠️
...siri/updater/lite/SiriETLiteUpdaterParameters.java 25.00% 3 Missing ⚠️
...siri/updater/lite/SiriSXLiteUpdaterParameters.java 25.00% 3 Missing ⚠️
...routerconfig/updaters/SiriETLiteUpdaterConfig.java 95.45% 1 Missing ⚠️
...routerconfig/updaters/SiriSXLiteUpdaterConfig.java 95.45% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #6284      +/-   ##
=============================================
- Coverage      69.81%   69.80%   -0.01%     
- Complexity     17825    17933     +108     
=============================================
  Files           2020     2042      +22     
  Lines          76271    76631     +360     
  Branches        7806     7829      +23     
=============================================
+ Hits           53250    53494     +244     
- Misses         20304    20399      +95     
- Partials        2717     2738      +21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@leonardehrenfried leonardehrenfried changed the title Implement SIRI light Implement SIRI Light Nov 28, 2024
@leonardehrenfried
Copy link
Member Author

@habrahamsson-skanetrafiken Can I ask you to review this one? If not let me know and I will reassign.

@leonardehrenfried
Copy link
Member Author

It never occurred to me until yesterday's meeting that I also could have made the current updater/loader configurable. Let me know if you feel that's the better option, @t2gran.

@leonardehrenfried leonardehrenfried changed the title Implement SIRI Light Implement SIRI Lite Dec 3, 2024
Copy link
Member

@t2gran t2gran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read through most of the main code - not all. The wiring can be improved, so I will wait with the rest of the review to that is done.

/**
* Feed id that is used to match trip ids in the TripUpdates
*/
private final String feedId;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this unused, or is it the SIRI namespace?

Copy link
Member Author

@leonardehrenfried leonardehrenfried Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a reference to the actual id of the feed and unused.

.toString();
}

private static SiriLoader createLoader(Parameters parameters) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DRY - This can be refactored out. Either create a SiriLoaderFactory or create it in the UpdatorConfigurator and pass it in.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done both in c7bf5ed

@leonardehrenfried leonardehrenfried force-pushed the siri-light branch 2 times, most recently from 1ab52da to c7bf5ed Compare December 11, 2024 20:42
@t2gran
Copy link
Member

t2gran commented Dec 12, 2024

Here is what I had in mind with respect to manual Dependency Injection:

package org.opentripplanner.updater.siri.configure;

/** This is doing manually dependency injection and work as a factory to create the updater components. */
class SiriUpdaterModule {

   public static SiriETUpdater createSiriETUpdater(...) {
     var loader = createLoader(...);    
     var source = createSource(loader, ...);
     return createETUpdater(source, ...);
   }

  private static createLoader(...);    
  private static createSource(...);
  private static createUpdater(...);
}

Each component define the parameters as an interface inside the class. The same parameters can be repeated, but not inherited. For example if URI uri() is used in Loader and Updater both interfaces have the same method. Then the implementation of these 3 interfaces can be passed to all 3, but each class only see the set of parameters they need. If the main class (Updator) inherit an other class and that has a Parameters inside, then the main parameter will inherit that. In other words, the Parameters classes follow the same inheritance structure as the outer main class.
A extends B ==> A.Parameters extends B.Parameters.

The factory for creating the Loader can be inlined here. The SiriUpdaterModule reduce the dependencies and remove DI code from the Updaters constructors.

@leonardehrenfried
Copy link
Member Author

@t2gran I have introduce the DI class that you requested in defdf5f

@Jouca
Copy link

Jouca commented Dec 13, 2024

Just a question,
Is Siri Lite basically working as like SIRI if you use it with GTFS-RT (resulting to an error) ?

@leonardehrenfried
Copy link
Member Author

Yes, you cannot use it at the same time as GTFS-RT. I cannot promise anything but it looks like this might change in 2025.

}

private static SiriLoader createLoader(SiriSXUpdater.Parameters params) {
return switch (params) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should have support for file loading like the ET case has?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Here it is: de1e23d

@leonardehrenfried leonardehrenfried merged commit df53a35 into opentripplanner:dev-2.x Jan 3, 2025
5 checks passed
t2gran pushed a commit that referenced this pull request Jan 3, 2025
@leonardehrenfried leonardehrenfried deleted the siri-light branch January 3, 2025 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Feature Real-Time Update The issue/PR is related to RealTime updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement SIRI Lite
4 participants