Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat : SchedulerTaskService add NotifyRunResultAsync #641

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
Loading