Skip to content

Commit

Permalink
Fix for GetJobAsync deserialization issue (#1461)
Browse files Browse the repository at this point in the history
Bugfix: `GetJobAsync` deserialization failure

Updated GetJobsAsync deserialization to reflect actual values returned

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
  • Loading branch information
WhitWaldo authored Feb 19, 2025
1 parent 89d9d56 commit e9ee4d2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions examples/Jobs/JobsSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Dapr.Jobs.Models;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDaprJobsClient();
builder.Logging.ClearProviders();
builder.Logging.AddConsole();

Expand Down
12 changes: 8 additions & 4 deletions src/Dapr.Jobs/DaprJobsGrpcClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,15 @@ public override async Task<DaprJobDetails> GetJobAsync(string jobName, Cancellat
var envelope = new Autogenerated.GetJobRequest { Name = jobName };
var grpcCallOptions = DaprClientUtilities.ConfigureGrpcCallOptions(typeof(DaprJobsClient).Assembly, this.DaprApiToken, cancellationToken);
var response = await Client.GetJobAlpha1Async(envelope, grpcCallOptions);
return new DaprJobDetails(new DaprJobSchedule(response.Job.Schedule))
var schedule = DateTime.TryParse(response.Job.DueTime, out var dueTime)
? DaprJobSchedule.FromDateTime(dueTime)
: new DaprJobSchedule(response.Job.Schedule);

return new DaprJobDetails(schedule)
{
DueTime = response.Job.DueTime is not null ? DateTime.Parse(response.Job.DueTime) : null,
Ttl = response.Job.Ttl is not null ? DateTime.Parse(response.Job.Ttl) : null,
RepeatCount = response.Job.Repeats == default ? null : (int?)response.Job.Repeats,
DueTime = !string.IsNullOrWhiteSpace(response.Job.DueTime) ? DateTime.Parse(response.Job.DueTime) : null,
Ttl = !string.IsNullOrWhiteSpace(response.Job.Ttl) ? DateTime.Parse(response.Job.Ttl) : null,
RepeatCount = (int?)response.Job.Repeats,
Payload = response.Job.Data.ToByteArray()
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/Dapr.Jobs/Models/DaprJobSchedule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static DaprJobSchedule FromDuration(TimeSpan duration)
/// <summary>
/// Specifies a schedule in which the job is triggered weekly.
/// </summary>
public static DaprJobSchedule Weekly { get; } =new DaprJobSchedule("@weekly");
public static DaprJobSchedule Weekly { get; } = new DaprJobSchedule("@weekly");

/// <summary>
/// Specifies a schedule in which the job is triggered daily.
Expand Down

0 comments on commit e9ee4d2

Please sign in to comment.