Skip to content

Commit 3100318

Browse files
author
Alan Christie
committed
fix: Consistent use of the term 'ordinal'
1 parent f11ad7f commit 3100318

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -181,26 +181,26 @@ RabbitMQ Topic Queue.
181181
Version 2 uses the `rstream` package and relies on a RabbitMQ stream.
182182

183183
Version 2 also extends messages prior to forwarding them to their socket clients.
184-
It does this by appending the messages's **offset** in the stream (an `integer`,
185-
which we refer to as an **ordinal**)), and the message's **timestamp** (also an `integer`),
186-
both of which are provided by the backing RabbitMQ stream as the messages are received
187-
by the Event Stream's consumer. The **offset** can be used as a unique message identifier.
184+
It does this by appending the messages's **ordinal** (an `integer`, its _offset_ in the
185+
stream), and **timestamp** (also an `integer`), both of which are provided by the
186+
backing RabbitMQ stream as the messages are received.
187+
The **ordinal** can be used as a unique message identifier.
188188

189189
When received as a protobuf string the values are appended to the end of the original
190190
message using `|` as a delimiter. Here is an example, with the message split at the
191191
delimiter for clarity: -
192192

193193
accountserver.MerchantProcessingCharge
194194
|timestamp: "2025-04-30T19:20:37.926+00:00" merchant_kind: "DATA_MANAGER" [...]
195-
|offset: 2
195+
|ordinal: 2
196196
|timestamp: 1746042171620
197197

198198
JSON strings will have these values added to the received dictionary using the
199-
keys `ess_offset` and `ess_timestamp`, again, displayed here over several lines
199+
keys `ess_ordinal` and `ess_timestamp`, again, displayed here over several lines
200200
for clarity: -
201201

202202
{
203-
"ess_offset": 2,
203+
"ess_ordinal": 2,
204204
"ess_timestamp": 1746042171620,
205205
"message_type": "accountserver.MerchantProcessingCharge",
206206
"message_body": {
@@ -223,20 +223,20 @@ You can select the start of your events buy providing either an **ordinal**,
223223
event after the given reference. For example, if you provide **ordinal** `100`
224224
the next event you can expect to receive is an event with **ordinal** `101`.
225225

226-
- To stream from a specific **ordinal** (**offset**), provide it as the numerical value
226+
- To stream from a specific **ordinal**, provide it as the numerical value
227227
of the header property `X-StreamOffsetFromOrdinal`.
228228

229229
- To stream from a specific **timestamp**, provide it as the numerical value
230230
of the header property `X-StreamOffsetFromTimestamp`.
231231

232232
- To stream from a specific **datetime**, provide the date/time string as the value
233233
of the header property `X-StreamOffsetFromDatetime`. The datetime string is extremely
234-
flexible and is interpreted by the **python-dateutil** package's `parse` function.
235-
UTC is used as the reference for messages and the string will be interpreted as a
236-
UTC value if it has no timezone specification. For example, if you are in CEST and
237-
it is `13:33` and you want to retrieve times from 13:33 (local time) then you will need
238-
to provide a **datetime** string value that has the time set to
239-
`11:33` (the UTC time for 13:33 CEST) or specify `13:33+02:00`
234+
flexible and is interpreted by the [python-dateutil] package's `parse` function.
235+
UTC is used as the reference for messages, and the string will be interpreted as a
236+
UTC value if it has no timezone specification. If you are in CEST for example, and
237+
it is `13:33`, and you want to retrieve times from 13:33 (local time), then you
238+
will need to provide a string value that has the date you are interested in,
239+
ans the time set to `11:33` (the UTC time for 13:33 CEST) or specify `13:33+02:00`.
240240

241241
You can only provide one type of historical reference. If you provide a header
242242
value for `X-StreamOffsetFromOrdinal` for example, you cannot also provide
@@ -271,4 +271,5 @@ on event message size, should be able to retain events for several days.
271271
[fastapi]: https://fastapi.tiangolo.com
272272
[pre-commit]: https://pre-commit.com
273273
[poetry]: https://python-poetry.org
274+
[python-dateutil]: https://github.com/dateutil/dateutil
274275
[rabbitmq]: https://www.rabbitmq.com

app/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,13 +424,13 @@ async def on_message_for_websocket(
424424
if message_string[0] != "{":
425425
# The EventStream Service is permitted to append to the protobuf string
426426
# as long as it uses the '|' delimiter. Here qwe add offset and timestamp.
427-
message_string += f"|offset: {message_context.offset}"
427+
message_string += f"|ordinal: {message_context.offset}"
428428
message_string += f"|timestamp: {message_context.timestamp}"
429429
else:
430430
# The EventStream Service is permitted to append to the JSON string
431431
# as long as it uses keys with the prefix "ess_"
432432
msg_dict: dict[str, Any] = json.loads(message_string)
433-
msg_dict["ess_offset"] = message_context.offset
433+
msg_dict["ess_ordinal"] = message_context.offset
434434
msg_dict["ess_timestamp"] = message_context.timestamp
435435
message_string = json.dumps(msg_dict)
436436
try:

0 commit comments

Comments
 (0)