@golemio/pid 4.1.1 → 4.1.2-dev.2016480560
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/integration-engine/ropid-gtfs/helpers/DataCacheManager.d.ts +0 -1
- package/dist/integration-engine/ropid-gtfs/helpers/DataCacheManager.js +0 -1
- package/dist/integration-engine/ropid-gtfs/helpers/DataCacheManager.js.map +1 -1
- package/docs/cache/types/redis.md +145 -11
- package/package.json +2 -2
|
@@ -4,7 +4,6 @@ export declare class DataCacheManager implements IDataCacheManager {
|
|
|
4
4
|
private readonly staticFileRepository;
|
|
5
5
|
private readonly runTripsRepository;
|
|
6
6
|
private readonly blockStopsRepository;
|
|
7
|
-
private readonly delayComputationRepository;
|
|
8
7
|
private readonly regionalBusGtfsLookupCacheRepository;
|
|
9
8
|
static getInstance(): DataCacheManager;
|
|
10
9
|
private constructor();
|
|
@@ -17,7 +17,6 @@ class DataCacheManager {
|
|
|
17
17
|
this.staticFileRepository = new cache_1.StaticFileRedisRepository();
|
|
18
18
|
this.runTripsRepository = new cache_1.RunTripsRedisRepository();
|
|
19
19
|
this.blockStopsRepository = Di_1.RopidGtfsContainer.resolve(RopidGtfsContainerToken_1.RopidGtfsContainerToken.BlockStopsRedisRepository);
|
|
20
|
-
this.delayComputationRepository = new cache_1.DelayComputationRedisRepository();
|
|
21
20
|
this.regionalBusGtfsLookupCacheRepository = new RegionalBusGtfsCacheRepository_1.RegionalBusGtfsCacheRepository();
|
|
22
21
|
}
|
|
23
22
|
async cleanCache() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataCacheManager.js","sourceRoot":"","sources":["../../../../src/integration-engine/ropid-gtfs/helpers/DataCacheManager.ts"],"names":[],"mappings":";;;AAAA,0IAAqI;AACrI,6EAAwE;AACxE,gDAK8B;AAC9B,kCAA+C;AAC/C,4EAAyE;AAGzE,MAAa,gBAAgB;
|
|
1
|
+
{"version":3,"file":"DataCacheManager.js","sourceRoot":"","sources":["../../../../src/integration-engine/ropid-gtfs/helpers/DataCacheManager.ts"],"names":[],"mappings":";;;AAAA,0IAAqI;AACrI,6EAAwE;AACxE,gDAK8B;AAC9B,kCAA+C;AAC/C,4EAAyE;AAGzE,MAAa,gBAAgB;IAOlB,MAAM,CAAC,WAAW;QACrB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACjB,IAAI,CAAC,SAAS,GAAG,IAAI,gBAAgB,EAAE,CAAC;SAC3C;QAED,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED;QACI,IAAI,CAAC,oBAAoB,GAAG,IAAI,iCAAyB,EAAE,CAAC;QAC5D,IAAI,CAAC,kBAAkB,GAAG,IAAI,+BAAuB,EAAE,CAAC;QACxD,IAAI,CAAC,oBAAoB,GAAG,uBAAkB,CAAC,OAAO,CAClD,iDAAuB,CAAC,yBAAyB,CACpD,CAAC;QACF,IAAI,CAAC,oCAAoC,GAAG,IAAI,+DAA8B,EAAE,CAAC;IACrF,CAAC;IAEM,KAAK,CAAC,UAAU;QACnB,IAAI;YACA,MAAM,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC/C,MAAM,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC7C,MAAM,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC/C,MAAM,IAAI,CAAC,oCAAoC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SAClE;QAAC,OAAO,GAAG,EAAE;YACV,MAAM,IAAI,6BAAY,CAAC,yCAAyC,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;SACjG;IACL,CAAC;CACJ;AAlCD,4CAkCC"}
|
|
@@ -92,38 +92,172 @@ flowchart TD;
|
|
|
92
92
|
|
|
93
93
|
### gtfsRunSchedule:*
|
|
94
94
|
|
|
95
|
-
-
|
|
95
|
+
- key = `*${route_id}_${run_number}`
|
|
96
|
+
- retence dat aktivne v tride `DataCacheManager`
|
|
97
|
+
- TTL podle casu vygenerovane ho z methody `getNextExpireTimestamp`
|
|
98
|
+
- hodnota je `string`
|
|
99
|
+
- cache obsaguje data z tabulky ropidgtfs_precomputed_trip_schedule
|
|
100
|
+
|
|
101
|
+
```mermaid
|
|
102
|
+
flowchart TD;
|
|
103
|
+
psql[("PSQL ropidgtfs_precomputed_trip_schedule")];
|
|
104
|
+
redis_trip_schedule[("Redis gtfsRunSchedule:*")];
|
|
105
|
+
connector[("OG Redis connector")];
|
|
106
|
+
repository["IE RunTripsRedisRepository"];
|
|
107
|
+
|
|
108
|
+
propagateDelay["propagateDelay"];
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
repository<--GET*.runTuple--->propagateDelay;
|
|
112
|
+
runManager["AbstractGTFSTripRunManager"]
|
|
113
|
+
get_gtfsrt["GET /v2/departureboards"];
|
|
114
|
+
|
|
115
|
+
initial["Zpráva z vozidla"];
|
|
116
|
+
initial--process-->runManager;
|
|
117
|
+
repository--GET*.runTuple<-->redis_trip_schedule;
|
|
118
|
+
runManager--GET*.runTuple<-->repository;
|
|
119
|
+
runManager--SET *.runTuple-->repository;
|
|
120
|
+
repository--SET *.runTuple-->redis_trip_schedule;
|
|
121
|
+
runManager--SELECT if not found in redis<-->psql;
|
|
122
|
+
|
|
123
|
+
get_gtfsrt-->connector;
|
|
124
|
+
connector--**MGET** *runTuple<-->redis_trip_schedule;
|
|
125
|
+
```
|
|
96
126
|
|
|
97
127
|
### gtfsBlockSchedule:*
|
|
98
128
|
|
|
99
|
-
-
|
|
129
|
+
- key = `*gtfs_block_id`
|
|
130
|
+
- retence dat aktivne v tride `DataCacheManager`
|
|
131
|
+
- TTL podle casu vygenerovane ho z methody `getNextExpireTimestamp`
|
|
132
|
+
- hodnota je `string`
|
|
133
|
+
- cache obsahuje data trip_stops podle gtfs block_id
|
|
100
134
|
|
|
101
|
-
|
|
135
|
+
```mermaid
|
|
136
|
+
flowchart TD;
|
|
137
|
+
psql[("PSQL ropidgtfs_stop_times")];
|
|
138
|
+
cache[("Redis gtfsBlockSchedule:*")];
|
|
139
|
+
repository["IE BlockStopsRedisRepository"];
|
|
140
|
+
updateDelay["updateDelay"];
|
|
141
|
+
updateGTFSTripId["updateGTFSTripId"];
|
|
142
|
+
tripStopsManager["tripStopsManager"];
|
|
143
|
+
initial["Zpráva z vozidla"];
|
|
144
|
+
|
|
145
|
+
initial--process-->updateGTFSTripId;
|
|
146
|
+
updateGTFSTripId<--create cache for trip stops-->tripStopsManager;
|
|
147
|
+
updateGTFSTripId-->updateDelay;
|
|
148
|
+
updateDelay<--get/update cache for trip stops-->tripStopsManager;
|
|
149
|
+
updateDelay-->propagateDelay;
|
|
150
|
+
propagateDelay-->propagateTrainDelay;
|
|
151
|
+
propagateTrainDelay<--get/update cache for trip stops-->tripStopsManager;
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
repository--GET*.blockId<-->redis_trip_schedule;
|
|
156
|
+
tripStopsManager--GET*.blockId<-->repository;
|
|
157
|
+
tripStopsManager--SET *.blockId-->repository;
|
|
158
|
+
repository--SET *.blockId-->cache;
|
|
159
|
+
tripStopsManager--SELECT if not found in redis<-->psql;
|
|
102
160
|
|
|
103
|
-
|
|
161
|
+
```
|
|
162
|
+
### gtfsDelayComputation:*
|
|
104
163
|
|
|
164
|
+
- key = `*${gtfs_trip_id}`
|
|
165
|
+
- TTL nastavovano na valid_to posledni pozice kdyz je znama kdyz ne tak na 30 min
|
|
166
|
+
- hodnota je `json`
|
|
167
|
+
- cache obsahuje informace o tripu
|
|
168
|
+
- stop_times
|
|
169
|
+
- shapes_anchor_points
|
|
170
|
+
- shapes
|
|
171
|
+
|
|
105
172
|
### Flowchart
|
|
106
173
|
|
|
107
174
|
```mermaid
|
|
108
175
|
flowchart TD;
|
|
109
|
-
|
|
176
|
+
|
|
177
|
+
updateDelay["UpdateDelay Task"];
|
|
178
|
+
|
|
179
|
+
saveRunToDb["save*RunToDb Task"];
|
|
180
|
+
updateRunsGTFSTripId["updateRunsGTFSTripId Task"]
|
|
181
|
+
processRegionalBusPositions["processRegionalBusPositions Task"]
|
|
182
|
+
processRegionalBusRunMessages["processRegionalBusRunMessages Task"]
|
|
183
|
+
repository["DelayComputationRedisRepository"];
|
|
184
|
+
cache["Redis gtfsDelayComputation:*"];
|
|
185
|
+
initial["Zprava z vozidla"]
|
|
186
|
+
|
|
187
|
+
initial-->saveRunToDb
|
|
188
|
+
saveRunToDb--common message-->updateRunsGTFSTripId
|
|
189
|
+
updateRunsGTFSTripId-->updateDelay;
|
|
190
|
+
updateDelay<--getTripPropertiesBatch-->repository;
|
|
191
|
+
updateDelay<--cacheTripDataBatch-->repository;
|
|
192
|
+
|
|
193
|
+
saveRunToDb--ArrivaCity run message-->processRegionalBusRunMessages
|
|
194
|
+
processRegionalBusRunMessages-->processRegionalBusPositions
|
|
195
|
+
processRegionalBusPositions<--getTripPropertiesBatch-->repository;
|
|
196
|
+
processRegionalBusPositions<--cacheTripDataBatch-->repository;
|
|
197
|
+
|
|
198
|
+
repository--JSON.GET-->cache
|
|
199
|
+
repository--JSON.SET-->cache
|
|
200
|
+
|
|
110
201
|
```
|
|
111
202
|
|
|
112
203
|
## Cache pro předzpracování a párování dat z Telmaxu (Arriva City)
|
|
113
204
|
|
|
114
205
|
### vpRegionalBusCisLookup:*
|
|
115
206
|
|
|
116
|
-
-
|
|
207
|
+
- key = `*${external_trip_id}`
|
|
208
|
+
- TTL podle casu vygenerovane ho z methody `getNextExpireTimestamp`
|
|
209
|
+
- hodnota je string (JSON.stringify())
|
|
210
|
+
- cache obsahuje cis informace o tripu
|
|
211
|
+
- cis_line_id
|
|
212
|
+
- cis_trip_number
|
|
213
|
+
- registration_number
|
|
214
|
+
|
|
215
|
+
```mermaid
|
|
216
|
+
flowchart TD
|
|
217
|
+
cache["vpRegionalBusCisLookup:*"]
|
|
218
|
+
|
|
219
|
+
repo["RegionalBusCisCacheRepository"]
|
|
220
|
+
telmax["Telmax (Arriva City)"]
|
|
221
|
+
task["saveArrivaCityRunsToDB task"]
|
|
222
|
+
|
|
223
|
+
telmax-->|bus position message|task
|
|
224
|
+
task-->|lookup CIS ID|repo
|
|
225
|
+
repo-->|get/set|cache
|
|
226
|
+
task-->|update cache|repo
|
|
227
|
+
cache-->|return data|repo
|
|
228
|
+
```
|
|
117
229
|
|
|
118
230
|
### vpRegionalBusGtfsLookup:*
|
|
119
231
|
|
|
120
|
-
-
|
|
232
|
+
- key = `*${cis_line_id}_${cis_trip_number}`
|
|
233
|
+
- TTL zadne nema
|
|
234
|
+
- retence dat aktivne v tride `DataCacheManager`
|
|
235
|
+
- hodnota je string (JSON.stringify())
|
|
236
|
+
- cache obsahuje gtfs informace o tripu
|
|
237
|
+
- gtfs_trip_id
|
|
238
|
+
- route_name
|
|
239
|
+
- run_number
|
|
240
|
+
- agency_name
|
|
241
|
+
- is_wheelchair_accessible
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
```mermaid
|
|
245
|
+
flowchart TD
|
|
246
|
+
cache["vpRegionalBusGtfsLookup:*"]
|
|
121
247
|
|
|
122
|
-
|
|
248
|
+
repo["RegionalBusGtfsCacheRepository"]
|
|
249
|
+
telmax["Telmax (Arriva City)"]
|
|
250
|
+
task["processRegionalBusRunMessages Task"]
|
|
251
|
+
psql["gtfs data in DB"]
|
|
123
252
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
telmax-->|bus position message|task
|
|
256
|
+
task<--No gtfs data for trip in cache-->psql
|
|
257
|
+
task-->|lookup GTFS trip|repo
|
|
258
|
+
repo-->|get/set|cache
|
|
259
|
+
task-->|update cache|repo
|
|
260
|
+
cache-->|return data|repo
|
|
127
261
|
```
|
|
128
262
|
|
|
129
263
|
## Cache pro public API
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@golemio/pid",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.2-dev.2016480560",
|
|
4
4
|
"description": "Golemio PID Module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@golemio/core": ">=1.16.0-rc.1551191551"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@golemio/ovapi-gtfs-realtime-bindings": "1.2.
|
|
78
|
+
"@golemio/ovapi-gtfs-realtime-bindings": "1.2.4-dev.1288219308",
|
|
79
79
|
"@turf/turf": "^6.5.0",
|
|
80
80
|
"cheap-ruler": "^3.0.2",
|
|
81
81
|
"csv-parser": "^3.0.0",
|