Initial admin and DR services. (#329)

* Add initial services for admin, tasks, and DR

* Fix up some of the contract interfaces

* Make fields public to allow Json.Net to work

* Fix a couple issues in backup contracts
This commit is contained in:
Karl Burtram
2017-04-26 10:29:15 -07:00
committed by GitHub
parent 009967fee8
commit 1a16101381
15 changed files with 409 additions and 1 deletions

View File

@@ -0,0 +1,31 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.SqlTools.ServiceLayer.TaskServices.Contracts
{
public class ListTasksParams
{
bool ListActiveTasksOnly { get; set; }
}
public class ListTasksResponse
{
TaskInfo[] Tasks { get; set; }
}
public class ListTasksRequest
{
public static readonly
RequestType<ListTasksParams, ListTasksResponse> Type =
RequestType<ListTasksParams, ListTasksResponse>.Create("tasks/listtasks");
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.SqlTools.ServiceLayer.TaskServices.Contracts
{
public enum TaskState
{
NotStarted = 0,
Running = 1,
Complete = 2
}
public class TaskInfo
{
public int TaskId { get; set; }
public TaskState State { get; set; }
}
}

View File

@@ -0,0 +1,52 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using Microsoft.SqlTools.Hosting.Protocol;
using Microsoft.SqlTools.ServiceLayer.Hosting;
using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Microsoft.SqlTools.ServiceLayer.TaskServices.Contracts;
using System;
using System.Threading.Tasks;
namespace Microsoft.SqlTools.ServiceLayer.TaskServices
{
public class TaskService
{
private static readonly Lazy<TaskService> instance = new Lazy<TaskService>(() => new TaskService());
/// <summary>
/// Default, parameterless constructor.
/// </summary>
internal TaskService()
{
}
/// <summary>
/// Gets the singleton instance object
/// </summary>
public static TaskService Instance
{
get { return instance.Value; }
}
/// <summary>
/// Initializes the service instance
/// </summary>
public void InitializeService(ServiceHost serviceHost, SqlToolsContext context)
{
serviceHost.SetRequestHandler(ListTasksRequest.Type, HandleListTasksRequest);
}
/// <summary>
/// Handles a list tasks request
/// </summary>
internal static async Task HandleListTasksRequest(
ListTasksParams listTasksParams,
RequestContext<ListTasksResponse> requestContext)
{
await requestContext.SendResult(new ListTasksResponse());
}
}
}