From 32c06e32f7ad13a3fe24872eae81718f9b3d9d51 Mon Sep 17 00:00:00 2001 From: qinyouzeng Date: Fri, 20 Dec 2024 13:09:31 +0800 Subject: [PATCH] update --- .../ShellCommandModel.cs | 19 ++++++++----------- .../_Imports.cs | 4 ++++ 2 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 src/Shells/Masa.Scheduler.Shells.JobShell.Shared/_Imports.cs diff --git a/src/Shells/Masa.Scheduler.Shells.JobShell.Shared/ShellCommandModel.cs b/src/Shells/Masa.Scheduler.Shells.JobShell.Shared/ShellCommandModel.cs index 7f90d41..ffe7cc1 100644 --- a/src/Shells/Masa.Scheduler.Shells.JobShell.Shared/ShellCommandModel.cs +++ b/src/Shells/Masa.Scheduler.Shells.JobShell.Shared/ShellCommandModel.cs @@ -1,15 +1,15 @@ // Copyright (c) MASA Stack All rights reserved. // Licensed under the Apache License. See LICENSE.txt in the project root for license information. -using System.Text; - namespace Masa.Scheduler.Shells.JobShell.Shared; public struct ShellCommandModel { static string emptyTraceId = Guid.Empty.ToString("N"); - public ShellCommandModel(string basePath, Guid taskId, string jobAssemblyPath, string jobEntryClassName, string? traceId, string? parentSpanId, long uTCTicks, long offset, Guid jobId, string otelUrl = "http://localhost:4317", string? jobStartParam = default) + internal const string DEFAULT_OTEL_URL = "http://localhost:4317"; + + public ShellCommandModel(string basePath, Guid taskId, string jobAssemblyPath, string jobEntryClassName, string? traceId, string? parentSpanId, long uTCTicks, long offset, Guid jobId, string? otelUrl = default, string? jobStartParam = default) { if (string.IsNullOrEmpty(jobAssemblyPath)) throw new ArgumentNullException(nameof(jobAssemblyPath)); @@ -24,7 +24,7 @@ public ShellCommandModel(string basePath, Guid taskId, string jobAssemblyPath, s UTCTicks = uTCTicks; Offset = offset; JobId = jobId; - OtelUrl = otelUrl; + OtelUrl = string.IsNullOrEmpty(otelUrl) ? DEFAULT_OTEL_URL : otelUrl; JobStartParam = jobStartParam; } @@ -42,9 +42,6 @@ public ShellCommandModel(string basePath, Guid taskId, string jobAssemblyPath, s public long UTCTicks { get; } - /// - /// 时区偏移量,单位s - /// public long Offset { get; } public Guid JobId { get; } @@ -65,7 +62,7 @@ public override string ToString() UTCTicks, Offset, JobId, - string.IsNullOrEmpty(OtelUrl) ? "http://localhost:4317" : OtelUrl, + OtelUrl, string.IsNullOrEmpty(JobStartParam) ? "" : Convert.ToBase64String(Encoding.UTF8.GetBytes(JobStartParam)) ); } @@ -86,9 +83,9 @@ public static class ShellCommandModelExtension throw new ArgumentException($"arg length less than {paramCount}"); _ = Guid.TryParse(args[start++], out var taskId); string path = args[start++], className = args[start++], traceId = args[start++], spanId = args[start++]; - long ticks = Convert.ToInt64(args[start++]); - long offset = Convert.ToInt64(args[start++]); - _ = Guid.TryParse(args[start++], out Guid jobId); + var ticks = Convert.ToInt64(args[start++]); + var offset = Convert.ToInt64(args[start++]); + _ = Guid.TryParse(args[start++], out var jobId); string otelUrl = args[start++], jobParam = args.Length - paramCount > 0 ? Encoding.UTF8.GetString(Convert.FromBase64String(args[start])) : default!; return new ShellCommandModel(hasFirst ? args[0] : default!, taskId, path, className, traceId, spanId, ticks, offset, jobId, otelUrl, jobParam); diff --git a/src/Shells/Masa.Scheduler.Shells.JobShell.Shared/_Imports.cs b/src/Shells/Masa.Scheduler.Shells.JobShell.Shared/_Imports.cs new file mode 100644 index 0000000..1319587 --- /dev/null +++ b/src/Shells/Masa.Scheduler.Shells.JobShell.Shared/_Imports.cs @@ -0,0 +1,4 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the Apache License. See LICENSE.txt in the project root for license information. + +global using System.Text;