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

Added TimeoutManager item retention #6

Merged
merged 17 commits into from
Sep 6, 2024
Merged

Added TimeoutManager item retention #6

merged 17 commits into from
Sep 6, 2024

Conversation

mkatychev
Copy link
Contributor

@mkatychev mkatychev commented Aug 30, 2024

TimeoutManager can now hold a Copy item (to be returned to sender) for a set amount of time:

rex-sm/src/timeout.rs

Lines 172 to 176 in efb8b50

pub enum Operation<T> {
Cancel,
Set(Instant),
Retain(T, Instant),
}

This opens the way for retry logic implementations that can re-run on a cadence without blocking StateMachine processors.

  • StateMachine::process is not a sync method
  • StateId is now part of the SmContext:

    rex-sm/src/manager.rs

    Lines 129 to 134 in 0bbc754

    pub struct SmContext<K: Rex> {
    pub signal_queue: SignalQueue<K>,
    pub notification_queue: NotificationQueue<K::Message>,
    pub state_store: Arc<StateStore<StateId<K>, K::State>>,
    pub id: StateId<K>,
    }
  • Added timeout::Timeout trait for Kinds that handle timeout items:

    rex-sm/src/timeout.rs

    Lines 159 to 166 in efb8b50

    pub trait Timeout: Rex
    where
    Self::Message: TimeoutMessage<Self>,
    {
    fn return_item(&self, _item: RetainItem<Self>) -> Option<Self::Input> {
    None
    }
    }
  • Added timeout::TimeoutMessage for RexMessages that handle timeoue items:

    rex-sm/src/timeout.rs

    Lines 150 to 157 in efb8b50

    pub trait TimeoutMessage<K: Rex>:
    std::fmt::Debug
    + RexMessage
    + From<UnaryRequest<K, Operation<Self::Item>>>
    + TryInto<UnaryRequest<K, Operation<Self::Item>>, Error = Report<ConversionError>>
    {
    type Item: Copy + Send + std::fmt::Debug;
    }

@mkatychev mkatychev changed the base branch from main to v0.5.x August 30, 2024 21:51
@mergify mergify bot added the feature label Aug 30, 2024
@mkatychev mkatychev changed the base branch from v0.5.x to main August 30, 2024 22:01
@mkatychev mkatychev marked this pull request as ready for review September 3, 2024 16:00
@mkatychev mkatychev requested a review from a team September 3, 2024 16:12
Comment on lines +254 to 255
sm.process(ctx.init(id), input);
continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
sm.process(ctx.init(id), input);
continue;
sm.process(ctx.init(id), input);

mkatychev and others added 2 commits September 4, 2024 19:06
Co-authored-by: Jeremiah Goyette <jgoyette@knox-networks.com>
Co-authored-by: Jeremiah Goyette <jgoyette@knox-networks.com>
@mergify mergify bot merged commit d8991f7 into main Sep 6, 2024
4 checks passed
@mergify mergify bot removed the automerge label Sep 6, 2024
@mergify mergify bot deleted the feat/retain-time branch September 6, 2024 14:42
Copy link

mergify bot commented Sep 6, 2024

[✅] @mkatychev: Added TimeoutManager item retention has been merged successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants