Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
Minor event fix
Browse files Browse the repository at this point in the history
- Moved to 0.1.5
  • Loading branch information
alandoherty committed Nov 26, 2018
1 parent 55558f9 commit 6450c3c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 55 deletions.
60 changes: 9 additions & 51 deletions samples/Example.General/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,6 @@ class Program

static void Main(string[] args) => AsyncMain(args).Wait();

public static async void ReadLoop(int[] ctr, Node node, Guid[] uuids) {
Random rand = new Random();

while (true) {
try {
int i = rand.Next(0, uuids.Length);
Guid uuid = uuids[i];
ITest001 proxy = node.Proxy<ITest001>($"auth:{uuid}");

string s = await proxy.Login(new LoginRequestMsg() {
Password = "wow",
Username = "alan"
}).ConfigureAwait(false);

Interlocked.Increment(ref ctr[0]);

//Console.WriteLine($"String: {s}");
} catch(Exception ex) {
Console.WriteLine(ex.ToString());
}
}
}

class EventTest
{
public string Potato { get; set; }
Expand All @@ -102,37 +79,18 @@ static async Task AsyncMain(string[] args) {
ThrowUnhandledExceptions = true
});

// attach services
Guid[] uuids = new Guid[500];
List<Task> tasks = new List<Task>();

Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();

for (int i = 0; i < uuids.Length; i++) {
uuids[i] = Guid.NewGuid();
// subscribe
Guid g = Guid.NewGuid();
EventSubscription subscription = await TestNode.SubscribeAsync($"device:{g}.*");

tasks.Add(TestNode.AttachAsync($"auth:{uuids[i]}", RpcBehaviour.Bind<ITest001>(new Test001(uuids[i]))));
}

await Task.WhenAll(tasks).ConfigureAwait(false);

Console.WriteLine($"Attached {uuids.Length} services in {stopwatch.ElapsedMilliseconds}ms");

int[] ctr = new int[] { 0 };
int pavg = 0;

for (int i = 0; i < 32; i++)
ReadLoop(ctr, TestNode, uuids);
subscription.AsObservable().Subscribe(new EventObserver());

while(true) {
Console.WriteLine($"Logging in at {ctr[0]}/s avg ({pavg}/s), ({Process.GetCurrentProcess().Threads.Count} threads)");

pavg += ctr[0];
pavg = pavg / 2;
ctr[0] = 0;

await Task.Delay(1000).ConfigureAwait(false);
while (true) {
await TestNode.EmitAsync($"device:{g}.test", new EventTest() {
Potato = "wow"
});
await Task.Delay(500);
}

await Task.Delay(50000);
Expand Down
6 changes: 3 additions & 3 deletions src/Holon/Holon.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

<PropertyGroup>
<TargetFramework>netstandard1.6</TargetFramework>
<Version>0.1.4.1</Version>
<Version>0.1.5</Version>
<Authors>Alan Doherty</Authors>
<Company>Alan Doherty</Company>
<Description>A minimal service and event bus with additional support for RPC</Description>
<Copyright>BattleCrate Ltd 2018</Copyright>
<PackageProjectUrl>https://github.com/alandoherty/holon-net</PackageProjectUrl>
<RepositoryUrl>https://github.com/alandoherty/holon-net</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<AssemblyVersion>0.1.4.1</AssemblyVersion>
<AssemblyVersion>0.1.5.0</AssemblyVersion>
<PackageLicenseUrl>https://github.com/alandoherty/holon-net/blob/master/LICENSE</PackageLicenseUrl>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageIconUrl>https://s3-eu-west-1.amazonaws.com/assets.alandoherty.co.uk/github/holon-net-nuget.png</PackageIconUrl>
<FileVersion>0.1.4.1</FileVersion>
<FileVersion>0.1.5.0</FileVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
2 changes: 1 addition & 1 deletion src/Holon/Namespace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ public async Task EmitAsync(EventAddress addr, object data) {

// send event
try {
await _broker.SendAsync(string.Format("!{0}", addr.Namespace), addr.Name, body, new Dictionary<string, object>() {
await _broker.SendAsync(string.Format("!{0}", addr.Namespace), $"{addr.Resource}.{addr.Name}", body, new Dictionary<string, object>() {
{ EventHeader.HEADER_NAME, new EventHeader(EventHeader.HEADER_VERSION, serializer.Name).ToString() }
}, null, null, false).ConfigureAwait(false);
} catch (Exception) { }
Expand Down

0 comments on commit 6450c3c

Please sign in to comment.