Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/beetlex-io/EventNext

EventNext is logic interface design actors components for .net core
https://github.com/beetlex-io/EventNext

actor dotnet event-driven interface-design logic-design

Last synced: 3 months ago
JSON representation

EventNext is logic interface design actors components for .net core

Awesome Lists containing this project

README

        

# EventNext
EventNext is logic interface design in event driven components for .net core

## samples
https://github.com/IKende/BeetleX-Samples

## Install
```
PM> Install-Package EventNext
```
## Define logic
``` csharp
public interface IUserService
{
Task Income(int value);

Task Payout(int value);

Task Amount();
}

[Service(typeof(IUserService))]
public class UserService : IUserService
{
private int mAmount;

public Task Amount()
{
return Task.FromResult(mAmount);
}

public Task Income(int value)
{
mAmount += value;
return Task.FromResult(mAmount);
}

public Task Payout(int value)
{
mAmount -= value;
return Task.FromResult(mAmount);
}
}
```
## using
``` csharp
EventCenter.Register(typeof(Program).Assembly);
henry = EventCenter.Create("henry");
nb = EventCenter.Create("nb");
var result = await henry.Income(10);
result = await henry.Payout(10);
result = await nb.Income(10);
result = await nb.Payout(10);
```
## Performance (vs akka.net)
default setting `Environment:e3-1230v2 16g memory windows 2008r2 .netcore 2.15`
- Akka.net
```
public class UserActor : ReceiveActor
{
public UserActor()
{
Receive(Income =>
{
mAmount += Income.Memory;
this.Sender.Tell(mAmount);
});
Receive(Outlay =>
{
mAmount -= Outlay.Memory;
this.Sender.Tell(mAmount);
});
Receive(Outlay =>
{
this.Sender.Tell(mAmount);
});
}
private decimal mAmount;
}
//invoke
Income income = new Income { Memory = i };
var result = await nbActor.Ask(income);
Payout payout = new Payout { Memory = i };
var result = await nbActor.Ask(payout);
```
- EventNext
```
[Service(typeof(IUserService))]
public class UserService : IUserService
{
private int mAmount;

public Task Amount()
{
return Task.FromResult(mAmount);
}

public Task Income(int value)
{
mAmount += value;
return Task.FromResult(mAmount);
}

public Task Payout(int value)
{
mAmount -= value;
return Task.FromResult(mAmount);
}
}
//invoke
var result = await nb.Income(i);
var result = await nb.Payout(i);
```
![](https://github.com/IKende/EventNext/blob/master/EventNext0.5.6.png?raw=true)