Browse Source
836: Introduce a supervisor actor that can restart another actor. r=thomaseizinger a=thomaseizinger 866: Bump vergen from 5.2.0 to 6.0.0 r=thomaseizinger a=dependabot[bot] Bumps [vergen](https://github.com/rustyhorde/vergen) from 5.2.0 to 6.0.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/rustyhorde/vergen/releases">vergen's releases</a>.</em></p> <blockquote> <h2>v6.0.0</h2> <ul> <li>The <code>Copy</code> impl was dropped from the <code>Config</code> struct to facilitate specifying a non-standard git base path.</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="resilient-broadcast21d6cdce0c
"><code>21d6cdc</code></a> prepare 6.0 release</li> <li>See full diff in <a href="https://github.com/rustyhorde/vergen/compare/5.2.0...6.0.0">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=vergen&package-manager=cargo&previous-version=5.2.0&new-version=6.0.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting ``@dependabot` rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - ``@dependabot` rebase` will rebase this PR - ``@dependabot` recreate` will recreate this PR, overwriting any edits that have been made to it - ``@dependabot` merge` will merge this PR after your CI passes on it - ``@dependabot` squash and merge` will squash and merge this PR after your CI passes on it - ``@dependabot` cancel merge` will cancel a previously requested merge and block automerging - ``@dependabot` reopen` will reopen this PR if it is closed - ``@dependabot` close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - ``@dependabot` ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - ``@dependabot` ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - ``@dependabot` ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> 867: Bump clap from 3.0.0-rc.1 to 3.0.0-rc.3 r=thomaseizinger a=dependabot[bot] Bumps [clap](https://github.com/clap-rs/clap) from 3.0.0-rc.1 to 3.0.0-rc.3. <details> <summary>Commits</summary> <ul> <li><a href="ada95d6f3d
"><code>ada95d6</code></a> chore: Release</li> <li><a href="4ab51976a3
"><code>4ab5197</code></a> chore: Release</li> <li><a href="ca48e22827
"><code>ca48e22</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/clap-rs/clap/issues/3140">#3140</a> from epage/panic</li> <li><a href="a4d2920cfa
"><code>a4d2920</code></a> docs(readme): Raise visibility of wild</li> <li><a href="756f825521
"><code>756f825</code></a> fix: Point to public method on ArgMatches panic</li> <li><a href="264dc37e50
"><code>264dc37</code></a> fix: Report if mixing subcommands and args</li> <li><a href="313b5e3c80
"><code>313b5e3</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/clap-rs/clap/issues/3138">#3138</a> from epage/disp</li> <li><a href="d38452c953
"><code>d38452c</code></a> refactor: Clarify explicit display order wins</li> <li><a href="ae2b315f6a
"><code>ae2b315</code></a> docs: Fix changelog link</li> <li><a href="cf93d7c75a
"><code>cf93d7c</code></a> docs: Fix example output</li> <li>Additional commits viewable in <a href="https://github.com/clap-rs/clap/compare/clap_generate-v3.0.0-rc.1...clap_generate-v3.0.0-rc.3">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=clap&package-manager=cargo&previous-version=3.0.0-rc.1&new-version=3.0.0-rc.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting ``@dependabot` rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - ``@dependabot` rebase` will rebase this PR - ``@dependabot` recreate` will recreate this PR, overwriting any edits that have been made to it - ``@dependabot` merge` will merge this PR after your CI passes on it - ``@dependabot` squash and merge` will squash and merge this PR after your CI passes on it - ``@dependabot` cancel merge` will cancel a previously requested merge and block automerging - ``@dependabot` reopen` will reopen this PR if it is closed - ``@dependabot` close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - ``@dependabot` ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - ``@dependabot` ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - ``@dependabot` ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> 868: Bump async-trait from 0.1.51 to 0.1.52 r=thomaseizinger a=dependabot[bot] Bumps [async-trait](https://github.com/dtolnay/async-trait) from 0.1.51 to 0.1.52. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/dtolnay/async-trait/releases">async-trait's releases</a>.</em></p> <blockquote> <h2>0.1.52</h2> <ul> <li>Eliminate <code>clippy::shadow_some</code> restriction lint from generated code (<a href="https://github-redirect.dependabot.com/dtolnay/async-trait/issues/184">#184</a>, thanks <a href="https://github.com/c410-f3r"><code>`@c410-f3r</code></a>)</li>` </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="20bd296e0d
"><code>20bd296</code></a> Release 0.1.52</li> <li><a href="076b7303ab
"><code>076b730</code></a> Touch up PR 184</li> <li><a href="9c42e3d90d
"><code>9c42e3d</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/dtolnay/async-trait/issues/184">#184</a> from c410-f3r/clippy</li> <li><a href="7f0d4b6488
"><code>7f0d4b6</code></a> Format PR 184 with rustfmt</li> <li><a href="572f7e95f4
"><code>572f7e9</code></a> Sort lint_suppress_with_body</li> <li><a href="5629db9678
"><code>5629db9</code></a> Fix <code>clippy::shadow_same</code> warning</li> <li><a href="c5de48ef87
"><code>c5de48e</code></a> Update ui test suite to nightly-2021-11-26</li> <li><a href="7080dc8c99
"><code>7080dc8</code></a> Raise minimum tested version to rustc 1.45</li> <li><a href="278abc7ab4
"><code>278abc7</code></a> Install newest build of cargo-outdated</li> <li><a href="1ab566d3e7
"><code>1ab566d</code></a> Remove noisy warnings from unreachable ui test</li> <li>Additional commits viewable in <a href="https://github.com/dtolnay/async-trait/compare/0.1.51...0.1.52">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=async-trait&package-manager=cargo&previous-version=0.1.51&new-version=0.1.52)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting ``@dependabot` rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - ``@dependabot` rebase` will rebase this PR - ``@dependabot` recreate` will recreate this PR, overwriting any edits that have been made to it - ``@dependabot` merge` will merge this PR after your CI passes on it - ``@dependabot` squash and merge` will squash and merge this PR after your CI passes on it - ``@dependabot` cancel merge` will cancel a previously requested merge and block automerging - ``@dependabot` reopen` will reopen this PR if it is closed - ``@dependabot` close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - ``@dependabot` ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - ``@dependabot` ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - ``@dependabot` ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> 869: Bump typescript from 4.5.2 to 4.5.3 in /taker-frontend r=thomaseizinger a=dependabot[bot] Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.5.2 to 4.5.3. <details> <summary>Commits</summary> <ul> <li>See full diff in <a href="https://github.com/Microsoft/TypeScript/commits">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=typescript&package-manager=npm_and_yarn&previous-version=4.5.2&new-version=4.5.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting ``@dependabot` rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - ``@dependabot` rebase` will rebase this PR - ``@dependabot` recreate` will recreate this PR, overwriting any edits that have been made to it - ``@dependabot` merge` will merge this PR after your CI passes on it - ``@dependabot` squash and merge` will squash and merge this PR after your CI passes on it - ``@dependabot` cancel merge` will cancel a previously requested merge and block automerging - ``@dependabot` reopen` will reopen this PR if it is closed - ``@dependabot` close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - ``@dependabot` ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - ``@dependabot` ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - ``@dependabot` ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> 870: Bump @chakra-ui/react from 1.7.2 to 1.7.3 in /taker-frontend r=thomaseizinger a=dependabot[bot] Bumps [`@chakra-ui/react](https://github.com/chakra-ui/chakra-ui/tree/HEAD/packages/react)` from 1.7.2 to 1.7.3. <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/chakra-ui/chakra-ui/blob/main/packages/react/CHANGELOG.md"><code>`@chakra-ui/react</code>'s` changelog</a>.</em></p> <blockquote> <h2>1.7.3</h2> <h3>Patch Changes</h3> <ul> <li><a href="https://github-redirect.dependabot.com/chakra-ui/chakra-ui/pull/5133">#5133</a> <a href="6efe10f210
"><code>6efe10f21</code></a> Thanks <a href="https://github.com/yoannfleurydev"><code>`@yoannfleurydev</code></a>!` - Update storybook url configuration for <code>`@chakra-ui/react</code>` to <a href="https://storybook.chakra-ui.com">https://storybook.chakra-ui.com</a></li> <li>Updated dependencies [<a href="26d2a547bc
"><code>26d2a547b</code></a>, <a href="cd0b7996b3
"><code>cd0b7996b</code></a>, <a href="ba76b8125a
"><code>ba76b8125</code></a>, <a href="d139cc1515
"><code>d139cc151</code></a>, <a href="586eb6090f
"><code>586eb6090</code></a>, <a href="f565841c62
"><code>f565841c6</code></a>, <a href="f15099adc6
"><code>f15099adc</code></a>, <a href="98b9fbecb2
"><code>98b9fbecb</code></a>, <a href="c20aa919e4
"><code>c20aa919e</code></a>, <a href="53e2df4f9c
"><code>53e2df4f9</code></a>, <a href="b4decca9af
"><code>b4decca9a</code></a>, <a href="39846457e2
"><code>39846457e</code></a>, <a href="f4fd9441ea
"><code>f4fd9441e</code></a>, <a href="17400aff62
"><code>17400aff6</code></a>]: <ul> <li><code>`@chakra-ui/layout</code><a` href="https://github.com/1"><code>`@1</code></a>.6.0</li>` <li><code>`@chakra-ui/menu</code><a` href="https://github.com/1"><code>`@1</code></a>.8.2</li>` <li><code>`@chakra-ui/popover</code><a` href="https://github.com/1"><code>`@1</code></a>.11.0</li>` <li><code>`@chakra-ui/input</code><a` href="https://github.com/1"><code>`@1</code></a>.3.2</li>` <li><code>`@chakra-ui/system</code><a` href="https://github.com/1"><code>`@1</code></a>.8.3</li>` <li><code>`@chakra-ui/theme</code><a` href="https://github.com/1"><code>`@1</code></a>.12.2</li>` <li><code>`@chakra-ui/toast</code><a` href="https://github.com/1"><code>`@1</code></a>.5.0</li>` <li><code>`@chakra-ui/tooltip</code><a` href="https://github.com/1"><code>`@1</code></a>.4.2</li>` <li><code>`@chakra-ui/media-query</code><a` href="https://github.com/1"><code>`@1</code></a>.2.2</li>` <li><code>`@chakra-ui/transition</code><a` href="https://github.com/1"><code>`@1</code></a>.4.2</li>` <li><code>`@chakra-ui/icon</code><a` href="https://github.com/2"><code>`@2</code></a>.0.0</li>` <li><code>`@chakra-ui/accordion</code><a` href="https://github.com/1"><code>`@1</code></a>.4.2</li>` <li><code>`@chakra-ui/alert</code><a` href="https://github.com/1"><code>`@1</code></a>.3.2</li>` <li><code>`@chakra-ui/close-button</code><a` href="https://github.com/1"><code>`@1</code></a>.2.2</li>` <li><code>`@chakra-ui/form-control</code><a` href="https://github.com/1"><code>`@1</code></a>.5.2</li>` <li><code>`@chakra-ui/modal</code><a` href="https://github.com/1"><code>`@1</code></a>.10.2</li>` <li><code>`@chakra-ui/number-input</code><a` href="https://github.com/1"><code>`@1</code></a>.3.2</li>` <li><code>`@chakra-ui/provider</code><a` href="https://github.com/1"><code>`@1</code></a>.7.3</li>` <li><code>`@chakra-ui/radio</code><a` href="https://github.com/1"><code>`@1</code></a>.4.3</li>` <li><code>`@chakra-ui/select</code><a` href="https://github.com/1"><code>`@1</code></a>.2.2</li>` <li><code>`@chakra-ui/skeleton</code><a` href="https://github.com/1"><code>`@1</code></a>.2.3</li>` <li><code>`@chakra-ui/stat</code><a` href="https://github.com/1"><code>`@1</code></a>.2.2</li>` <li><code>`@chakra-ui/tag</code><a` href="https://github.com/1"><code>`@1</code></a>.2.2</li>` <li><code>`@chakra-ui/textarea</code><a` href="https://github.com/1"><code>`@1</code></a>.2.2</li>` </ul> </li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="211c64187d
"><code>211c641</code></a> chore(release): version packages</li> <li><a href="5c865602bf
"><code>5c86560</code></a> Merge pull request <a href="https://github.com/chakra-ui/chakra-ui/tree/HEAD/packages/react/issues/4594">#4594</a> from feychenie/refactor/move-provider-to-separate-pa...</li> <li><a href="74c850b551
"><code>74c850b</code></a> chore: updates</li> <li><a href="e7a732755e
"><code>e7a7327</code></a> chore: general cleanups and updates to theme</li> <li><a href="5b3373daef
"><code>5b3373d</code></a> chore: update themes and fix type issues</li> <li><a href="209c6d3f45
"><code>209c6d3</code></a> chore: update extend theme to support new anatomy</li> <li><a href="26f875c62a
"><code>26f875c</code></a> refactor: move ChakraProvider to its own package</li> <li>See full diff in <a href="https://github.com/chakra-ui/chakra-ui/commits/`@chakra-ui/menu@1.7.3/packages/react">compare` view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=`@chakra-ui/react&package-manager=npm_and_yarn&previous-version=1.7.2&new-version=1.7.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)` Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting ``@dependabot` rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - ``@dependabot` rebase` will rebase this PR - ``@dependabot` recreate` will recreate this PR, overwriting any edits that have been made to it - ``@dependabot` merge` will merge this PR after your CI passes on it - ``@dependabot` squash and merge` will squash and merge this PR after your CI passes on it - ``@dependabot` cancel merge` will cancel a previously requested merge and block automerging - ``@dependabot` reopen` will reopen this PR if it is closed - ``@dependabot` close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - ``@dependabot` ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - ``@dependabot` ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - ``@dependabot` ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Co-authored-by: Thomas Eizinger <thomas@eizinger.io> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
bors[bot]
3 years ago
committed by
GitHub
parent
commit
b9d8a7ba39
9 changed files with 326 additions and 233 deletions
@ -0,0 +1,90 @@ |
|||
use crate::Tasks; |
|||
use async_trait::async_trait; |
|||
use std::fmt; |
|||
use xtra::{Address, Context}; |
|||
use xtra_productivity::xtra_productivity; |
|||
|
|||
/// A supervising actor reacts to messages from the actor it is supervising and restarts it based on
|
|||
/// a given policy.
|
|||
pub struct Actor<T, R> { |
|||
context: Context<T>, |
|||
ctor: Box<dyn Fn(Address<Self>) -> T + Send + 'static>, |
|||
tasks: Tasks, |
|||
restart_policy: Box<dyn FnMut(R) -> bool + Send + 'static>, |
|||
} |
|||
|
|||
impl<T, R> Actor<T, R> |
|||
where |
|||
T: xtra::Actor, |
|||
R: fmt::Display + 'static, |
|||
{ |
|||
/// Construct a new supervisor.
|
|||
///
|
|||
/// The supervisor needs to know two things:
|
|||
/// 1. How to construct an instance of the actor.
|
|||
/// 2. When to construct an instance of the actor.
|
|||
pub fn new( |
|||
ctor: impl (Fn(Address<Self>) -> T) + Send + 'static, |
|||
restart_policy: impl (FnMut(R) -> bool) + Send + 'static, |
|||
) -> (Self, Address<T>) { |
|||
let (address, context) = Context::new(None); |
|||
|
|||
let supervisor = Self { |
|||
context, |
|||
ctor: Box::new(ctor), |
|||
tasks: Tasks::default(), |
|||
restart_policy: Box::new(restart_policy), |
|||
}; |
|||
|
|||
(supervisor, address) |
|||
} |
|||
|
|||
fn spawn_new(&mut self, ctx: &mut Context<Self>) { |
|||
tracing::info!("Spawning new instance of actor"); // TODO: Include name
|
|||
|
|||
let this = ctx.address().expect("we are alive"); |
|||
let actor = (self.ctor)(this); |
|||
|
|||
self.tasks.add(self.context.attach(actor)); |
|||
} |
|||
} |
|||
|
|||
#[async_trait] |
|||
impl<T, R> xtra::Actor for Actor<T, R> |
|||
where |
|||
T: xtra::Actor, |
|||
R: fmt::Display + 'static, |
|||
{ |
|||
async fn started(&mut self, ctx: &mut Context<Self>) { |
|||
self.spawn_new(ctx); |
|||
} |
|||
} |
|||
|
|||
#[xtra_productivity] |
|||
impl<T, R> Actor<T, R> |
|||
where |
|||
T: xtra::Actor, |
|||
R: fmt::Display + 'static, |
|||
{ |
|||
pub fn handle(&mut self, msg: Stopped<R>, ctx: &mut Context<Self>) { |
|||
let reason = msg.reason; |
|||
|
|||
tracing::info!("Actor stopped: {}", reason); // TODO: Include name of actor
|
|||
|
|||
let should_restart = (self.restart_policy)(reason); |
|||
|
|||
tracing::debug!("Restart actor? {}", should_restart); |
|||
|
|||
if should_restart { |
|||
self.spawn_new(ctx) |
|||
} |
|||
} |
|||
} |
|||
|
|||
/// Tell the supervisor that the actor was stopped.
|
|||
///
|
|||
/// The given `reason` will be passed to the `restart_policy` configured in the supervisor. If it
|
|||
/// yields `true`, a new instance of the actor will be spawned.
|
|||
pub struct Stopped<R> { |
|||
pub reason: R, |
|||
} |
Loading…
Reference in new issue