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

Akka Fsm Update #2559

Merged
merged 4 commits into from
Mar 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 31 additions & 18 deletions src/core/Akka.API.Tests/CoreAPISpec.ApproveCore.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ namespace Akka.Actor
public TState StateName { get; }
public void CancelTimer(string name) { }
public Akka.Actor.FSMBase.State<TState, TData> GoTo(TState nextStateName) { }
[System.ObsoleteAttribute("This method is obsoleted. Use GoTo(nextStateName).Using(newStateData) [1.2.0]")]
public Akka.Actor.FSMBase.State<TState, TData> GoTo(TState nextStateName, TData stateData) { }
public void Initialize() { }
public bool IsTimerActive(string name) { }
Expand Down Expand Up @@ -750,52 +751,59 @@ namespace Akka.Actor
public abstract class FSMBase : Akka.Actor.ActorBase
{
protected FSMBase() { }
public class CurrentState<TS>
public sealed class CurrentState<TS>
Copy link
Member

Choose a reason for hiding this comment

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

Sealing all of this off seems good to me.

{
public CurrentState(Akka.Actor.IActorRef fsmRef, TS state) { }
public Akka.Actor.IActorRef FsmRef { get; }
public TS State { get; }
public override bool Equals(object obj) { }
public override int GetHashCode() { }
public override string ToString() { }
}
public class Event<TD> : Akka.Actor.INoSerializationVerificationNeeded
public sealed class Event<TD> : Akka.Actor.INoSerializationVerificationNeeded
{
public Event(object fsmEvent, TD stateData) { }
public object FsmEvent { get; }
public TD StateData { get; }
public override string ToString() { }
}
public class Failure : Akka.Actor.FSMBase.Reason
public sealed class Failure : Akka.Actor.FSMBase.Reason
{
public Failure(object cause) { }
public object Cause { get; }
}
public class LogEntry<TS, TD>
public sealed class LogEntry<TS, TD>
{
public LogEntry(TS stateName, TD stateData, object fsmEvent) { }
public object FsmEvent { get; }
public TD StateData { get; }
public TS StateName { get; }
public override string ToString() { }
}
public class Normal : Akka.Actor.FSMBase.Reason
public sealed class Normal : Akka.Actor.FSMBase.Reason
{
[System.ObsoleteAttribute("This constructor is obsoleted. Use Normal.Instance [1.2.0]")]
public Normal() { }
public static Akka.Actor.FSMBase.Normal Instance { get; }
}
public abstract class Reason
{
protected Reason() { }
}
public class Shutdown : Akka.Actor.FSMBase.Reason
public sealed class Shutdown : Akka.Actor.FSMBase.Reason
{
[System.ObsoleteAttribute("This constructor is obsoleted. Use Shutdown.Instance [1.2.0]")]
public Shutdown() { }
public static Akka.Actor.FSMBase.Shutdown Instance { get; }
}
public class State<TS, TD> : System.IEquatable<Akka.Actor.FSMBase.State<TS, TD>>
{
public State(TS stateName, TD stateData, System.Nullable<System.TimeSpan> timeout = null, Akka.Actor.FSMBase.Reason stopReason = null, System.Collections.Generic.List<object> replies = null) { }
public System.Collections.Generic.List<object> Replies { get; set; }
public State(TS stateName, TD stateData, System.Nullable<System.TimeSpan> timeout = null, Akka.Actor.FSMBase.Reason stopReason = null, System.Collections.Generic.IReadOnlyList<object> replies = null, bool notifies = True) { }
public System.Collections.Generic.IReadOnlyList<object> Replies { get; set; }
public TD StateData { get; }
public TS StateName { get; }
public Akka.Actor.FSMBase.Reason StopReason { get; }
public System.Nullable<System.TimeSpan> Timeout { get; }
public Akka.Actor.FSMBase.State<TS, TD> Copy(System.Nullable<System.TimeSpan> timeout, Akka.Actor.FSMBase.Reason stopReason = null, System.Collections.Generic.List<object> replies = null) { }
public bool Equals(Akka.Actor.FSMBase.State<TS, TD> other) { }
public override bool Equals(object obj) { }
public Akka.Actor.FSMBase.State<TS, TD> ForMax(System.TimeSpan timeout) { }
Expand All @@ -804,31 +812,36 @@ namespace Akka.Actor
public override string ToString() { }
public Akka.Actor.FSMBase.State<TS, TD> Using(TD nextStateData) { }
}
public class StateTimeout
public sealed class StateTimeout
{
[System.ObsoleteAttribute("This constructor is obsoleted. Use Shutdown.Instance [1.2.0]")]
public StateTimeout() { }
public static Akka.Actor.FSMBase.StateTimeout Instance { get; }
}
public class StopEvent<TS, TD> : Akka.Actor.INoSerializationVerificationNeeded
public sealed class StopEvent<TS, TD> : Akka.Actor.INoSerializationVerificationNeeded
{
public StopEvent(Akka.Actor.FSMBase.Reason reason, TS terminatedState, TD stateData) { }
public Akka.Actor.FSMBase.Reason Reason { get; }
public TD StateData { get; }
public TS TerminatedState { get; }
public override string ToString() { }
}
public class SubscribeTransitionCallBack
public sealed class SubscribeTransitionCallBack
{
public SubscribeTransitionCallBack(Akka.Actor.IActorRef actorRef) { }
public Akka.Actor.IActorRef ActorRef { get; }
}
public class Transition<TS>
public sealed class Transition<TS>
{
public Transition(Akka.Actor.IActorRef fsmRef, TS from, TS to) { }
public TS From { get; }
public Akka.Actor.IActorRef FsmRef { get; }
public TS To { get; }
public override bool Equals(object obj) { }
public override int GetHashCode() { }
public override string ToString() { }
}
public class UnsubscribeTransitionCallBack
public sealed class UnsubscribeTransitionCallBack
{
public UnsubscribeTransitionCallBack(Akka.Actor.IActorRef actorRef) { }
public Akka.Actor.IActorRef ActorRef { get; }
Expand Down Expand Up @@ -3952,7 +3965,7 @@ namespace Akka.Routing
protected CustomRouterConfig() { }
protected CustomRouterConfig(string routerDispatcher) { }
}
public class Deafen : Akka.Routing.ListenerMessage
public sealed class Deafen : Akka.Routing.ListenerMessage
{
public Deafen(Akka.Actor.IActorRef listener) { }
public Akka.Actor.IActorRef Listener { get; }
Expand Down Expand Up @@ -4020,7 +4033,7 @@ namespace Akka.Routing
{
Akka.Routing.ListenerSupport Listeners { get; }
}
public class Listen : Akka.Routing.ListenerMessage
public sealed class Listen : Akka.Routing.ListenerMessage
{
public Listen(Akka.Actor.IActorRef listener) { }
public Akka.Actor.IActorRef Listener { get; }
Expand Down Expand Up @@ -4386,7 +4399,7 @@ namespace Akka.Routing
public Akka.Util.ISurrogated FromSurrogate(Akka.Actor.ActorSystem system) { }
}
}
public class WithListeners : Akka.Routing.ListenerMessage
public sealed class WithListeners : Akka.Routing.ListenerMessage
{
public WithListeners(System.Action<Akka.Actor.IActorRef> listenerFunction) { }
public System.Action<Akka.Actor.IActorRef> ListenerFunction { get; }
Expand Down Expand Up @@ -5073,7 +5086,7 @@ namespace Akka.Util.Internal
public static string BetweenDoubleQuotes(this string self) { }
public static System.Collections.Generic.IEnumerable<T> Concat<T>(this System.Collections.Generic.IEnumerable<T> enumerable, T item) { }
public static System.Collections.Generic.IEnumerable<T> Drop<T>(this System.Collections.Generic.IEnumerable<T> self, int count) { }
public static void ForEach<T>(this System.Collections.Generic.IEnumerable<T> enumerable, System.Action<T> action) { }
public static void ForEach<T>(this System.Collections.Generic.IEnumerable<T> source, System.Action<T> action) { }
public static TValue GetOrElse<TKey, TValue>(this System.Collections.Generic.IDictionary<TKey, TValue> hash, TKey key, TValue elseValue) { }
public static T GetOrElse<T>(this T obj, T elseValue) { }
public static T Head<T>(this System.Collections.Generic.IEnumerable<T> self) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -830,14 +830,14 @@ namespace Akka.Persistence.Fsm
public void WhenUnhandled(Akka.Persistence.Fsm.PersistentFSMBase<TState, TData, TEvent>.StateFunction stateFunction) { }
public class State<TState, TData, TEvent> : Akka.Actor.FSMBase.State<TState, TData>
{
public State(TState stateName, TData stateData, System.Nullable<System.TimeSpan> timeout = null, Akka.Actor.FSMBase.Reason stopReason = null, System.Collections.Generic.List<object> replies = null, Akka.Util.ILinearSeq<TEvent> domainEvents = null, System.Action<TData> afterTransitionDo = null) { }
public State(TState stateName, TData stateData, System.Nullable<System.TimeSpan> timeout = null, Akka.Actor.FSMBase.Reason stopReason = null, System.Collections.Generic.IReadOnlyList<object> replies = null, Akka.Util.ILinearSeq<TEvent> domainEvents = null, System.Action<TData> afterTransitionDo = null) { }
public System.Action<TData> AfterTransitionHandler { get; }
public Akka.Util.ILinearSeq<TEvent> DomainEvents { get; }
public bool Notifies { get; set; }
public new bool Notifies { get; set; }
public Akka.Persistence.Fsm.PersistentFSMBase<TState, TData, TEvent>.State AndThen(System.Action<TData> handler) { }
public Akka.Persistence.Fsm.PersistentFSMBase<TState, TData, TEvent>.State Applying(Akka.Util.ILinearSeq<TEvent> events) { }
public Akka.Persistence.Fsm.PersistentFSMBase<TState, TData, TEvent>.State Applying(TEvent e) { }
public Akka.Persistence.Fsm.PersistentFSMBase<TState, TData, TEvent>.State Copy(System.Nullable<System.TimeSpan> timeout, Akka.Actor.FSMBase.Reason stopReason = null, System.Collections.Generic.List<object> replies = null, Akka.Util.ILinearSeq<TEvent> domainEvents = null, System.Action<TData> afterTransitionDo = null) { }
public Akka.Persistence.Fsm.PersistentFSMBase<TState, TData, TEvent>.State Copy(System.Nullable<System.TimeSpan> timeout, Akka.Actor.FSMBase.Reason stopReason = null, System.Collections.Generic.IReadOnlyList<object> replies = null, Akka.Util.ILinearSeq<TEvent> domainEvents = null, System.Action<TData> afterTransitionDo = null) { }
public Akka.Persistence.Fsm.PersistentFSMBase<TState, TData, TEvent>.State ForMax(System.TimeSpan timeout) { }
public Akka.Persistence.Fsm.PersistentFSMBase<TState, TData, TEvent>.State Replying(object replyValue) { }
public Akka.Persistence.Fsm.PersistentFSMBase<TState, TData, TEvent>.State Using(TData nextStateData) { }
Expand All @@ -854,7 +854,7 @@ namespace Akka.Persistence.Fsm
public System.Action<TData> AfterTransitionHandler { get; }
public Akka.Util.ILinearSeq<TEvent> DomainEvents { get; }
public bool Notifies { get; set; }
public System.Collections.Generic.List<object> Replies { get; }
public System.Collections.Generic.IReadOnlyList<object> Replies { get; }
public TData StateData { get; }
public TState StateName { get; }
public Akka.Actor.FSMBase.Reason StopReason { get; }
Expand Down
10 changes: 5 additions & 5 deletions src/core/Akka.Persistence/Fsm/PersistentFSMBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public State Stay()
/// <returns>TBD</returns>
public State Stop()
{
return Stop(new FSMBase.Normal());
return Stop(FSMBase.Normal.Instance);
}

/// <summary>
Expand Down Expand Up @@ -659,7 +659,7 @@ protected override void PostStop()
* Setting this instance's state to Terminated does no harm during restart, since
* the new instance will initialize fresh using StartWith.
*/
Terminate(Stay().WithStopReason(new FSMBase.Shutdown()));
Terminate(Stay().WithStopReason(FSMBase.Shutdown.Instance));
base.PostStop();
}

Expand Down Expand Up @@ -1059,7 +1059,7 @@ public State ForMax(TimeSpan timeout)
/// <summary>
/// TBD
/// </summary>
public List<object> Replies
public IReadOnlyList<object> Replies
{
get
{
Expand Down Expand Up @@ -1137,7 +1137,7 @@ public class State : FSMBase.State<TState, TData>
/// <param name="domainEvents">TBD</param>
/// <param name="afterTransitionDo">TBD</param>
public State(TState stateName, TData stateData, TimeSpan? timeout = null, FSMBase.Reason stopReason = null,
List<object> replies = null, ILinearSeq<TEvent> domainEvents = null, Action<TData> afterTransitionDo = null)
IReadOnlyList<object> replies = null, ILinearSeq<TEvent> domainEvents = null, Action<TData> afterTransitionDo = null)
: base(stateName, stateData, timeout, stopReason, replies)
{
AfterTransitionHandler = afterTransitionDo;
Expand Down Expand Up @@ -1208,7 +1208,7 @@ public State AndThen(Action<TData> handler)
/// <param name="afterTransitionDo">TBD</param>
/// <returns>TBD</returns>
public State Copy(TimeSpan? timeout, FSMBase.Reason stopReason = null,
List<object> replies = null, ILinearSeq<TEvent> domainEvents = null, Action<TData> afterTransitionDo = null)
IReadOnlyList<object> replies = null, ILinearSeq<TEvent> domainEvents = null, Action<TData> afterTransitionDo = null)
{
return new State(StateName, StateData, timeout ?? Timeout, stopReason ?? StopReason,
replies ?? Replies,
Expand Down
4 changes: 2 additions & 2 deletions src/core/Akka.Remote.TestKit/BarrierCoordinator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ protected void InitFSM()
//we only allow the deadlines to get shorter
if (enterDeadline.TimeLeft < @event.StateData.Deadline.TimeLeft)
{
SetTimer("Timeout", new StateTimeout(), enterDeadline.TimeLeft, false);
SetTimer("Timeout", StateTimeout.Instance, enterDeadline.TimeLeft, false);
nextState = HandleBarrier(@event.StateData.Copy(arrived: together, deadline: enterDeadline));
}
else
Expand Down Expand Up @@ -693,7 +693,7 @@ protected void InitFSM()

OnTransition((state, nextState) =>
{
if (state == State.Idle && nextState == State.Waiting) SetTimer("Timeout", new StateTimeout(), NextStateData.Deadline.TimeLeft, false);
if (state == State.Idle && nextState == State.Waiting) SetTimer("Timeout", StateTimeout.Instance, NextStateData.Deadline.TimeLeft, false);
else if(state == State.Waiting && nextState == State.Idle) CancelTimer("Timeout");
});

Expand Down
Loading