Skip to content

Commit

Permalink
matching: expect GTFS_RT_2 stream & consumer to be created by the use…
Browse files Browse the repository at this point in the history
…r 💥📝
  • Loading branch information
derhuerst committed Jan 13, 2025
1 parent b6400fd commit 12fc305
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
13 changes: 0 additions & 13 deletions lib/match.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,19 +339,6 @@ const runGtfsMatching = async (cfg, opt = {}) => {
streamInfo,
}, 'using NATS JetStream stream for AUS IstFahrts')
}
{
// create/update NATS JetStream stream for GTFS-RT data
const streamInfo = await natsJetstreamManager.streams.add({
name: NATS_JETSTREAM_GTFSRT_STREAM_NAME,
subjects: [
GTFS_RT_TOPIC_PREFIX + '>',
],
// todo: limits?
})
serviceLogger.debug({
streamInfo,
}, 'created/re-used NATS JetStream stream for GTFS-RT data')
}

const istFahrtsConsumer = await natsJetstreamClient.consumers.get(
NATS_JETSTREAM_AUS_ISTFAHRT_STREAM_NAME,
Expand Down
21 changes: 19 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ By default, `gtfs-rt-feed` will connect as `gtfs-rt-$MAJOR_VERSION` to `localhos

#### create NATS stream & consumer

We also need to create a [NATS JetStream](https://docs.nats.io/nats-concepts/jetstream) [stream](https://docs.nats.io/nats-concepts/jetstream/streams) called `AUS_ISTFAHRT_2` that `gtfs-rt-feed` will read (unmatched) GTFS-RT messages from. This can be done using the [NATS CLI](https://github.com/nats-io/natscli):
We also need to create a [NATS JetStream](https://docs.nats.io/nats-concepts/jetstream) [stream](https://docs.nats.io/nats-concepts/jetstream/streams) called `AUS_ISTFAHRT_2` that `gtfs-rt-feed` will read (unmatched) VDV-454 `AUS` `IstFahrt` messages from. This can be done using the [NATS CLI](https://github.com/nats-io/natscli):

```shell
nats stream add \
Expand All @@ -192,7 +192,7 @@ nats stream add \
AUS_ISTFAHRT_2
```

On the `AUS_ISTFAHRT_2` stream, we create a durable [consumer]():
On the `AUS_ISTFAHRT_2` stream, we create a durable [consumer](https://docs.nats.io/nats-concepts/jetstream/consumers) called `gtfs-rt-feed`:

```shell
nats consumer add \
Expand All @@ -219,6 +219,23 @@ nats consumer add \
gtfs-rt-feed
```

Next, again using the NATS CLI, we'll create a stream called `GTFS_RT_2` that the `gtfs-rt-feed` service will write (matched) GTFS-RT messages into:

```shell
nats stream add \
# omit this if you want to configure more details
--defaults \
# collect all messages published to these subjects
--subjects='gtfsrt.>' \
# acknowledge publishes
--ack \
# with limited storage, discard the oldest limits first
--retention=limits --discard=old \
--description='GTFS-RT messages' \
# name of the stream
GTFS_RT_2
```

#### configure access to Redis

`gtfs-rt-feed` uses [`ioredis`](https://npmjs.com/package/ioredis) to connect to PostgreSQL; For details about supported environment variables and their defaults, refer to [its docs](https://github.com/redis/ioredis#readme).
Expand Down

0 comments on commit 12fc305

Please sign in to comment.