Skip to content
Open
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
10 changes: 5 additions & 5 deletions samples/MessagingGAgent.Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
var parentAgent = client.GetGrain<IGroupGAgent>(parentId);

List<IMessagingGAgent> messagingAgents = [];
var maxAgents = 400;
var maxAgents = 10;
for(var i = 0; i < maxAgents; ++i)
{
var messagingAgentId = Guid.NewGuid();
Expand All @@ -42,8 +42,8 @@ await publisher.PublishEventAsync(new SendEvent()
{
Message = "Hello, World!"
});

await Task.Delay(600000);
Console.WriteLine("Published event. Waiting for agents to receive messages...");
await Task.Delay(maxAgents * 1000);

var completed = 0;
foreach (var agent in messagingAgents)
Expand All @@ -52,14 +52,14 @@ await publisher.PublishEventAsync(new SendEvent()
if (receivedMessages != maxAgents)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("Agent did not receive the expected number of messages. " + receivedMessages);
Console.WriteLine("Agent did not receive the expected number of messages. " + receivedMessages);

continue;
}
completed++;
}

Console.ForegroundColor = ConsoleColor.Green;
Console.Write("Completed: " + completed);
Console.WriteLine("Completed: " + completed);

await host.StopAsync();
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<ProjectReference Include="..\..\..\src\Aevatar.Plugins\Aevatar.Plugins.csproj" />
<ProjectReference Include="..\..\..\src\Aevatar\Aevatar.csproj" />
<ProjectReference Include="..\..\..\test\Aevatar.Core.Tests\Aevatar.Core.Tests.csproj" />
<ProjectReference Include="..\..\..\src\Aevatar.Agent.Abstractions\Aevatar.Agent.Abstractions.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
13 changes: 13 additions & 0 deletions src/Aevatar.Agent.Abstractions/Aevatar.Agent.Abstractions.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Orleans.Sdk" />
</ItemGroup>

</Project>
7 changes: 7 additions & 0 deletions src/Aevatar.Agent.Abstractions/IGAgentEventBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Aevatar.Agent.Abstractions;

public interface IGAgentEventBase
{
Guid Id { get; set; }
DateTime Ctime { get; set; }
}
7 changes: 7 additions & 0 deletions src/Aevatar.Agent.Abstractions/IGAgentEventBaseCollection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Aevatar.Agent.Abstractions;

public interface IGAgentEventBase<T> : IGAgentEventBase
where T : IGAgentEventBase<T>
{

}
9 changes: 9 additions & 0 deletions src/Aevatar.Agent.Abstractions/IGAgentState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Aevatar.Agent.Abstractions;

public interface IGAgentState
{
List<GrainId> Children{get;set;}
GrainId? Parent{get;set;}
string? GAgentCreator{get;set;}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@
<PackageReference Include="Orleans.SyncWork" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Aevatar.Agent.Abstractions\Aevatar.Agent.Abstractions.csproj" />
<ProjectReference Include="..\Aevatar.Core.Artifact\Aevatar.Core.Artifact.csproj" />
</ItemGroup>

</Project>
9 changes: 0 additions & 9 deletions src/Aevatar.Core.Abstractions/IArtifact.cs

This file was deleted.

2 changes: 2 additions & 0 deletions src/Aevatar.Core.Abstractions/IArtifactGAgent.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Aevatar.Core.Artifact;

namespace Aevatar.Core.Abstractions;

public interface IArtifactGAgent<TArtifact, TState, TStateLogEvent> : IGAgent
Expand Down
2 changes: 2 additions & 0 deletions src/Aevatar.Core.Abstractions/IGAgentFactory.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Aevatar.Core.Artifact;

namespace Aevatar.Core.Abstractions;

public interface IGAgentFactory
Expand Down
6 changes: 4 additions & 2 deletions src/Aevatar.Core.Abstractions/StateBase.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
using Aevatar.Agent.Abstractions;

namespace Aevatar.Core.Abstractions;

[GenerateSerializer]
public abstract class StateBase
public abstract class StateBase : IGAgentState
{
[Id(0)] public List<GrainId> Children { get; set; } = [];
[Id(1)] public GrainId? Parent { get; set; }
[Id(2)] public string? GAgentCreator { get; set; }

public void Apply(StateLogEventBase @stateLogEvent)
public void Apply(IGAgentEventBase @stateLogEvent)
{
// Just to avoid exception on GAgentBase.TransitionState.
}
Expand Down
12 changes: 9 additions & 3 deletions src/Aevatar.Core.Abstractions/StateLogEventBase.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
using Aevatar.Agent.Abstractions;

namespace Aevatar.Core.Abstractions;

[GenerateSerializer]
public abstract class StateLogEventBase
public abstract class StateLogEventBase : IGAgentEventBase
{
[Id(0)] public virtual Guid Id { get; set; }
[Id(1)] public DateTime Ctime { get; set; }
}

[GenerateSerializer]
public abstract class StateLogEventBase<T> : StateLogEventBase
where T:StateLogEventBase<T>;
public abstract class StateLogEventBase<T> : StateLogEventBase,IGAgentEventBase<T>
where T : StateLogEventBase<T>;




13 changes: 13 additions & 0 deletions src/Aevatar.Core.Artifact/Aevatar.Core.Artifact.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<ProjectReference Include="..\Aevatar.Agent.Abstractions\Aevatar.Agent.Abstractions.csproj" />
</ItemGroup>

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
13 changes: 13 additions & 0 deletions src/Aevatar.Core.Artifact/IArtifact.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Aevatar.Agent.Abstractions;

namespace Aevatar.Core.Artifact;

public interface IArtifact<in TState, TStateLogEvent>
where TState : IGAgentState
where TStateLogEvent : IGAgentEventBase<TStateLogEvent>
{
void TransitionState(IGAgentState state, IGAgentEventBase<TStateLogEvent> stateLogEvent);
string GetDescription();
}

public interface IArtifactGAgent;
2 changes: 2 additions & 0 deletions src/Aevatar.Core/Aevatar.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

<ItemGroup>
<ProjectReference Include="..\Aevatar.Core.Abstractions\Aevatar.Core.Abstractions.csproj" />
<ProjectReference Include="..\Aevatar.Agent.Abstractions\Aevatar.Agent.Abstractions.csproj" />
<ProjectReference Include="..\Aevatar.Core.Artifact\Aevatar.Core.Artifact.csproj" />
</ItemGroup>

</Project>
6 changes: 4 additions & 2 deletions src/Aevatar.Core/ArtifactGAgent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Reflection;
using Aevatar.Core.Abstractions;
using Aevatar.Core.Abstractions.Exceptions;
using Aevatar.Core.Artifact;
using Aevatar.Agent.Abstractions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

Expand Down Expand Up @@ -81,7 +83,7 @@ await base.OnGAgentActivateAsync(cancellationToken)

protected override void GAgentTransitionState(
TState state,
StateLogEventBase<TStateLogEvent> @event)
IGAgentEventBase<TStateLogEvent> @event)
{
ValidateParameters(state, @event);
try
Expand Down Expand Up @@ -134,7 +136,7 @@ private void ValidateOperationStatus()

private static void ValidateParameters(
TState state,
StateLogEventBase<TStateLogEvent> @event)
IGAgentEventBase<TStateLogEvent> @event)
{
if (state == null)
throw new ArgumentNullException(nameof(state),
Expand Down
5 changes: 3 additions & 2 deletions src/Aevatar.Core/GAgentBase.Subscribe.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Aevatar.Core.Abstractions;
using Microsoft.Extensions.Logging;
using Aevatar.Agent.Abstractions;

namespace Aevatar.Core;

public abstract partial class GAgentBase<TState, TStateLogEvent, TEvent, TConfiguration>
{
protected sealed override void TransitionState(TState state, StateLogEventBase<TStateLogEvent> @event)
protected sealed override void TransitionState(TState state, IGAgentEventBase<TStateLogEvent> @event)
{
switch (@event)
{
Expand Down Expand Up @@ -42,7 +43,7 @@ protected sealed override void TransitionState(TState state, StateLogEventBase<T
Logger.LogDebug("GrainId {GrainId}: State after transition: {@State}", this.GetGrainId().ToString(), State);
}

protected virtual void GAgentTransitionState(TState state, StateLogEventBase<TStateLogEvent> @event)
protected virtual void GAgentTransitionState(TState state, IGAgentEventBase<TStateLogEvent> @event)
{
// Derived classes can override this method.
}
Expand Down
7 changes: 4 additions & 3 deletions src/Aevatar.Core/GAgentBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Concurrent;
using Aevatar.Agent.Abstractions;
using Aevatar.Core.Abstractions;
using Aevatar.Core.Abstractions.Projections;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -35,8 +36,8 @@ public abstract class
[StorageProvider(ProviderName = "PubSubStore")]
[LogConsistencyProvider(ProviderName = "LogStorage")]
public abstract partial class
GAgentBase<TState, TStateLogEvent, TEvent, TConfiguration>
: JournaledGrain<TState, StateLogEventBase<TStateLogEvent>>, IStateGAgent<TState>, IExtGAgent
GAgentBase<TState, TStateLogEvent, TEvent, TConfiguration>
: JournaledGrain<TState, IGAgentEventBase<TStateLogEvent>>, IStateGAgent<TState>, IExtGAgent
where TState : StateBase, new()
where TStateLogEvent : StateLogEventBase<TStateLogEvent>
where TEvent : EventBase
Expand Down Expand Up @@ -349,7 +350,7 @@ protected sealed override async void RaiseEvent<T>(T @event)
}, Logger);
}

private async Task InternalRaiseEventAsync<T>(T raisedStateLogEvent) where T : StateLogEventBase<TStateLogEvent>
private async Task InternalRaiseEventAsync<T>(T raisedStateLogEvent) where T : IGAgentEventBase<TStateLogEvent>
{
await HandleRaiseEventAsync();
}
Expand Down
1 change: 1 addition & 0 deletions src/Aevatar.Core/GAgentFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Aevatar.Core.Abstractions;
using Aevatar.Core.Artifact;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Orleans.Streams;
Expand Down
1 change: 1 addition & 0 deletions src/Aevatar.Core/StateProjectionGAgentBase.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Reflection;
using Aevatar.Core.Abstractions;
using Aevatar.Agent.Abstractions;
using Orleans.Streams;

namespace Aevatar.Core;
Expand Down
1 change: 1 addition & 0 deletions src/Aevatar.Plugins/Aevatar.Plugins.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<ItemGroup>
<ProjectReference Include="..\Aevatar.Core\Aevatar.Core.csproj" />
<ProjectReference Include="..\Aevatar.EventSourcing.Core\Aevatar.EventSourcing.Core.csproj" />
<ProjectReference Include="..\Aevatar.Agent.Abstractions\Aevatar.Agent.Abstractions.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/Aevatar.Plugins/GAgents/PluginCodeStorageGAgent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Aevatar.Core;
using Aevatar.Core.Abstractions;
using Aevatar.Agent.Abstractions;

namespace Aevatar.Plugins.GAgents;

Expand Down Expand Up @@ -36,7 +37,7 @@ public override Task<string> GetDescriptionAsync()
}

protected override void GAgentTransitionState(PluginCodeStorageGAgentState state,
StateLogEventBase<PluginCodeStorageStateLogEvent> @event)
IGAgentEventBase<PluginCodeStorageStateLogEvent> @event)
{
switch (@event)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Aevatar.Plugins/GAgents/TenantPluginCodeGAgent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Aevatar.Core;
using Aevatar.Core.Abstractions;
using Aevatar.Agent.Abstractions;

namespace Aevatar.Plugins.GAgents;

Expand Down Expand Up @@ -32,7 +33,7 @@ public override Task<string> GetDescriptionAsync()
}

protected override void GAgentTransitionState(TenantPluginCodeGAgentState state,
StateLogEventBase<TenantPluginStateLogEvent> @event)
IGAgentEventBase<TenantPluginStateLogEvent> @event)
{
switch (@event)
{
Expand Down
Loading