Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/beetlex-io/EventNext
- Owner: beetlex-io
- License: apache-2.0
- Created: 2019-05-18T02:18:36.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-11-22T00:21:40.000Z (about 2 years ago)
- Last Synced: 2024-11-10T12:52:02.583Z (3 months ago)
- Topics: actor, dotnet, event-driven, interface-design, logic-design
- Language: C#
- Homepage:
- Size: 86.9 KB
- Stars: 42
- Watchers: 4
- Forks: 10
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)