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

feat(jstzd): define Task trait #563

Merged
merged 1 commit into from
Sep 16, 2024
Merged

Conversation

huancheng-trili
Copy link
Collaborator

@huancheng-trili huancheng-trili commented Sep 13, 2024

Context

Define the Task trait. Task represents any task to be run with backends, e.g. octez node, jstz node, etc.

JSTZ-115

Description

Define the basic Task trait.

The methods:

  • spawn: The initialiser that takes in the necessary config for this task and runs the task.
  • kill: Abort the running task.
  • health_check: Check if the task is still alive.

Manually testing the PR

cargo build

$ cd $(git rev-parse --show-toplevel)/crates/jstzd && cargo build
   Compiling jstzd v0.1.0-alpha.0 (/Users/huanchengchang/code/jstz/crates/jstzd)
    Finished dev [unoptimized + debuginfo] target(s) in 0.64s

Copy link

codecov bot commented Sep 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 34.31%. Comparing base (1475a6a) to head (7aae0bb).
Report is 1 commits behind head on main.


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1475a6a...7aae0bb. Read the comment docs.

Copy link
Collaborator

@zcabter zcabter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, minor nits 🪡

Cargo.toml Outdated
Comment on lines 15 to 16
"crates/octez",
"crates/jstzd"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Alphabetical ordering

Suggested change
"crates/octez",
"crates/jstzd"
"crates/jstzd"
"crates/octez",

Comment on lines 11 to 14
async-dropper = { version = "0.3.1", features = ["tokio", "simple"] }
async-trait = "0.1.82"
futures-util.workspace = true
async-scoped = "0.9.0"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Move dependencies to workspace Cargo

#[async_trait]
trait Task {
type Config;
async fn spawn(config: Self::Config) -> anyhow::Result<Self>
Copy link
Collaborator

@zcabter zcabter Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets just use anyhow::Result

@huancheng-trili huancheng-trili marked this pull request as ready for review September 13, 2024 15:30
Copy link
Collaborator

@zcabter zcabter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@huancheng-trili huancheng-trili force-pushed the huan/jstzd-define-task-trait branch from b21a887 to 7aae0bb Compare September 16, 2024 11:15
@huancheng-trili huancheng-trili merged commit 027eeb5 into main Sep 16, 2024
5 checks passed
@huancheng-trili huancheng-trili deleted the huan/jstzd-define-task-trait branch September 16, 2024 11:22
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.

2 participants