/* Copyright 2017-present MongoDB Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Threading;
using System.Threading.Tasks;
using MongoDB.Bson;
using MongoDB.Driver.Core.Bindings;
namespace MongoDB.Driver
{
///
/// The interface for a client session.
///
public interface IClientSession : IDisposable
{
// properties
///
/// Gets the client.
///
///
/// The client.
///
IMongoClient Client { get; }
///
/// Gets the cluster time.
///
///
/// The cluster time.
///
BsonDocument ClusterTime { get; }
///
/// Gets a value indicating whether this session is an implicit session.
///
///
/// true if this session is an implicit session; otherwise, false.
///
bool IsImplicit { get; }
///
/// Gets a value indicating whether this instance is in a transaction.
///
///
/// true if this instance is in a transaction; otherwise, false.
///
bool IsInTransaction { get; }
///
/// Gets the operation time.
///
///
/// The operation time.
///
BsonTimestamp OperationTime { get; }
///
/// Gets the options.
///
///
/// The options.
///
ClientSessionOptions Options { get; }
///
/// Gets the server session.
///
///
/// The server session.
///
IServerSession ServerSession { get; }
///
/// Gets the wrapped core session (intended for internal use only).
///
///
/// The wrapped core session.
///
ICoreSessionHandle WrappedCoreSession { get; }
// methods
///
/// Aborts the transaction.
///
/// The cancellation token.
void AbortTransaction(CancellationToken cancellationToken = default(CancellationToken));
///
/// Aborts the transaction.
///
/// The cancellation token.
/// A Task.
Task AbortTransactionAsync(CancellationToken cancellationToken = default(CancellationToken));
///
/// Advances the cluster time.
///
/// The new cluster time.
void AdvanceClusterTime(BsonDocument newClusterTime);
///
/// Advances the operation time.
///
/// The new operation time.
void AdvanceOperationTime(BsonTimestamp newOperationTime);
///
/// Commits the transaction.
///
/// The cancellation token.
void CommitTransaction(CancellationToken cancellationToken = default(CancellationToken));
///
/// Commits the transaction.
///
/// The cancellation token.
/// A Task.
Task CommitTransactionAsync(CancellationToken cancellationToken = default(CancellationToken));
///
/// Starts a transaction.
///
/// The transaction options.
void StartTransaction(TransactionOptions transactionOptions = null);
}
///
/// A handle to an underlying reference counted IClientSession.
///
///
public interface IClientSessionHandle : IClientSession
{
///
/// Forks this instance.
///
/// A session.
IClientSessionHandle Fork();
}
}