Skip to content

Conversation

@adamziel
Copy link
Contributor

@adamziel adamziel commented Oct 15, 2020

This PR updates the edit-widgets package so that it saves the entities using batch processing against the correct API endpoints.

Testing instructions TBD

@github-actions
Copy link

github-actions bot commented Oct 15, 2020

Size Change: +4.3 kB (0%)

Total Size: 1.2 MB

Filename Size Change
build/block-directory/index.js 8.6 kB -2 B (0%)
build/block-editor/index.js 130 kB -41 B (0%)
build/block-library/index.js 144 kB +1 B
build/blocks/index.js 47.6 kB +1 B
build/components/index.js 170 kB -8 B (0%)
build/core-data/index.js 12.1 kB +17 B (0%)
build/data-controls/index.js 684 B +1 B
build/edit-post/index.js 306 kB +10 B (0%)
build/edit-site/index.js 21.6 kB +1 B
build/edit-widgets/index.js 26.6 kB +4.27 kB (16%) ⚠️
build/editor/index.js 42.6 kB +2 B (0%)
build/format-library/index.js 7.49 kB -1 B
build/keyboard-shortcuts/index.js 2.39 kB +2 B (0%)
build/list-reusable-blocks/index.js 3.02 kB -2 B (0%)
build/media-utils/index.js 5.12 kB -1 B
build/reusable-blocks/index.js 3.06 kB -1 B
build/rich-text/index.js 13 kB +1 B
build/server-side-render/index.js 2.61 kB -1 B
build/token-list/index.js 1.24 kB -2 B (0%)
build/wordcount/index.js 1.23 kB +53 B (4%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/annotations/index.js 3.54 kB 0 B
build/api-fetch/index.js 3.35 kB 0 B
build/autop/index.js 2.72 kB 0 B
build/blob/index.js 668 B 0 B
build/block-directory/style-rtl.css 943 B 0 B
build/block-directory/style.css 942 B 0 B
build/block-editor/style-rtl.css 11 kB 0 B
build/block-editor/style.css 10.9 kB 0 B
build/block-library/editor-rtl.css 8.93 kB 0 B
build/block-library/editor.css 8.93 kB 0 B
build/block-library/style-rtl.css 7.71 kB 0 B
build/block-library/style.css 7.71 kB 0 B
build/block-library/theme-rtl.css 741 B 0 B
build/block-library/theme.css 741 B 0 B
build/block-serialization-default-parser/index.js 1.77 kB 0 B
build/block-serialization-spec-parser/index.js 3.1 kB 0 B
build/components/style-rtl.css 15.4 kB 0 B
build/components/style.css 15.4 kB 0 B
build/compose/index.js 9.63 kB 0 B
build/data/index.js 8.63 kB 0 B
build/date/index.js 31.9 kB 0 B
build/deprecated/index.js 772 B 0 B
build/dom-ready/index.js 569 B 0 B
build/dom/index.js 4.43 kB 0 B
build/edit-navigation/index.js 10.6 kB 0 B
build/edit-navigation/style-rtl.css 868 B 0 B
build/edit-navigation/style.css 871 B 0 B
build/edit-post/style-rtl.css 6.37 kB 0 B
build/edit-post/style.css 6.35 kB 0 B
build/edit-site/style-rtl.css 3.8 kB 0 B
build/edit-site/style.css 3.81 kB 0 B
build/edit-widgets/style-rtl.css 3.09 kB 0 B
build/edit-widgets/style.css 3.09 kB 0 B
build/editor/editor-styles-rtl.css 480 B 0 B
build/editor/editor-styles.css 482 B 0 B
build/editor/style-rtl.css 3.85 kB 0 B
build/editor/style.css 3.84 kB 0 B
build/element/index.js 4.45 kB 0 B
build/escape-html/index.js 733 B 0 B
build/format-library/style-rtl.css 547 B 0 B
build/format-library/style.css 548 B 0 B
build/hooks/index.js 1.74 kB 0 B
build/html-entities/index.js 622 B 0 B
build/i18n/index.js 3.54 kB 0 B
build/is-shallow-equal/index.js 709 B 0 B
build/keycodes/index.js 1.85 kB 0 B
build/list-reusable-blocks/style-rtl.css 476 B 0 B
build/list-reusable-blocks/style.css 476 B 0 B
build/notices/index.js 1.69 kB 0 B
build/nux/index.js 3.27 kB 0 B
build/nux/style-rtl.css 671 B 0 B
build/nux/style.css 668 B 0 B
build/plugins/index.js 2.44 kB 0 B
build/primitives/index.js 1.35 kB 0 B
build/priority-queue/index.js 789 B 0 B
build/redux-routine/index.js 2.85 kB 0 B
build/shortcode/index.js 1.7 kB 0 B
build/url/index.js 4.06 kB 0 B
build/viewport/index.js 1.75 kB 0 B
build/warning/index.js 1.13 kB 0 B

compressed-size-action

@TimothyBJacobs
Copy link
Member

This looks great to me!

Chunks processing seems to be one step too far as they make the entire transaction not atomic.

Could you expand what this means?

@adamziel
Copy link
Contributor Author

Chunks processing seems to be one step too far as they make the entire transaction not atomic.
Could you expand what this means?

@TimothyBJacobs sure! The words "transaction" and "commit" usually characterize an atomic operation that either goes through or fails in its entirety. In this PR, however, a transaction may consists of multiple chunks which means it may partially fail so I'm not entirely comfortable with this vocabulary.

I'm not saying we shouldn't do chunks - that's a useful automation. If the caller needs to save 21 entities and a single batch may only handle 20, then it's going to send two batch requests anyway. Handling that logic manually would be repetitive and prone to errors so it's good to have it baked in. And there transactions out there that may end up in a partially failed state too (MyISAM - I'm looking at you).

I think I would be more comfortable with this if the chunks were called "transactions" and transactions were called something else. This way each transaction would be atomic, but the collection of transactions wouldn't.

@adamziel
Copy link
Contributor Author

There we go, I updated the nomenclature to "batch" and "transaction".

@TimothyBJacobs TimothyBJacobs force-pushed the update/data-layer-batch-requests-use-state branch from b40cf06 to e36d90e Compare October 18, 2020 22:28
@TimothyBJacobs
Copy link
Member

One issue I'm running into is that the batch we return to the caller takes the ordered list of items in a queue, and returns them as an object. Object insertion order isn't guaranteed. This means that if the caller doesn't have the itemId returned by enqueueItem, which in nearly all cases it won't. They can't match up their apiFetch calls with the results returned by processBatch.

Keying the results and errors by the itemId makes a lot of operations convenient, so maybe instead of reverting that to an array, we maintain a property on the batch of the itemIds in insertion order?

@youknowriad
Copy link
Contributor

@adamziel would you mind explaining the public API of the proposed package in the description or the README?

@adamziel adamziel merged commit f15f3e7 into master Oct 19, 2020
@adamziel adamziel deleted the update/data-layer-batch-requests-use-state branch October 19, 2020 17:13
@github-actions github-actions bot added this to the Gutenberg 9.2 milestone Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants