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

Commit d3bc8e3

Browse files
committed
Minor event alterations
- Moved to 0.1.6.3
1 parent e1a3813 commit d3bc8e3

File tree

4 files changed

+28
-20
lines changed

4 files changed

+28
-20
lines changed

samples/Example.General/Program.cs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,37 +50,43 @@ public Test001(Guid uuid) {
5050
}
5151
}
5252

53+
class EventObserver : IObserver<Event>
54+
{
55+
public void OnCompleted() {
56+
}
57+
58+
public void OnError(Exception error) {
59+
}
60+
61+
public void OnNext(Event value) {
62+
63+
}
64+
}
65+
5366
class Program
5467
{
5568
public static Node TestNode { get; set; }
5669

5770
static void Main(string[] args) => AsyncMain(args).Wait();
58-
59-
class EventTest
60-
{
61-
public string Potato { get; set; }
62-
}
71+
6372

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

70-
TestNode.TraceBegin += (o, e) => Console.WriteLine($"Begin trace {e.TraceId} for {e.Envelope.ID} at {DateTime.UtcNow}");
71-
TestNode.TraceEnd += (o, e) => Console.WriteLine($"End trace {e.TraceId} for {e.Envelope.ID} at {DateTime.UtcNow}");
72-
7379
// attach
74-
await TestNode.AttachAsync("auth:login", RpcBehaviour.Bind<ITest001>(new Test001(Guid.NewGuid())));
80+
//await TestNode.AttachAsync("auth:login", RpcBehaviour.Bind<ITest001>(new Test001(Guid.NewGuid())));
81+
82+
// subscribe
83+
(await TestNode.SubscribeAsync("auth:login.happened"))
84+
.AsObservable().Subscribe(new EventObserver());
7585

76-
ITest001 proxy = TestNode.Proxy<ITest001>("auth:login", new ProxyConfiguration() {
77-
TraceId = Guid.NewGuid().ToString()
78-
});
79-
80-
await proxy.Login(new LoginRequestMsg() {
86+
await TestNode.EmitAsync("auth:login.happened", new LoginRequestMsg() {
8187
Password = "password",
8288
Username = "username"
83-
});
89+
}).ConfigureAwait(false);
8490

8591
await Task.Delay(50000);
8692
}

src/Holon/Events/Event.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ internal Event(string id, string @namespace, string resource, string name, byte[
165165
_namespace = @namespace;
166166
_name = name;
167167
_data = data;
168+
_timestamp = DateTime.UtcNow;
168169
}
169170
#endregion
170171
}

src/Holon/Events/Serializers/ProtobufEventSerializer.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public Event DeserializeEvent(byte[] body) {
3131
using (MemoryStream ms = new MemoryStream(body)) {
3232
EventMsg msg = Serializer.Deserialize<EventMsg>(ms);
3333

34-
return new Event(msg.ID, msg.Namespace, msg.Resource, msg.Name, msg.Data);
34+
return new Event(msg.ID, msg.Namespace, msg.Resource, msg.Name, msg.Data);
3535
}
3636
}
3737

@@ -42,7 +42,8 @@ public byte[] SerializeEvent(Event e) {
4242
eventMsg.Type = "serialized";
4343
eventMsg.Data = e.Data;
4444
eventMsg.Resource = e.Resource;
45-
eventMsg.Namespace = e.Name;
45+
eventMsg.Namespace = e.Namespace;
46+
eventMsg.ID = e.ID;
4647
Serializer.Serialize(ms, eventMsg);
4748
return ms.ToArray();
4849
}

src/Holon/Holon.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
<PropertyGroup>
44
<TargetFramework>netstandard1.6</TargetFramework>
5-
<Version>0.1.6.2</Version>
5+
<Version>0.1.6.3</Version>
66
<Authors>Alan Doherty</Authors>
77
<Company>Alan Doherty</Company>
88
<Description>A minimal service and event bus with additional support for RPC</Description>
99
<Copyright>BattleCrate Ltd 2018</Copyright>
1010
<PackageProjectUrl>https://github.com/alandoherty/holon-net</PackageProjectUrl>
1111
<RepositoryUrl>https://github.com/alandoherty/holon-net</RepositoryUrl>
1212
<RepositoryType>git</RepositoryType>
13-
<AssemblyVersion>0.1.6.2</AssemblyVersion>
13+
<AssemblyVersion>0.1.6.3</AssemblyVersion>
1414
<PackageLicenseUrl>https://github.com/alandoherty/holon-net/blob/master/LICENSE</PackageLicenseUrl>
1515
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1616
<PackageIconUrl>https://s3-eu-west-1.amazonaws.com/assets.alandoherty.co.uk/github/holon-net-nuget.png</PackageIconUrl>
17-
<FileVersion>0.1.6.2</FileVersion>
17+
<FileVersion>0.1.6.3</FileVersion>
1818
</PropertyGroup>
1919

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

0 commit comments

Comments
 (0)