Skip to content

Commit

Permalink
feat : SchedulerTaskService add NotifyRunResultAsync (#641)
Browse files Browse the repository at this point in the history
  • Loading branch information
wzh425 committed Jul 5, 2023
1 parent da33bba commit c99a478
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.

namespace Masa.BuildingBlocks.StackSdks.Scheduler.Enum;

public enum TaskRunResultStatus
{
Success = 3,
Failure = 4,
TimeoutSuccess = 6,
Ignore = 9
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.

namespace Masa.BuildingBlocks.StackSdks.Scheduler.Request;

public class NotifySchedulerTaskRunResultRequest: SchedulerTaskRequestBase
{
public TaskRunResultStatus Status { get; set; }

public string? Message { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ public interface ISchedulerTaskService
Task<bool> StopAsync(SchedulerTaskRequestBase request);

Task<bool> StartAsync(SchedulerTaskRequestBase request);

Task NotifyRunResultAsync(NotifySchedulerTaskRunResultRequest request);
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,10 @@ public async Task<bool> StartAsync(SchedulerTaskRequestBase request)
await _caller.PutAsync(requestUri, requestData);
return true;
}

public async Task NotifyRunResultAsync(NotifySchedulerTaskRunResultRequest request)
{
var requestUri = $"{API}/notifyRunResultBySdk";
await _caller.PostAsync(requestUri, request);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,22 @@ public async Task TestStartSchedulerTaskAsync()
caller.Verify(provider => provider.PutAsync(requestUri, It.IsAny<StartSchedulerTaskRequest>(), true, default), Times.Once);
Assert.IsTrue(result);
}

[TestMethod]
public async Task TestNotifyRunResultAsync()
{
var request = new NotifySchedulerTaskRunResultRequest()
{
TaskId = Guid.NewGuid(),
Status = BuildingBlocks.StackSdks.Scheduler.Enum.TaskRunResultStatus.Success,
OperatorId = Guid.NewGuid()
};

var requestUri = $"{API}/notifyRunResultBySdk";
var caller = new Mock<ICaller>();
caller.Setup(provider => provider.PostAsync(requestUri, It.IsAny<NotifySchedulerTaskRunResultRequest>(), true, default)).Verifiable();
var schedulerClient = new SchedulerClient(caller.Object);
await schedulerClient.SchedulerTaskService.NotifyRunResultAsync(request);
caller.Verify(provider => provider.PostAsync(requestUri, It.IsAny<NotifySchedulerTaskRunResultRequest>(), true, default), Times.Once);
}
}

0 comments on commit c99a478

Please sign in to comment.