enable dotnet build in PR check and Add namespace back in .proto (#384)

* enable dotnet build for PR check

* add namespace back

---------

Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
This commit is contained in:
Xiaoyun Zhang 2024-08-21 10:58:04 -07:00 committed by GitHub
parent 63000e5424
commit 09ceef4b4a
4 changed files with 19 additions and 12 deletions

View File

@ -2,6 +2,12 @@ name: '[AGNext nuget] Build and test'
on: on:
workflow_call: workflow_call:
push:
branches:
- main
pull_request:
branches:
- main
jobs: jobs:
build: build:

View File

@ -80,12 +80,12 @@ public abstract class AgentBase
{ {
case Message.MessageOneofCase.Event: case Message.MessageOneofCase.Event:
{ {
var activity = ExtractActivity(msg.Event.Type, msg.Event.Metadata); var activity = ExtractActivity(msg.Event.DataType, msg.Event.Metadata);
await InvokeWithActivityAsync( await InvokeWithActivityAsync(
static ((AgentBase Agent, Event Item) state) => state.Agent.HandleEvent(state.Item), static ((AgentBase Agent, Event Item) state) => state.Agent.HandleEvent(state.Item),
(this, msg.Event), (this, msg.Event),
activity, activity,
msg.Event.Type).ConfigureAwait(false); msg.Event.DataType).ConfigureAwait(false);
} }
break; break;
case Message.MessageOneofCase.Request: case Message.MessageOneofCase.Request:
@ -175,8 +175,8 @@ public abstract class AgentBase
protected async ValueTask PublishEvent(Event item) protected async ValueTask PublishEvent(Event item)
{ {
var activity = s_source.StartActivity($"PublishEvent '{item.Type}'", ActivityKind.Client, Activity.Current?.Context ?? default); var activity = s_source.StartActivity($"PublishEvent '{item.DataType}'", ActivityKind.Client, Activity.Current?.Context ?? default);
activity?.SetTag("peer.service", $"{item.Type}/{item.Namespace}"); activity?.SetTag("peer.service", $"{item.DataType}/{item.Namespace}");
var completion = new TaskCompletionSource<RpcResponse>(TaskCreationOptions.RunContinuationsAsynchronously); var completion = new TaskCompletionSource<RpcResponse>(TaskCreationOptions.RunContinuationsAsynchronously);
Context.DistributedContextPropagator.Inject(activity, item.Metadata, static (carrier, key, value) => ((IDictionary<string, string>)carrier!)[key] = value); Context.DistributedContextPropagator.Inject(activity, item.Metadata, static (carrier, key, value) => ((IDictionary<string, string>)carrier!)[key] = value);
@ -187,7 +187,7 @@ public abstract class AgentBase
}, },
(this, item, completion), (this, item, completion),
activity, activity,
item.Type).ConfigureAwait(false); item.DataType).ConfigureAwait(false);
} }
protected virtual Task<RpcResponse> HandleRequest(RpcRequest request) => Task.FromResult(new RpcResponse { Error = "Not implemented" }); protected virtual Task<RpcResponse> HandleRequest(RpcRequest request) => Task.FromResult(new RpcResponse { Error = "Not implemented" });

View File

@ -11,7 +11,7 @@ public static class RpcEventExtensions
var result = new RpcEvent var result = new RpcEvent
{ {
Namespace = input.Namespace, Namespace = input.Namespace,
Type = input.Type, DataType = input.Type,
}; };
if (input.Data is not null) if (input.Data is not null)
@ -26,7 +26,7 @@ public static class RpcEventExtensions
{ {
var result = new Event var result = new Event
{ {
Type = input.Type, Type = input.DataType,
Subject = input.Namespace, Subject = input.Namespace,
Namespace = input.Namespace, Namespace = input.Namespace,
Data = [] Data = []

View File

@ -24,11 +24,12 @@ message RpcResponse {
} }
message Event { message Event {
string topic_type = 1; string namespace = 1;
string topic_source = 2; string topic_type = 2;
string data_type = 3; string topic_source = 3;
string data = 4; string data_type = 4;
map<string, string> metadata = 5; string data = 5;
map<string, string> metadata = 6;
} }
message RegisterAgentType { message RegisterAgentType {