Skip to content

Commit

Permalink
Refactored file locations, simplified API to use the DaprJobSchedule …
Browse files Browse the repository at this point in the history
…type with factory methods for creating it and properties for discerning its type.

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
  • Loading branch information
WhitWaldo committed Sep 14, 2024
1 parent b8fd743 commit dddbc34
Show file tree
Hide file tree
Showing 8 changed files with 331 additions and 348 deletions.
11 changes: 6 additions & 5 deletions src/Dapr.Jobs/DaprJobsGrpcClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ internal DaprJobsGrpcClient(
/// </summary>
/// <param name="jobName">The name of the job being scheduled.</param>
/// <param name="schedule">The schedule defining when the job will be triggered.</param>
/// <param name="payload">The main payload of the job.</param>
/// <param name="startingFrom">The optional point-in-time from which the job schedule should start.</param>
/// <param name="repeats">The optional number of times the job should be triggered.</param>
/// <param name="ttl">Represents when the job should expire. If both this and DueTime are set, TTL needs to represent a later point in time.</param>
/// <param name="payload">The main payload of the job.</param>
/// <param name="cancellationToken">Cancellation token.</param>
[Obsolete("The API is currently not stable as it is in the Alpha stage. This attribute will be removed once it is stable.")]
public override async Task ScheduleJobAsync(string jobName, DaprJobSchedule schedule, DateTimeOffset? startingFrom,
int? repeats = null, DateTimeOffset? ttl = null, ReadOnlyMemory<byte>? payload = null,
public override async Task ScheduleJobAsync(string jobName, DaprJobSchedule schedule,
ReadOnlyMemory<byte>? payload = null, DateTimeOffset? startingFrom = null, int? repeats = null,
DateTimeOffset? ttl = null,
CancellationToken cancellationToken = default)
{
ArgumentVerifier.ThrowIfNullOrEmpty(jobName, nameof(jobName));
Expand Down Expand Up @@ -139,8 +140,8 @@ public override async Task<JobDetails> GetJobAsync(string jobName, CancellationT
throw new DaprException(
"Get job operation failed: the Dapr endpoint indicated a failure. See InnerException for details.", ex);
}
return new JobDetails

return new JobDetails(new DaprJobSchedule(response.Job.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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Text;
using System.Text.Json;

namespace Dapr.Jobs.Extensions.Helpers.Deserialization;
namespace Dapr.Jobs.Extensions;

/// <summary>
/// Provides utility extensions for deserializing an array of UTF-8 encoded bytes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Text;
using System.Text.Json;

namespace Dapr.Jobs.Extensions.Helpers.Serialization;
namespace Dapr.Jobs.Extensions;

/// <summary>
/// Provides helper extensions for performing serialization operations when scheduling one-time Cron jobs for the developer.
Expand Down
Loading

0 comments on commit dddbc34

Please sign in to comment.