commands update

This commit is contained in:
Adam R. Grey 2021-07-23 02:08:34 -04:00
parent a6d0ce16a1
commit a99d5a9086
8 changed files with 88 additions and 31 deletions

1
.gitignore vendored
View File

@ -373,3 +373,4 @@ FodyWeavers.xsd
# Local History for Visual Studio Code
.history/
franz/nugify.sh

26
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/franz.tests/bin/Debug/net5.0/franz.tests.dll",
"args": [],
"cwd": "${workspaceFolder}/franz.tests",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}

42
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,42 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/franz.tests/franz.tests.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/franz.tests/franz.tests.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/franz.tests/franz.tests.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}

View File

@ -80,26 +80,25 @@ namespace franz
public void addHandler<T>(Action<T> theAction) where T : silver_messages.message
{
Console.WriteLine($"typeof(T) reports as {typeof(T)}.");
var topic = typeof(T).ToString();
Action<KafkaRecord<string, string>> wrapped = (kr) =>
{
Console.WriteLine($"wrapped receives kafkarecord, is ready to process: {kr.Value}");
var deserialized = JsonConvert.DeserializeObject<T>(kr.Value);
if(deserialized != null && deserialized.type == deserialized.GetType().ToString())
{
Console.WriteLine("message deserialized for this handler");
theAction(deserialized);
Console.WriteLine("action survived");
}
else
{
Console.WriteLine("message didn't deserialize for this handler");
try
{
theAction(deserialized);
}
catch(Exception e)
{
consoleLogger.LogError("if I don't catch this error the whole thing dies so...");
consoleLogger.LogError(JsonConvert.SerializeObject(e));
}
}
};
if(!topicConsumers.ContainsKey(typeof(T).ToString())){
Console.WriteLine($"making consumer for {handling_group}, topic {topic}");
topicConsumers[topic] = new KafkaConsumer<string, string>(topic, clusterClient);
topicConsumers[topic].ConsumeFromLatest();
topicSubscribers.Add(topic, 0);
@ -121,8 +120,8 @@ namespace franz
public void ProduceMessage<T>(T message) where T : silver_messages.message
{
Console.WriteLine($"producing message {message}");
clusterClient.Produce(typeof(T).ToString(), message.ToString());
}
public void HiImAFunction(){}
}
}

View File

@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<PackageId>silvermeddlists.franz</PackageId>
<Version>0.0.1</Version>
<Version>0.0.2</Version>
<Authors>adam</Authors>
<Company>Silver Meddlists</Company>
</PropertyGroup>

View File

@ -4,15 +4,18 @@ using silver_messages;
namespace silver_messages.directorial
{
public class command_completed : silver_messages.message
public abstract class command_ended : silver_messages.message
{
//name of the command that was called
public string command { get; set; }
//runtime in ms
public uint runtime { get; set; }
public string stdout { get; set; }
public string stderr { get; set; }
public int exit_code { get; set; }
}
}
public class command_completed : command_ended
{
public int exit_code { get; set; }
public long runtimeMilliseconds { get; set; }
}
public class command_expired : command_ended {}
}

View File

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using silver_messages;
namespace silver_messages.directorial
{
public class command_expired : silver_messages.message
{
//name of the command that was called
public string command { get; set; }
//runtime in ms
public uint runtime { get; set; }
}
}

View File

@ -19,4 +19,3 @@ namespace silver_messages.directorial
public int timeout { get; set; }
}
}