mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-11 10:38:32 -05:00
Update connection logic to handle multiple connections per URI (#176)
* Add CancelTokenKey for uniquely identifying cancelations of Connections associated with an OwnerUri and ConnectionType string. * Update ConnectionInfo to use ConcurrentDictionary of DbConnection instances. Add wrapper functions for the ConcurrentDictionary. * Refactor Connect and Disconnect in ConnectionService. * Update ConnectionService: Handle multiple connections per ConnectionInfo. Handle cancelation tokens uniquely identified with CancelTokenKey. Add GetOrOpenConnection() for other services to request an existing or create a new DbConnection. * Add ConnectionType.cs for ConnectionType strings. * Add ConnectionType string to ConnectParams, ConnectionCompleteNotification, DisconnectParams. * Update Query ExecuteInternal to use the dedicated query connection and GetOrOpenConnection(). * Update test library to account for multiple connections in ConnectionInfo. * Write tests ensuring multiple connections don’t create redundant data. * Write tests ensuring database changes affect all connections of a given ConnectionInfo. * Write tests for TRANSACTION statements and temp tables.
This commit is contained in:
@@ -14,6 +14,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
||||
/// A URI identifying the owner of the connection. This will most commonly be a file in the workspace
|
||||
/// or a virtual file representing an object in a database.
|
||||
/// </summary>
|
||||
public string OwnerUri { get; set; }
|
||||
public string OwnerUri { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of connection we are trying to cancel
|
||||
/// </summary>
|
||||
public string Type { get; set; } = ConnectionType.Default;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,5 +22,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
||||
/// connection properties to the same database.
|
||||
/// </summary>
|
||||
public ConnectionDetails Connection { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of this connection. By default, this is set to ConnectionType.Default.
|
||||
/// </summary>
|
||||
public string Type { get; set; } = ConnectionType.Default;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
||||
/// Gets or sets the actual Connection established, including Database Name
|
||||
/// </summary>
|
||||
public ConnectionSummary ConnectionSummary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of connection that this notification is for
|
||||
/// </summary>
|
||||
public string Type { get; set; } = ConnectionType.Default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -15,5 +15,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
||||
/// or a virtual file representing an object in a database.
|
||||
/// </summary>
|
||||
public string OwnerUri { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of connection we are disconnecting. If null, we will disconnect all connections.
|
||||
/// connections.
|
||||
/// </summary>
|
||||
public string Type { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user