Naming
Every pubsub topic, state key and CloudEvent type, subject and source
in Virtufin is built by one library, Virtufin.Naming. The same library
exists in Python (virtufin-naming) and TypeScript (@virtufin/naming).
Code never writes a name by hand: it asks an entity for its topic or key.
The rules are normative in the pubsub-topics spec. The naming reference lists every family that every repo defines, generated from the published fragments. This page explains the model.
The model in one picture
An entity is a stem (scope + path), an identity, an entity type and a set of events. Every name is derived from those parts, so the topic, the key and the subject of one entity can never disagree:
flowchart LR
subgraph Entity["Entity: Binance order book"]
S["scope<br/><code>act</code> or <code>hyp.<WORLD></code>"]
P["path<br/><code>exchange.binance.orderbook</code>"]
I["identity<br/><code>BTC_USDT</code>"]
E["events<br/><code>changed</code>, <code>gap</code>, …"]
end
S --> T["topic<br/><code>act.exchange.binance.orderbook.changed.BTC_USDT</code>"]
P --> T
E --> T
I --> T
S --> K["state key<br/><code>act.exchange.binance.orderbook.BTC_USDT</code>"]
P --> K
I --> K
I --> SU["ce-subject<br/><code>currency_pair/BTC_USDT</code>"]
P --> CT["ce-type<br/><code>com.virtufin.exchange.binance.orderbook.changed</code>"]
E --> CT
The derivation rules, scopes, segment classes and owners: Naming rules. Building names in C#, Python and TypeScript: Build names with the naming library.
What protects everyone else
- The fragment cannot change existing names: composition adds families and never edits them. The conformance suite checks that every Binance name is unchanged after the Alpaca fragment is added.
- If another fragment also declared venue
alpaca, bound the order book toalpacaagain, or declared one of its worker types, composition would fail with a message naming both fragments, and so would the specs site build. - A fragment id composes only once, unless the copies are identical. Worker
builds from before the venue fragments moved to market-data-devkit embed an
older copy. Once the fragment changes, those builds no longer compose with
the current
Virtufin.MarketData.DevKit(AlpacaOrderBook ≤ 0.9.2, AlpacaTrades ≤ 0.5.4 since market-data-devkit 0.15.1).