Skip to content
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

refactor: meta-service: re-implement export with Stream #13097

Merged
merged 1 commit into from
Oct 7, 2023

Conversation

drmingdrmer
Copy link
Member

@drmingdrmer drmingdrmer commented Oct 7, 2023

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

refactor: meta-service: re-implement export with Stream
  • Updated the export() function in grpc_service.rs to use crate
    futures-async-stream, changed return type of the function to use a
    BoxStream that yields a series of JSON strings, instead of returning
    a big Vec<String>.

    This allows for more efficient handling of asynchronous streams, which
    can provide performance improvements.

    Note that export(self: Arc<Sefl>) takes an Arc<Self> as argument
    because the generated gRPC stream signature requires a 'static
    lifetime. As a result, the export(&self) can not be used:

    type ExportStream: Stream<Item = Result<_, _>> + Send + 'static;
    
  • Add dependency crate futures-async-stream;

  • Enable unstable feature #![feature(generators)] for building a
    Stream from a generator(yield ...);

Changelog

  • Improvement

Related Issues


This change is Reviewable

@vercel
Copy link

vercel bot commented Oct 7, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
databend ⬜️ Ignored (Inspect) Visit Preview Oct 7, 2023 5:39am

@drmingdrmer drmingdrmer marked this pull request as ready for review October 7, 2023 04:13
@github-actions github-actions bot added the pr-refactor this PR changes the code base without new features or bugfix label Oct 7, 2023
@drmingdrmer
Copy link
Member Author

@everpcpc
This PR could be relevant to the new features that you are working on. Therefore I'd like to invite you to review this PR.

- Updated the `export()` function in `grpc_service.rs` to use crate
  `futures-async-stream`, changed return type of the function to use a
  `BoxStream` that yields a series of JSON strings, instead of returning
  a big `Vec<String>`.

  This allows for more efficient handling of asynchronous streams, which
  can provide performance improvements.

  Note that `export(self: Arc<Sefl>)` takes an `Arc<Self>` as argument
  because the generated `gRPC` stream signature requires a `'static`
  lifetime. As a result, the `export(&self)` can not be used:

  ```
  type ExportStream: Stream<Item = Result<_, _>> + Send + 'static;
  ```

- Add dependency crate `futures-async-stream`;

- Enable unstable feature `#![feature(generators)]` for building a
  `Stream` from a generator(`yield ...`);
@drmingdrmer drmingdrmer merged commit 8236a77 into databendlabs:main Oct 7, 2023
58 checks passed
@drmingdrmer drmingdrmer deleted the 42-export-stream-2 branch October 7, 2023 06:24
andylokandy pushed a commit to andylokandy/databend that referenced this pull request Nov 27, 2023
…#13097)

- Updated the `export()` function in `grpc_service.rs` to use crate
  `futures-async-stream`, changed return type of the function to use a
  `BoxStream` that yields a series of JSON strings, instead of returning
  a big `Vec<String>`.

  This allows for more efficient handling of asynchronous streams, which
  can provide performance improvements.

  Note that `export(self: Arc<Sefl>)` takes an `Arc<Self>` as argument
  because the generated `gRPC` stream signature requires a `'static`
  lifetime. As a result, the `export(&self)` can not be used:

  ```
  type ExportStream: Stream<Item = Result<_, _>> + Send + 'static;
  ```

- Add dependency crate `futures-async-stream`;

- Enable unstable feature `#![feature(generators)]` for building a
  `Stream` from a generator(`yield ...`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-refactor this PR changes the code base without new features or bugfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants