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

[TaskCenter][3/n] New TaskCenter::spawn_child #2343

Merged
merged 2 commits into from
Nov 25, 2024
Merged

[TaskCenter][3/n] New TaskCenter::spawn_child #2343

merged 2 commits into from
Nov 25, 2024

Commits on Nov 25, 2024

  1. [TaskCenter][2/n] Introduces TaskCenterFuture extensions traits

    - Adds `in_tc(&TaskCenter)` and `in_current_tc()` to scope a future to run in a task-center if it'll be dispatched as a task
    - Introduces a root task (TaskId(0)) in TaskCenter that's used as a default parent/source of task context
    - Removes unnecessary args from block_on, run_in_scope_sync. (some of those will be changed in future PRs)
    - Introduces `Metadata::current()` and `Metadata::with_current(F)`
    AhmedSoliman committed Nov 25, 2024
    Configuration menu
    Copy the full SHA
    0db0fd4 View commit details
    Browse the repository at this point in the history
  2. [TaskCenter][3/n] New TaskCenter::spawn_child

    - Improvements to the future extensions (fixing root task context propagation)
    - A round of removals of explicit task-center reference passing
    - `try_set_global_metadata` is now an associated function
    
    ## Example
    
    Before:
    ```rust
      task_center().spawn_child(
          TaskKind::RpcServer,
          "metadata-store-grpc",
          None,
          async move {
              net_util::run_hyper_server(
                  &bind_address,
                  service,
                  "metadata-store-grpc",
                  || health_status.update(MetadataServerStatus::Ready),
                  || health_status.update(MetadataServerStatus::Unknown),
              )
              .await?;
              Ok(())
          },
      )?;
    ```
    
    After:
    ```rust
      TaskCenter::spawn_child(TaskKind::RpcServer, "metadata-store-grpc", async move {
          net_util::run_hyper_server(
              &bind_address,
              service,
              "metadata-store-grpc",
              || health_status.update(MetadataServerStatus::Ready),
              || health_status.update(MetadataServerStatus::Unknown),
          )
          .await?;
          Ok(())
      })?;
    ```
    AhmedSoliman committed Nov 25, 2024
    Configuration menu
    Copy the full SHA
    6ba826f View commit details
    Browse the repository at this point in the history