-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bfetch (2) #53711
bfetch (2) #53711
Conversation
Pinging @elastic/kibana-app-arch (Team:AppArch) |
examples/bfetch_explorer/public/containers/app/sidebar/index.tsx
Outdated
Show resolved
Hide resolved
examples/bfetch_explorer/public/components/count_until/index.tsx
Outdated
Show resolved
Hide resolved
examples/bfetch_explorer/public/components/count_until/index.tsx
Outdated
Show resolved
Hide resolved
…ex.tsx Co-Authored-By: Lukas Olson <[email protected]>
Co-Authored-By: Lukas Olson <[email protected]>
Co-Authored-By: Lukas Olson <[email protected]>
Yes, it does not have to return a
They are separate because they provide different functionality, they could be combined into one class, but since its already written separately, would like to leave it as is.
Yes, I added functional tests here. |
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recent code changes LGTM but I didn't pull down and test (although I did yesterday and everything looked good)
@elasticmachine merge upstream |
@elasticmachine merge upstream |
* feat: 🎸 implement ItemBuffer * test: 💍 add tests for ItemBuffer * feat: 🎸 add TimedItemBuffer * test: 💍 add TimedItemBuffer tests * feat: 🎸 add createBatchedFunction * chore: 🤖 save wip on higher level batching * test: 💍 add createBatchedFunction tests * feat: 🎸 implement createStreamingBatchedFunction() method * refactor: 💡 rename "data" key to "result" * feat: 🎸 return error in "error" key in legacy protocol * feat: 🎸 add server-side to Expressions plugin * refactor: 💡 move interpreter server-side registries to NP * feat: 🎸 implement bfetch.addBatchProcessingRoute * feat: 🎸 improve streaming and batching func to pass request * feat: 🎸 initial setup of new expressions batching endpoint * feat: 🎸 expose bfetch.batchedFunction() function * feat: 🎸 add of() function of() function awaits a promise and converts it to a 3-tuple representing its state. * refactor: 💡 move normalizeError() to /common * feat: 🎸 improve createStreamingBatchedFunction() function * refactor: 💡 move GET /api/interpreter/fns to the New Platform * feat: 🎸 move batched_fetch to the New Platform * feat: 🎸 implement legacy interpreter batching on server in NP * feat: 🎸 switch legacy interpreter server functions to NP * chore: 🤖 remove unused import * fix: 🐛 correct expressions mocks * test: 💍 fix batching tests after refactor * test: 💍 stub bfetch plugin explorer * test: 💍 add routing and app structure to bfetch_explorer * test: 💍 add server-side to bfetch_explorer * test: 💍 create <DoubleInteger> component in bfetch_explorer * test: 💍 improve bfetch_explorer * test: 💍 add <CountUntil> demo to bfetch_explorer * test: 💍 by default redirect to first bfetch_explorer example * test: 💍 add error example to bfetch_explorer * docs: ✏️ improve bfetch docs * docs: ✏️ improve bfetch server-side docs * chore: 🤖 address self-review comments * fix: 🐛 use new core ES data client, remove unuseed import * fix: 🐛 remove unused interface import * Update examples/bfetch_explorer/public/components/count_until/index.tsx Co-Authored-By: Lukas Olson <[email protected]> * Update examples/bfetch_explorer/public/components/double_integers/index.tsx Co-Authored-By: Lukas Olson <[email protected]> * Update src/plugins/bfetch/common/buffer/item_buffer.ts Co-Authored-By: Lukas Olson <[email protected]> * Update src/plugins/kibana_utils/common/of.ts Co-Authored-By: Lukas Olson <[email protected]> * docs: ✏️ add batchedFunction params to README * refactor: 💡 rename onflush to onFlush * feat: 🎸 make maxItemAge optional in TimedItemBuffer * refactor: 💡 remove promise from fetchStreaming * test: 💍 add bfetch_explorer functional tests * test: 💍 rename test plugin to kbn_tp_bfetch_explorer * fix: 🐛 use stream instead of removed promise * fix: 🐛 use correct tsconfig.json in bfetch test plugin * feat: 🎸 add kbn_tp_bfetch_explorer server-side files to tsconfi Co-authored-by: Lukas Olson <[email protected]> Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Lukas Olson <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
* feat: 🎸 implement ItemBuffer * test: 💍 add tests for ItemBuffer * feat: 🎸 add TimedItemBuffer * test: 💍 add TimedItemBuffer tests * feat: 🎸 add createBatchedFunction * chore: 🤖 save wip on higher level batching * test: 💍 add createBatchedFunction tests * feat: 🎸 implement createStreamingBatchedFunction() method * refactor: 💡 rename "data" key to "result" * feat: 🎸 return error in "error" key in legacy protocol * feat: 🎸 add server-side to Expressions plugin * refactor: 💡 move interpreter server-side registries to NP * feat: 🎸 implement bfetch.addBatchProcessingRoute * feat: 🎸 improve streaming and batching func to pass request * feat: 🎸 initial setup of new expressions batching endpoint * feat: 🎸 expose bfetch.batchedFunction() function * feat: 🎸 add of() function of() function awaits a promise and converts it to a 3-tuple representing its state. * refactor: 💡 move normalizeError() to /common * feat: 🎸 improve createStreamingBatchedFunction() function * refactor: 💡 move GET /api/interpreter/fns to the New Platform * feat: 🎸 move batched_fetch to the New Platform * feat: 🎸 implement legacy interpreter batching on server in NP * feat: 🎸 switch legacy interpreter server functions to NP * chore: 🤖 remove unused import * fix: 🐛 correct expressions mocks * test: 💍 fix batching tests after refactor * test: 💍 stub bfetch plugin explorer * test: 💍 add routing and app structure to bfetch_explorer * test: 💍 add server-side to bfetch_explorer * test: 💍 create <DoubleInteger> component in bfetch_explorer * test: 💍 improve bfetch_explorer * test: 💍 add <CountUntil> demo to bfetch_explorer * test: 💍 by default redirect to first bfetch_explorer example * test: 💍 add error example to bfetch_explorer * docs: ✏️ improve bfetch docs * docs: ✏️ improve bfetch server-side docs * chore: 🤖 address self-review comments * fix: 🐛 use new core ES data client, remove unuseed import * fix: 🐛 remove unused interface import * Update examples/bfetch_explorer/public/components/count_until/index.tsx Co-Authored-By: Lukas Olson <[email protected]> * Update examples/bfetch_explorer/public/components/double_integers/index.tsx Co-Authored-By: Lukas Olson <[email protected]> * Update src/plugins/bfetch/common/buffer/item_buffer.ts Co-Authored-By: Lukas Olson <[email protected]> * Update src/plugins/kibana_utils/common/of.ts Co-Authored-By: Lukas Olson <[email protected]> * docs: ✏️ add batchedFunction params to README * refactor: 💡 rename onflush to onFlush * feat: 🎸 make maxItemAge optional in TimedItemBuffer * refactor: 💡 remove promise from fetchStreaming * test: 💍 add bfetch_explorer functional tests * test: 💍 rename test plugin to kbn_tp_bfetch_explorer * fix: 🐛 use stream instead of removed promise * fix: 🐛 use correct tsconfig.json in bfetch test plugin * feat: 🎸 add kbn_tp_bfetch_explorer server-side files to tsconfi Co-authored-by: Lukas Olson <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
Summary
Closes #44326
Partially addresses: #44393
batched_fetch
to the NP, now it isplugins.bfetch.batchedFunction
.plugins.bfetch.addBatchProcessingRoute
on server-side which works with client-sideplugins.bfetch.batchedFunction
.expressions
plugin.bfetch
plugin.bfetch_explorer
example plugin.To see the
bfetch_explorer
example plugin runChecklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.This was checked for cross-browser compatibility, including a check against IE11Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n supportDocumentation was added for features that require explanation or tutorialsThis was checked for keyboard-only and screenreader accessibilityFor maintainers
Dev Docs
Request batching and response streaming functionality of legacy Interpreter plugin has been moved out into a separate
bfetch
Kibana platform plugin. Now every plugin can create server endpoints and browser wrappers that can batch HTTP requests and stream responses back.As an example, we will create a batch processing endpoint that receives a number then doubles it
and streams it back. We will also consider the number to be time in milliseconds
and before streaming the number back the server will wait for the specified number of
milliseconds.
To do that, first create server-side batch processing route using
addBatchProcessingRoute
.Now on client-side create
double
function usingbatchedFunction
.The newly created
double
function can be called many times and itwill package individual calls into batches and send them to the server.
Note: the created
double
must accept a single object argument ({ num: number }
in this case)and it will return a promise that resolves into an object, too (also
{ num: number }
in this case).Use the
double
function.