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

Port Pulse, DelayFlow and Valve streams-contrib stages #3421

Merged

Conversation

alex-bogomaz
Copy link
Contributor

@alex-bogomaz alex-bogomaz commented Apr 26, 2018

Hello - this PR contains port of 3 following "Streams-Contrib" stages:

  • Pulse
  • DelayFlow
  • Valve

please review. This is for issue #3234

@Aaronontheweb
Copy link
Member

@marcpiechura any thoughts on these changes?

@marcpiechura
Copy link
Contributor

@alex-bogomaz sorry totally forgot to review your PR, I’m on vacation until next weekend, maybe @Horusiath will find some time to review it.

@marcpiechura
Copy link
Contributor

@alex-bogomaz haven’t forgot your PR but I’m still quite busy, will review it in the next days

Copy link
Contributor

@marcpiechura marcpiechura left a comment

Choose a reason for hiding this comment

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

Locks good overall, only a few remarks regarding naming, code style and internal optimization you can't know.

flip.AwaitResult().Should().BeTrue();

probe.ExpectNext().Should().Be(1);
probe.ExpectNext().Should().Be(2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just as note, you can simplify those checks by using probe.ExpectNext(1, 2)

/// </summary>
/// <param name="elem">element</param>
/// <returns></returns>
TimeSpan NextDelay(T elem);
Copy link
Contributor

Choose a reason for hiding this comment

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

We have agreed on using full names instead of shortcuts from the jvm, i.e. element instead of elem , it's not 100% rule especially vor local variables etc. but we should do it in the API, so please change.

_delay = delay;
}

public TimeSpan NextDelay(T elem) => _delay;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use /// <inheritdoc/>

_delay = _initialDelay;
}

public TimeSpan NextDelay(T elem)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use /// <inheritdoc/>

throw new ArgumentException("Increase step must be positive", nameof(increaseStep));

if (maxDelay <= initialDelay)
throw new ArgumentException("Max delay must be bigger than initial delay");
Copy link
Contributor

Choose a reason for hiding this comment

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

Add nameof as above

public Inlet<T> In = new Inlet<T>("Sample-in");
public Outlet<T> Out = new Outlet<T>("Sample-out");
public Inlet<T> In { get; }
public Outlet<T> Out { get; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch 👍

{
var promise = new TaskCompletionSource<bool>();
_flipCallback(Tuple.Create(flipToMode, promise));
return promise.Task;
Copy link
Contributor

Choose a reason for hiding this comment

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

either use promise or completion as name in both cases, I would prefer completion ;-)

_mode = mode;

In = new Inlet<T>("valve.in");
Out = new Outlet<T>("valve.out");
Copy link
Contributor

Choose a reason for hiding this comment

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

could be inlined with the property definition if you want to save two lines ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I followed "Retry.cs" code-style here - inlets and outlets are initialized in constructor, not in property declaration

if (IsOpen)
Pull(_valve.In);
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

See comment about IOutHandler and IInHandler

public FixedDelay(TimeSpan delay)
{
_delay = delay;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If you want you can use the ney C# syntax for single line constructors / methods
public FixedDelay(TimeSpan delay) => _delay = delay;

@marcpiechura
Copy link
Contributor

Sorry for the delay @alex-bogomaz , left you some remarks but good work overall 👍

@alex-bogomaz
Copy link
Contributor Author

@marcpiechura - I'm finished with comments - could you please take a look when you have time

throw new ArgumentException("Increase step must be positive", nameof(increaseStep));

if (maxDelay <= initialDelay)
throw new Exception($"{nameof(maxDelay)} must be bigger than {nameof(initialDelay)}");
Copy link
Contributor

Choose a reason for hiding this comment

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

That‘s not exactly what I meant ;-)

throw new ArgumentException("Max delay must be bigger than initial delay", nameof(maxDelay));

@marcpiechura marcpiechura merged commit 56c284b into akkadotnet:dev May 24, 2018
@marcpiechura
Copy link
Contributor

Thanks for your contribution @alex-bogomaz 👌

cuteant added a commit to cuteant/akka.net that referenced this pull request May 24, 2018
* Port Pulse, DelayFlow, Valve

* use Tuple instead of ValueTuple

* minor code cleanup

* replace LambdaHandler with IInHandler and IOutHandler

* cache FixedDelay strategy

* IDelayStrategy - approve API changes

* Modified ArgumentException message in DelayFlow

Take from akkadotnet@56c284b
@Aaronontheweb Aaronontheweb added this to the 1.3.8 milestone Jun 4, 2018
cuteant added a commit to cuteant/akka.net that referenced this pull request Jun 7, 2018
* Port Pulse, DelayFlow, Valve

* use Tuple instead of ValueTuple

* minor code cleanup

* replace LambdaHandler with IInHandler and IOutHandler

* cache FixedDelay strategy

* IDelayStrategy - approve API changes

* Modified ArgumentException message in DelayFlow

Take from akkadotnet@56c284b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants