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

Updating editable #1

Open
Cambyst opened this issue Sep 4, 2023 · 2 comments
Open

Updating editable #1

Cambyst opened this issue Sep 4, 2023 · 2 comments
Labels
T-good-first-issue This issue is good for newcomers.

Comments

@Cambyst
Copy link

Cambyst commented Sep 4, 2023

Hi Team,

Thank you for the great project ! I was wondering if you had an example of adding "editable" to a mutable attribute (for example list) and updating the value without cloning it ?

Many thanks in advance !

For instance, in example.graph:

node X -> O { #[editable = "true"] x: list<i32>, }

We could the below but it is expensive as it is cloning the x attribute:
`
impl Runnable<Request, EResponse> for X {
type Resp = XResponse;
type Error = ();

async fn run(&self, req: Request, prev_resp: EResponse) -> Result<Self::Resp, Self::Error> {
    tokio::time::sleep(prev_resp.0).await;
    let mut old_vec = self.x.load().to_vec();
    old_vec.push(req.user_age);
    self.x.store(Arc::new(old_vec));
    Ok(XResponse(!req.msg.contains('*')))
}

}`

@Millione
Copy link
Member

Millione commented Sep 4, 2023

Thank you for the great project ! I was wondering if you had an example of adding "editable" to a mutable attribute (for example list) and updating the value without cloning it ?

Right now we achieve the interior mutabilty using ArcSwap by default, which means it lacks the ability you required.

Maybe we can modify the DSL editable mark specification as follows:

node X -> O { #[editable = "::std::sync::RwLock"] x: list<i32> }
node X -> O { #[editable = "::std::cell::RefCell"] x: list<i32> }

It means the interior mutability controlled by the user, makes it more flexible.

@Millione
Copy link
Member

Millione commented Sep 4, 2023

@Cambyst BTW, do you have the interest to implement it? I'd be super welcomed for a PR.

@Millione Millione added the T-good-first-issue This issue is good for newcomers. label Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-good-first-issue This issue is good for newcomers.
Development

No branches or pull requests

2 participants