Summary

Class:CBAM.SQL.PostgreSQL.NotificationEventArgs
Assembly:CBAM.SQL.PostgreSQL
File(s):/repo-dir/contents/Source/Code/CBAM.SQL.PostgreSQL/Connection.cs
Covered lines:8
Uncovered lines:0
Coverable lines:8
Total lines:156
Line coverage:100%

Coverage History

Metrics

MethodCyclomatic complexity NPath complexity Sequence coverage Branch coverage
.ctor(...)101%0%

File(s)

/repo-dir/contents/Source/Code/CBAM.SQL.PostgreSQL/Connection.cs

#LineLine coverage
 1/*
 2 * Copyright 2017 Stanislav Muhametsin. All rights Reserved.
 3 *
 4 * Licensed  under the  Apache License,  Version 2.0  (the "License");
 5 * you may not use  this file  except in  compliance with the License.
 6 * You may obtain a copy of the License at
 7 *
 8 *   http://www.apache.org/licenses/LICENSE-2.0
 9 *
 10 * Unless required by applicable law or agreed to in writing, software
 11 * distributed  under the  License is distributed on an "AS IS" BASIS,
 12 * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
 13 * implied.
 14 *
 15 * See the License for the specific language governing permissions and
 16 * limitations under the License.
 17 */
 18using CBAM.Abstractions;
 19using CBAM.SQL;
 20using System;
 21using System.Collections.Generic;
 22using System.IO;
 23using System.Net;
 24using System.Text;
 25using System.Threading.Tasks;
 26using UtilPack;
 27
 28namespace CBAM.SQL.PostgreSQL
 29{
 30   /// <summary>
 31   /// This interface extends <see cref="SQLConnection"/> to provide PostgreSQL-specific API.
 32   /// </summary>
 33   /// <remarks>
 34   /// The <see cref="Connection{TStatement, TStatementInformation, TStatementCreationArgs, TEnumerableItem, TVendorFunc
 35   /// Also, the <see cref="UtilPack.TabularData.AsyncDataColumnMetaData"/> objects of <see cref="SQLDataRow"/>s returne
 36   /// The PostgreSQL-specific <see cref="SQLException"/> type is <see cref="PgSQLException"/>.
 37   /// </remarks>
 38   public partial interface PgSQLConnection : SQLConnection
 39   {
 40      ///// <summary>
 41      ///// This event will be fired whenever a notification is processed, which happens *only* when <see cref="CheckNot
 42      ///// </summary>
 43      ///// <seealso cref="NotificationEventArgs"/>
 44      //event GenericEventHandler<NotificationEventArgs> NotificationEvent;
 45
 46      /// <summary>
 47      /// Checks whether any notifications are pending.
 48      /// Please note that this will NOT cause SQL query (<c>SELECT 1</c>) to be sent to backend, unless this connection
 49      /// </summary>
 50      /// <returns>Task which will have completed after processing all pending notifies. The returned integer will be am
 51      /// <remarks>
 52      /// During normal SQL statement processing, all encountered notifications will be queued to list.
 53      /// This method will empty that list, and also check for any pending notifications from backend.
 54      /// </remarks>
 55      ValueTask<NotificationEventArgs[]> CheckNotificationsAsync();
 56
 57      /// <summary>
 58      /// This method will return an <see cref="IAsyncEnumerable{T}"/> that can be used to continuously and asynchronous
 59      /// </summary>
 60      /// <returns>An <see cref="IAsyncEnumerable{T}"/> that can be used to continuously and asynchronously to extract n
 61      IAsyncEnumerable<NotificationEventArgs> ContinuouslyListenToNotificationsAsync(); // TODO argument Func<Boolean> s
 62
 63      /// <summary>
 64      /// Gets the <see cref="PostgreSQL.TypeRegistry"/> object which manages the conversions between CLR types and Post
 65      /// </summary>
 66      /// <value>The <see cref="PostgreSQL.TypeRegistry"/> object which manages the conversions between CLR types and Po
 67      /// <seealso cref="PostgreSQL.TypeRegistry"/>
 68      TypeRegistry TypeRegistry { get; }
 69
 70      /// <summary>
 71      /// Gets the process ID of the backend process this connection is connected to.
 72      /// </summary>
 73      /// <value>The process ID of the backend process this connection is connected to.</value>
 74      Int32 BackendProcessID { get; }
 75
 76      /// <summary>
 77      /// Gets the last seen transaction status.
 78      /// </summary>
 79      /// <value>The last seen transaction status.</value>
 80      /// <see cref="TransactionStatus"/>
 81      TransactionStatus LastSeenTransactionStatus { get; }
 82   }
 83
 84   /// <summary>
 85   /// This interface extends <see cref="SQLConnectionVendorFunctionality"/> to provide PostgreSQL-specific vendor funct
 86   /// Instances of this class are obtaineable from <see cref="Connection{TStatement, TStatementInformation, TStatementC
 87   /// </summary>
 88   public interface PgSQLConnectionVendorFunctionality : SQLConnectionVendorFunctionality
 89   {
 90      /// <summary>
 91      /// Tries to advance the given <see cref="PeekablePotentiallyAsyncReader{TValue}"/> to the end of <c>COPY IN</c> s
 92      /// </summary>
 93      /// <param name="reader">The <see cref="PeekablePotentiallyAsyncReader{TValue}"/>.</param>
 94      /// <returns>A task which always returns <c>true</c>.</returns>
 95      ValueTask<Boolean> TryAdvanceReaderOverCopyInStatement( PeekablePotentiallyAsyncReader<Char?> reader );
 96   }
 97
 98   /// <summary>
 99   /// This class encapsulates all information about the data of single PostgreSQL notification (data received as a resu
 100   /// </summary>
 101   public class NotificationEventArgs
 102   {
 103
 104      /// <summary>
 105      /// Creates a new instance of <see cref="NotificationEventArgs"/> with given parameters.
 106      /// </summary>
 107      /// <param name="pid">The process ID of the backend which issued notify.</param>
 108      /// <param name="name">The name of the notification.</param>
 109      /// <param name="payload">The payload of the notification.</param>
 1110      public NotificationEventArgs( Int32 pid, String name, String payload )
 111      {
 1112         this.ProcessID = pid;
 1113         this.Name = name;
 1114         this.Payload = payload;
 1115      }
 116
 117      /// <summary>
 118      /// Gets the process ID of the backend which issued notify.
 119      /// </summary>
 120      /// <value>The process ID of the backend which issued notify.</value>
 1121      public Int32 ProcessID { get; }
 122
 123      /// <summary>
 124      /// Gets the name of the notification.
 125      /// </summary>
 126      /// <value>The name of the notification.</value>
 1127      public String Name { get; }
 128
 129      /// <summary>
 130      /// Gets the textual payload that was supplied with <c>NOTIFY</c> command.
 131      /// </summary>
 132      /// <value>The textual payload that was supplied with <c>NOTIFY</c> command.</value>
 1133      public String Payload { get; }
 134   }
 135
 136   /// <summary>
 137   /// This enumeration describes the transaction status of the connection.
 138   /// </summary>
 139   public enum TransactionStatus
 140   {
 141      /// <summary>
 142      /// No transaction is currently going on.
 143      /// </summary>
 144      Idle = 'I',
 145
 146      /// <summary>
 147      /// The transaction is going on.
 148      /// </summary>
 149      InTransaction = 'T',
 150
 151      /// <summary>
 152      /// Error was resulted.
 153      /// </summary>
 154      ErrorInTransaction = 'E'
 155   }
 156}