update franz version

This commit is contained in:
Adam R Grey 2022-12-13 16:31:50 -05:00
parent ca2286126e
commit 71f4e3106e
2 changed files with 9 additions and 10 deletions

View File

@ -1,6 +1,5 @@
using franz; using franz;
using Newtonsoft.Json; using Newtonsoft.Json;
using silver_messages.directorial;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
@ -24,7 +23,7 @@ namespace directors_assistant
Telefranz.Configure(name: conf.name, bootstrap_servers: conf.bootstrap_servers, Telefranz.Configure(name: conf.name, bootstrap_servers: conf.bootstrap_servers,
commands: conf.commands.Select(c => c.name).ToList()); commands: conf.commands.Select(c => c.name).ToList());
telefranz = Telefranz.Instance; telefranz = Telefranz.Instance;
telefranz.addHandler((silver_messages.directorial.execute_command ec) => telefranz.addHandler((gray_messages.directorial.execute_command ec) =>
{ {
var matchedCommands = conf.commands.Where(c => c.name == ec.command)?.ToList(); var matchedCommands = conf.commands.Where(c => c.name == ec.command)?.ToList();
//I swear I have a vague memory of foreach in linq'd query throwing an exception when results empty. //I swear I have a vague memory of foreach in linq'd query throwing an exception when results empty.
@ -57,7 +56,7 @@ namespace directors_assistant
} }
}); });
await Task.Delay(1000); await Task.Delay(1000);
telefranz.ProduceMessage(new silver_messages.global.sound_off()); telefranz.ProduceMessage(new gray_messages.global.sound_off());
await Task.Delay(-1); await Task.Delay(-1);
} }
@ -93,7 +92,7 @@ namespace directors_assistant
{ {
stopwatch.Stop(); stopwatch.Stop();
Console.WriteLine($"{commandName} completed"); Console.WriteLine($"{commandName} completed");
telefranz.ProduceMessage(new silver_messages.directorial.command_completed() telefranz.ProduceMessage(new gray_messages.directorial.command_completed()
{ {
command = commandName, command = commandName,
runtimeMilliseconds = stopwatch.ElapsedMilliseconds, runtimeMilliseconds = stopwatch.ElapsedMilliseconds,
@ -106,7 +105,7 @@ namespace directors_assistant
{ {
process.Kill(); process.Kill();
Console.WriteLine($"{commandName} expired"); Console.WriteLine($"{commandName} expired");
telefranz.ProduceMessage(new silver_messages.directorial.command_expired() telefranz.ProduceMessage(new gray_messages.directorial.command_expired()
{ {
command = commandName, command = commandName,
stdout = string.Join('\n', outputs), stdout = string.Join('\n', outputs),
@ -126,7 +125,7 @@ namespace directors_assistant
{ {
return; return;
} }
telefranz.ProduceMessage(new silver_messages.directorial.command_output() telefranz.ProduceMessage(new gray_messages.directorial.command_output()
{ {
stdout = e.Data, stdout = e.Data,
command = commandName, command = commandName,
@ -140,7 +139,7 @@ namespace directors_assistant
return; return;
} }
Console.Error.WriteLine($"{commandName} err (but not necessarily dead?): {e.Data}"); Console.Error.WriteLine($"{commandName} err (but not necessarily dead?): {e.Data}");
telefranz.ProduceMessage(new silver_messages.directorial.command_error() telefranz.ProduceMessage(new gray_messages.directorial.command_error()
{ {
stderr = e.Data, stderr = e.Data,
command = commandName, command = commandName,
@ -157,7 +156,7 @@ namespace directors_assistant
process.WaitForExit(); process.WaitForExit();
stopwatch.Stop(); stopwatch.Stop();
Console.WriteLine($"{commandName} returned {process.ExitCode} after {stopwatch.ElapsedMilliseconds}ms"); Console.WriteLine($"{commandName} returned {process.ExitCode} after {stopwatch.ElapsedMilliseconds}ms");
telefranz.ProduceMessage(new silver_messages.directorial.command_completed() telefranz.ProduceMessage(new gray_messages.directorial.command_completed()
{ {
command = commandName, command = commandName,
runtimeMilliseconds = stopwatch.ElapsedMilliseconds, runtimeMilliseconds = stopwatch.ElapsedMilliseconds,
@ -167,7 +166,7 @@ namespace directors_assistant
catch(Exception e) catch(Exception e)
{ {
Console.Error.WriteLine($"{commandName} FATAL: {JsonConvert.SerializeObject(e)}"); Console.Error.WriteLine($"{commandName} FATAL: {JsonConvert.SerializeObject(e)}");
telefranz.ProduceMessage(new silver_messages.directorial.command_error() telefranz.ProduceMessage(new gray_messages.directorial.command_error()
{ {
stderr = e.Message, stderr = e.Message,
command = commandName, command = commandName,

View File

@ -12,7 +12,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="greyn.franz" Version="1.0.0" /> <PackageReference Include="greyn.franz" Version="2.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>