entur / lamassu

Mobility hub
European Union Public License 1.2
5 stars 7 forks source link

GBFS update delta service #415

Open testower opened 2 months ago

testower commented 2 months ago

Is your feature request related to a problem? Please describe.

The entity updaters are very complex and contain a lot of logic to figure out what has changed from one update to the next. The code is not easy to read and is not very well tested. In addition, we could foresee the need for a general solution to computing the delta of gbfs updates.

Goal / high level use-case

Create a new service within lamassu to compute the delta of gbfs updates. The delta can be used to create, update and delete entities from cache. This probably requires denormalize the entity cache, but makes updating more efficient. Cache lookup is very efficient, and GraphQL can resolve entities when needed.

The delta can also be used to create a proof-of-concept of a subscriptio-model for GBFS data.

Describe the solution you'd like

Perhaps by using a library for deep-comparison of objects: https://github.com/SQiShER/java-object-diff.

Describe alternatives you've considered

Additional context

testower commented 2 weeks ago

Design idea:

VehicleDelta {
  vehicleId: string
  type: [CREATE, UPDATE, DELETE]
  entity: {...}
}

VehicleStatusDelta {
  base: Timestamp
  compare: Timestamp
  vehicle: VehicleDelta
}