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

Commit

Permalink
Minor event alterations
Browse files Browse the repository at this point in the history
- Moved to 0.1.6.3
  • Loading branch information
alandoherty committed Dec 10, 2018
1 parent e1a3813 commit d3bc8e3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 20 deletions.
36 changes: 21 additions & 15 deletions samples/Example.General/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,37 +50,43 @@ public Test001(Guid uuid) {
}
}

class EventObserver : IObserver<Event>
{
public void OnCompleted() {
}

public void OnError(Exception error) {
}

public void OnNext(Event value) {

}
}

class Program
{
public static Node TestNode { get; set; }

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

class EventTest
{
public string Potato { get; set; }
}


static async Task AsyncMain(string[] args) {
// attach node
TestNode = await Node.CreateFromEnvironmentAsync(new NodeConfiguration() {
ThrowUnhandledExceptions = true
});

TestNode.TraceBegin += (o, e) => Console.WriteLine($"Begin trace {e.TraceId} for {e.Envelope.ID} at {DateTime.UtcNow}");
TestNode.TraceEnd += (o, e) => Console.WriteLine($"End trace {e.TraceId} for {e.Envelope.ID} at {DateTime.UtcNow}");

// attach
await TestNode.AttachAsync("auth:login", RpcBehaviour.Bind<ITest001>(new Test001(Guid.NewGuid())));
//await TestNode.AttachAsync("auth:login", RpcBehaviour.Bind<ITest001>(new Test001(Guid.NewGuid())));

// subscribe
(await TestNode.SubscribeAsync("auth:login.happened"))
.AsObservable().Subscribe(new EventObserver());

ITest001 proxy = TestNode.Proxy<ITest001>("auth:login", new ProxyConfiguration() {
TraceId = Guid.NewGuid().ToString()
});

await proxy.Login(new LoginRequestMsg() {
await TestNode.EmitAsync("auth:login.happened", new LoginRequestMsg() {
Password = "password",
Username = "username"
});
}).ConfigureAwait(false);

await Task.Delay(50000);
}
Expand Down
1 change: 1 addition & 0 deletions src/Holon/Events/Event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ internal Event(string id, string @namespace, string resource, string name, byte[
_namespace = @namespace;
_name = name;
_data = data;
_timestamp = DateTime.UtcNow;
}
#endregion
}
Expand Down
5 changes: 3 additions & 2 deletions src/Holon/Events/Serializers/ProtobufEventSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public Event DeserializeEvent(byte[] body) {
using (MemoryStream ms = new MemoryStream(body)) {
EventMsg msg = Serializer.Deserialize<EventMsg>(ms);

return new Event(msg.ID, msg.Namespace, msg.Resource, msg.Name, msg.Data);
return new Event(msg.ID, msg.Namespace, msg.Resource, msg.Name, msg.Data);
}
}

Expand All @@ -42,7 +42,8 @@ public byte[] SerializeEvent(Event e) {
eventMsg.Type = "serialized";
eventMsg.Data = e.Data;
eventMsg.Resource = e.Resource;
eventMsg.Namespace = e.Name;
eventMsg.Namespace = e.Namespace;
eventMsg.ID = e.ID;
Serializer.Serialize(ms, eventMsg);
return ms.ToArray();
}
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.6.2</Version>
<Version>0.1.6.3</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.6.2</AssemblyVersion>
<AssemblyVersion>0.1.6.3</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.6.2</FileVersion>
<FileVersion>0.1.6.3</FileVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down

0 comments on commit d3bc8e3

Please sign in to comment.