[RFC] @graphile/lds2
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, postgresql, typescript
- Lĩnh vực
- backend-api-design, databases
Hướng nghiên cứu
Bắt đầu bằng việc xem xét triển khai hiện tại của @graphile/lds và cách @graphile/subscriptions-lds sử dụng nó, sau đó so sánh các định nghĩa wal2json version-format 1 và 2 được mô tả ở đây. Công việc được xem là hoàn tất khi có một package @graphile/lds2 hữu ích, hỗ trợ hành vi wal2json được yêu cầu và khả năng watch, đồng thời việc tích hợp subscription liên quan đã được xử lý.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- JavaScript
- Star
- 764
- Fork
- 128
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của graphile/graphile-engine
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
graphile/graphile-engine#869 · 1 bình luận · 1 reaction ·
-
Provide a type guard to distinguish between ResolveTree and FieldsByTypeNameCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
graphile/graphile-engine#849 · 2 bình luận · 1 reaction ·
-
🐛 bug help wanted
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
graphile/graphile-engine#818 ·
-
Race condition when closing LDSCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 32/100
graphile/graphile-engine#755 · 2 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
graphile/graphile-engine#725 · 17 bình luận · 5 reaction ·
Tất cả issue của graphile/graphile-engine
Issue tương tự
-
FEATURE REQUEST
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
linuxmint/cinnamon-spices-applets#9356 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage Platform(Default)
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
Maintainer thường phản hồi trong vòng 1 ngày