[RFC] @graphile/lds2
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, postgresql, typescript
- Ambito
- backend-api-design, databases
Direzione di ricerca
Inizia esaminando l’implementazione corrente di @graphile/lds e il suo utilizzo da parte di @graphile/subscriptions-lds, quindi confronta le definizioni di wal2json version-format 1 e 2 descritte qui. Il lavoro sarà considerato completato quando sarà disponibile un pacchetto @graphile/lds2 utile, che supporti il comportamento wal2json richiesto e la funzionalità di watch, e quando sarà stata affrontata la relativa integrazione con subscriptions.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Feature description
The new package @graphile/lds2 is in essence a copy of the current implementation with two changes (1 & 2) and one addition (3):
-
Minimal required version of wal2json is at this time of writing 2.3, due to requiring the
include-pkparameter to be available. This is required for@graphile/subscriptions-ldsto properly work in cases whereREPLICA IDENTITY FULLis enabled on a table. -
Dropping support for
version-format 1, and moving toversion-format 2which no longer reports changes on a transaction level, but on a tuple level. Additional bonus is that in my opinion the json object is structured more like what the industry standard is today. -
Adding watch capability much to what I believe
graphile-buildhas for building it schema. Currently@graphile/ldsis not able to actively listen to schema changes, adding this would allow us to circumvent the need for theinclude-pkparameter and as such also keep supportingversion-format 1and wal2json <= 2.3, yet this is not the main goal of this addition.I believe the most useful purpose of adding a watch capability is to be able to support subscriptions on native pg >=11 partitioned tables and timescale hypertables. These table structures are providing a
virtualtable that one can doinsert,update,delete,selectupon, but in actuality these operations are redirected to one or more sub tables (partitions). wal2json does NOT report changes on this (virtual) parent table level, but on the actual subtable that the change occurred. This makes it impossible to subscribe to these type of tables with the current implementation of@graphile/lds. I am aware of the fact that native pg >= 11 partitioned tables are NOT very well supported inpostgraphileatm (Only the partitions are showing up in the schema, not the virtual table), but due to the different technical implementation of timescale hypertables these are actually coming out in the generated schema just fine (No partitions are shown, just the parent table).Having this watch capability allows us to figure out that when a change occurs in one of these sub tables, we also need to fabricate a same change for the (
virtual) parent table.
Motivating example
Motivation for this alternative version is twofold, being that the the current implementation of @graphile/lds:
-
Assumes that the primary key information of a change is always included in the property
oldkeysif the propertyoldkeysis included. This is NOT always the case due to the possibilty of enablingREPLICA IDENTITY FULLon a table which changes the contents ofoldkeysfrom not only containing the primary key(s), but to containing the entire record as it was before said change (much like theOLDvalue in update/delete triggers). As such, enabling this feature on a table breaks the current implementation of@graphile/lds.Fixing the above issue requires the use of a parameter
include-pkwhich is only available in version >=2.3 of wal2json, and as of right now we haven't been able to find a method to detect which version of wal2json is installed. The only way seems to be that oftry {} catch {}the code with the parameter and falling back on one without if it fails with a parameter unknown error. Problem I have with this approach is that we'd have to resort to string matching to determine the cause, which feels a bit too iffy to me. -
Is built on
version-format 1of wal2json which produces a JSON object per transaction. All of the new/old tuples are available in the JSON object. Whereas the newerversion-format 2produces a JSON object per tuple, supports thetruncateoperation and provides in my opinion a more logical constructed object.Below are both formats as defined in
typescriptdefinitions, these are both the default format which can be augmented with additional metadata based on parameters. One of which is the much neededinclude-pkwhich is only available in wal2json >= 2.3format-version 1:export interface Change { kind: Kind; schema: string; table: string; columnnames?: string[]; columntypes?: string[]; columnvalues?: Columnvalue[]; oldkeys?: Oldkeys; } enum Kind { Insert = 'insert', Update = 'update', Delete = 'delete' } export type Columnvalue = any; export interface Oldkeys { keynames: string[]; keytypes: string[]; keyvalues: Keyvalue[]; } export type Keyvalue = string;format-version 2:export interface Change { action: Action; schema: string; table: string; columns?: Column[]; identity?: Column[]; } enum Action { Insert = 'I', Update = 'U', Delete = 'D', Truncate = 'T' } export interface Column { name: string; type: string; value: Value; } export type Value = any;
As we discussed in Discord fixing/adding the above 2 points would result in such breaking changes that are whole new package is warranted. This new package @graphile/lds2 would have more strict requirements on which version of wal2json is used.
Breaking changes
None, because it is a new package. Yet, in order to make this package useful an update to @graphile/subscription-lds or alternative package that does the same but using @graphile/lds2 is required.
Supporting development
I [tick all that apply]:
- am interested in building this feature myself
- am interested in collaborating on building this feature
- am willing to help testing this feature before it's released
- am willing to write a test-driven test suite for this feature (before it exists)
- am a Graphile sponsor ❤️
- have an active support or consultancy contract with Graphile
- Lingua principale
- JavaScript
- Stelle
- 764
- Fork
- 128
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di graphile/graphile-engine
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
graphile/graphile-engine#869 · 1 commento · 1 reazione ·
-
Provide a type guard to distinguish between ResolveTree and FieldsByTypeNameForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
graphile/graphile-engine#849 · 2 commenti · 1 reazione ·
-
🐛 bug help wanted
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
graphile/graphile-engine#818 ·
-
Race condition when closing LDSForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 32/100
graphile/graphile-engine#755 · 2 commenti ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
graphile/graphile-engine#725 · 17 commenti · 5 reazioni ·
Tutte le issue di graphile/graphile-engine
Issue simili
-
FEATURE REQUEST
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
linuxmint/cinnamon-spices-applets#9356 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
needs-triage Platform(Default)
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
I maintainer di solito rispondono entro 1 giorno