C# Класс KafkaNet.KafkaTcpSocket

The TcpSocket provides an abstraction from the main driver from having to handle connection to and reconnections with a server. The interface is intentionally limited to only read/write. All connection and reconnect details are handled internally.
Наследование: IKafkaTcpSocket
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
Dispose ( ) : void
KafkaTcpSocket ( IKafkaLog log, KafkaNet.Model.KafkaEndpoint endpoint, int maxRetry, System.TimeSpan maximumReconnectionTimeout = null, KafkaNet.Model.StatisticsTrackerOptions statisticsTrackerOptions = null ) : KafkaNet.Common

Construct socket and open connection to a specified server.

ReadAsync ( int readSize ) : Task

Read a certain byte array size return only when all bytes received.

ReadAsync ( int readSize, CancellationToken cancellationToken ) : Task

Read a certain byte array size return only when all bytes received.

WriteAsync ( KafkaDataPayload payload ) : Task

Convenience function to write full buffer data to the server.

WriteAsync ( KafkaDataPayload payload, CancellationToken cancellationToken ) : Task

Write the buffer data to the server.

Приватные методы

Метод Описание
DedicatedSocketTask ( ) : Task

Stop all pendding task when can not establish connection in max retry, but keep trying to recove and connect to this connection. Only the broker router can dispose of it.

EnqueueReadTask ( int readSize, CancellationToken cancellationToken ) : Task
EnqueueWriteTask ( KafkaDataPayload payload, CancellationToken cancellationToken ) : Task
GetStreamAsync ( ) : Task
ProcessNetworkstreamTasks ( NetworkStream netStream ) : Task
ProcessNetworkstreamTasksReadTask ( NetworkStream netStream ) : Task
ProcessNetworkstreamsSendTask ( NetworkStream netStream ) : Task
ProcessReadTaskAsync ( NetworkStream netStream, SocketPayloadReadTask readTask ) : Task
ProcessSentTasksAsync ( NetworkStream netStream, SocketPayloadSendTask sendTask ) : Task
RaiseServerDisconnectedEvent ( ) : void
ReEstablishConnectionAsync ( ) : Task

(Re-)establish the Kafka server connection. Assumes that the caller has already obtained the _clientLock

SetExceptionToAllPendingTasks ( Exception ex ) : void
ThrowTaskExceptionIfFaulted ( Task task ) : Task
UseStatisticsTracker ( ) : bool
WrappedException ( Exception ex ) : Exception

Описание методов

Dispose() публичный Метод

public Dispose ( ) : void
Результат void

KafkaTcpSocket() публичный Метод

Construct socket and open connection to a specified server.
public KafkaTcpSocket ( IKafkaLog log, KafkaNet.Model.KafkaEndpoint endpoint, int maxRetry, System.TimeSpan maximumReconnectionTimeout = null, KafkaNet.Model.StatisticsTrackerOptions statisticsTrackerOptions = null ) : KafkaNet.Common
log IKafkaLog Logging facility for verbose messaging of actions.
endpoint KafkaNet.Model.KafkaEndpoint The IP endpoint to connect to.
maxRetry int
maximumReconnectionTimeout System.TimeSpan The maximum time to wait when backing off on reconnection attempts.
statisticsTrackerOptions KafkaNet.Model.StatisticsTrackerOptions
Результат KafkaNet.Common

ReadAsync() публичный Метод

Read a certain byte array size return only when all bytes received.
public ReadAsync ( int readSize ) : Task
readSize int The size in bytes to receive from server.
Результат Task

ReadAsync() публичный Метод

Read a certain byte array size return only when all bytes received.
public ReadAsync ( int readSize, CancellationToken cancellationToken ) : Task
readSize int The size in bytes to receive from server.
cancellationToken System.Threading.CancellationToken A cancellation token which will cancel the request.
Результат Task

WriteAsync() публичный Метод

Convenience function to write full buffer data to the server.
public WriteAsync ( KafkaDataPayload payload ) : Task
payload KafkaDataPayload The buffer data to send.
Результат Task

WriteAsync() публичный Метод

Write the buffer data to the server.
public WriteAsync ( KafkaDataPayload payload, CancellationToken cancellationToken ) : Task
payload KafkaDataPayload The buffer data to send.
cancellationToken System.Threading.CancellationToken A cancellation token which will cancel the request.
Результат Task