mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-16 17:23:38 -05:00
* Fix https://github.com/Microsoft/vscode-mssql/issues/986 and add better server edition naming - Fixed a number of issues related to the binding queue, specifically the fact that it didn't capture exceptions that occurred on the binding thread. This caused the thread to crash the service. - The root cause of the error was when you get a connection error during init of the SmoMetadataProvider which threw an exception. Because of this no Binder was created, and the code would null ref later during processing - Added logic to handle null ref issue and other related code - Added a unit test for the new error handling path, and supported still returning some value in this case - Separately, have a fix for an issue where the edition is shown as "SQL Azure" for all Azure connections. Fixing to be "Azure SQL DB" for this case and handle when the database reports as DW or Stretch instead. This maps better to users concept of what the edition should be and avoids returning what is an outdated term. * Messed up the test - fixing this by returning the expected return object
78 lines
2.5 KiB
C#
78 lines
2.5 KiB
C#
//
|
|
// Copyright (c) Microsoft. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
//
|
|
|
|
using System;
|
|
using System.Threading;
|
|
|
|
namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
|
{
|
|
/// <summary>
|
|
/// Class that stores the state of a binding queue request item
|
|
/// </summary>
|
|
public class QueueItem
|
|
{
|
|
/// <summary>
|
|
/// QueueItem constructor
|
|
/// </summary>
|
|
public QueueItem()
|
|
{
|
|
this.ItemProcessed = new ManualResetEvent(initialState: false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the queue item key
|
|
/// </summary>
|
|
public string Key { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the bind operation callback method
|
|
/// </summary>
|
|
public Func<IBindingContext, CancellationToken, object> BindOperation { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the timeout operation to call if the bind operation doesn't finish within timeout period
|
|
/// </summary>
|
|
public Func<IBindingContext, object> TimeoutOperation { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the operation to call if the bind operation encounters an unexpected exception.
|
|
/// Supports returning an object in case of the exception occurring since in some cases we need to be
|
|
/// tolerant of error cases and still return some value
|
|
/// </summary>
|
|
public Func<Exception, object> ErrorHandler { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets an event to signal when this queue item has been processed
|
|
/// </summary>
|
|
public virtual ManualResetEvent ItemProcessed { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the result of the queued task
|
|
/// </summary>
|
|
public object Result { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the binding operation timeout in milliseconds
|
|
/// </summary>
|
|
public int? BindingTimeout { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the timeout for how long to wait for the binding lock
|
|
/// </summary>
|
|
public int? WaitForLockTimeout { get; set; }
|
|
|
|
/// <summary>
|
|
/// Converts the result of the execution to type T
|
|
/// </summary>
|
|
public T GetResultAsT<T>() where T : class
|
|
{
|
|
//var task = this.ResultsTask;
|
|
return (this.Result != null)
|
|
? this.Result as T
|
|
: null;
|
|
}
|
|
}
|
|
}
|