Dreamine.Communication.Core 1.0.2
Dreamine.Communication.Core 통신 기능과 관련 API를 제공합니다.
로딩중...
검색중...
일치하는것 없음
Dreamine.Communication.Core.Resilience.ResilientMessageTransport 클래스 참조sealed

더 자세히 ...

Dreamine.Communication.Core.Resilience.ResilientMessageTransport에 대한 상속 다이어그램 :
Dreamine.Communication.Core.Resilience.ResilientMessageTransport에 대한 협력 다이어그램:

Public 멤버 함수

 ResilientMessageTransport (IMessageTransport innerTransport, ReconnectPolicy? reconnectPolicy=null, OutboundQueueOptions? queueOptions=null, IOutboundMessageQueue? outboundQueue=null)
async Task ConnectAsync (CancellationToken cancellationToken=default)
async Task DisconnectAsync (CancellationToken cancellationToken=default)
async Task SendAsync (MessageEnvelope message, CancellationToken cancellationToken=default)
async Task FlushQueueAsync (CancellationToken cancellationToken=default)
async ValueTask DisposeAsync ()

속성

TransportKind Kind [get]
ConnectionState State [get]
int QueuedMessageCount [get]
bool IsManualDisconnectRequested [get]
bool IsResilienceLoopRequested [get]

이벤트

EventHandler< MessageEnvelope >? MessageReceived
EventHandler< ConnectionState >? StateChanged
EventHandler< int >? QueueCountChanged

Private 멤버 함수

async Task HandleDisconnectedSendAsync (MessageEnvelope message, CancellationToken cancellationToken)
async Task WaitUntilConnectedAsync (CancellationToken cancellationToken)
void EnsureResilienceLoopStarted ()
async Task RunResilienceLoopAsync (CancellationToken cancellationToken)
void SetManualDisconnectRequested (bool value)
void SetResilienceLoopRequested (bool value)
void OnInnerMessageReceived (object? sender, MessageEnvelope message)
void NotifyStateChangedIfNeeded ()
void NotifyQueueCountChanged ()
void ThrowIfDisposed ()

정적 Private 멤버 함수

static bool IsOperationalState (ConnectionState state)
static async Task DelaySafelyAsync (TimeSpan delay, CancellationToken cancellationToken)

Private 속성

readonly IMessageTransport _innerTransport
readonly ReconnectPolicy _reconnectPolicy
readonly OutboundQueueOptions _queueOptions
readonly IOutboundMessageQueue _outboundQueue
readonly ReconnectDelayCalculator _delayCalculator
readonly SemaphoreSlim _flushLock = new(1, 1)
readonly object _loopSync = new()
readonly object _notifySync = new()
CancellationTokenSource _lifetimeCts = new()
Task? _resilienceLoopTask
int _manualDisconnectRequested = 1
int _resilienceLoopRequested
int _disposeGuard
bool _disposed
ConnectionState _lastNotifiedState = ConnectionState.Disconnected

상세한 설명

내부 메시지 전송 계층에 자동 재연결, 지수 백오프 및 연결 끊김 송신 큐를 추가합니다.

ResilientMessageTransport.cs 파일의 17 번째 라인에서 정의되었습니다.

생성자 & 소멸자 문서화

◆ ResilientMessageTransport()

Dreamine.Communication.Core.Resilience.ResilientMessageTransport.ResilientMessageTransport ( IMessageTransport innerTransport,
ReconnectPolicy? reconnectPolicy = null,
OutboundQueueOptions? queueOptions = null,
IOutboundMessageQueue? outboundQueue = null )
inline

내부 전송 계층과 선택적 복원·큐 설정으로 전송 계층을 초기화합니다.

매개변수
innerTransport실제 연결과 송수신을 담당할 전송 계층입니다.
reconnectPolicy재연결 간격과 횟수를 제어할 정책입니다.
queueOptions연결 끊김 송신 처리와 큐 제한 설정입니다.
outboundQueue사용자 지정 송신 큐이며, null이면 메모리 큐를 생성합니다.
예외
ArgumentNullExceptioninnerTransportnull인 경우 발생합니다.

ResilientMessageTransport.cs 파일의 204 번째 라인에서 정의되었습니다.

209 {
210 _innerTransport = innerTransport ?? throw new ArgumentNullException(nameof(innerTransport));
211 _reconnectPolicy = reconnectPolicy ?? new ReconnectPolicy();
212 _queueOptions = queueOptions ?? new OutboundQueueOptions();
213 _outboundQueue = outboundQueue ?? new InMemoryOutboundMessageQueue(_queueOptions);
214 _delayCalculator = new ReconnectDelayCalculator(_reconnectPolicy);
215
216 _lastNotifiedState = State;
217 _innerTransport.MessageReceived += OnInnerMessageReceived;
218 }

다음을 참조함 : _delayCalculator, _innerTransport, _lastNotifiedState, _outboundQueue, _queueOptions, _reconnectPolicy, OnInnerMessageReceived(), State.

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

멤버 함수 문서화

◆ ConnectAsync()

async Task Dreamine.Communication.Core.Resilience.ResilientMessageTransport.ConnectAsync ( CancellationToken cancellationToken = default)
inline

내부 연결과 필요 시 백그라운드 재연결 루프를 시작합니다.

매개변수
cancellationToken최초 연결과 큐 전송 취소 요청을 감시하는 토큰입니다.
반환값
비동기 연결 및 초기 큐 처리 작업입니다.
예외
ObjectDisposedException이미 해제된 경우 발생합니다.
OperationCanceledException작업 취소가 요청된 경우 발생할 수 있습니다.

ResilientMessageTransport.cs 파일의 338 번째 라인에서 정의되었습니다.

339 {
340 ThrowIfDisposed();
341
342 SetManualDisconnectRequested(false);
343 EnsureResilienceLoopStarted();
344 NotifyStateChangedIfNeeded();
345
346 try
347 {
348 await _innerTransport.ConnectAsync(cancellationToken).ConfigureAwait(false);
349 NotifyStateChangedIfNeeded();
350
351 if (_queueOptions.FlushOnReconnect)
352 {
353 await FlushQueueAsync(cancellationToken).ConfigureAwait(false);
354 }
355 }
356 catch
357 {
358 NotifyStateChangedIfNeeded();
359
360 if (!_reconnectPolicy.Enabled)
361 {
362 throw;
363 }
364
365 // 자동 재접속 모드에서는 최초 연결 실패를 치명 오류로 보지 않습니다.
366 // 이후 백그라운드 재접속 루프가 계속 연결을 시도합니다.
367 }
368 }

다음을 참조함 : _innerTransport, _queueOptions, _reconnectPolicy, EnsureResilienceLoopStarted(), FlushQueueAsync(), NotifyStateChangedIfNeeded(), SetManualDisconnectRequested(), ThrowIfDisposed().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ DelaySafelyAsync()

async Task Dreamine.Communication.Core.Resilience.ResilientMessageTransport.DelaySafelyAsync ( TimeSpan delay,
CancellationToken cancellationToken )
inlinestaticprivate

최소 양수 시간 동안 대기하고 정상적인 취소 예외를 내부에서 처리합니다.

매개변수
delay대기할 시간입니다.
cancellationToken대기 취소 토큰입니다.
반환값
안전한 비동기 대기 작업입니다.

ResilientMessageTransport.cs 파일의 1066 번째 라인에서 정의되었습니다.

1069 {
1070 if (delay <= TimeSpan.Zero)
1071 {
1072 delay = TimeSpan.FromMilliseconds(1);
1073 }
1074
1075 try
1076 {
1077 await Task.Delay(delay, cancellationToken).ConfigureAwait(false);
1078 }
1079 catch (OperationCanceledException)
1080 {
1081 // 정상적인 종료 경로입니다.
1082 }
1083 }

다음에 의해서 참조됨 : RunResilienceLoopAsync().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ DisconnectAsync()

async Task Dreamine.Communication.Core.Resilience.ResilientMessageTransport.DisconnectAsync ( CancellationToken cancellationToken = default)
inline

자동 재연결을 중지하고 내부 연결을 종료합니다.

매개변수
cancellationToken연결 해제 취소 요청을 감시하는 토큰입니다.
반환값
비동기 연결 해제 작업입니다.
예외
ObjectDisposedException이미 해제된 경우 발생합니다.
OperationCanceledException작업 취소가 요청된 경우 발생할 수 있습니다.

ResilientMessageTransport.cs 파일의 410 번째 라인에서 정의되었습니다.

411 {
412 ThrowIfDisposed();
413
414 SetManualDisconnectRequested(true);
415 SetResilienceLoopRequested(false);
416 NotifyStateChangedIfNeeded();
417
418 await _innerTransport.DisconnectAsync(cancellationToken).ConfigureAwait(false);
419 NotifyStateChangedIfNeeded();
420 }

다음을 참조함 : _innerTransport, NotifyStateChangedIfNeeded(), SetManualDisconnectRequested(), SetResilienceLoopRequested(), ThrowIfDisposed().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ DisposeAsync()

async ValueTask Dreamine.Communication.Core.Resilience.ResilientMessageTransport.DisposeAsync ( )
inline

재연결 루프를 중지하고 내부 전송 계층과 동기화 리소스를 비동기 해제합니다.

반환값
비동기 리소스 해제 작업입니다.

ResilientMessageTransport.cs 파일의 638 번째 라인에서 정의되었습니다.

639 {
640 // Interlocked guard prevents concurrent double-dispose.
641 if (Interlocked.CompareExchange(ref _disposeGuard, 1, 0) != 0)
642 {
643 return;
644 }
645
646 _disposed = true;
647 SetManualDisconnectRequested(true);
648 SetResilienceLoopRequested(false);
649
650 _innerTransport.MessageReceived -= OnInnerMessageReceived;
651
652 try
653 {
654 await _lifetimeCts.CancelAsync().ConfigureAwait(false);
655 }
656 catch
657 {
658 // Dispose 경로에서는 취소 실패를 무시합니다.
659 }
660
661 if (_resilienceLoopTask is not null)
662 {
663 try
664 {
665 await _resilienceLoopTask.ConfigureAwait(false);
666 }
667 catch
668 {
669 // Dispose 경로에서는 백그라운드 루프 예외를 무시합니다.
670 }
671 }
672
673 _lifetimeCts.Dispose();
674 _flushLock.Dispose();
675
676 await _innerTransport.DisposeAsync().ConfigureAwait(false);
677 }

다음을 참조함 : _disposed, _disposeGuard, _flushLock, _innerTransport, _lifetimeCts, _resilienceLoopTask, OnInnerMessageReceived(), SetManualDisconnectRequested(), SetResilienceLoopRequested().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ EnsureResilienceLoopStarted()

void Dreamine.Communication.Core.Resilience.ResilientMessageTransport.EnsureResilienceLoopStarted ( )
inlineprivate

자동 재연결이 활성화된 경우 복원 루프가 하나만 실행되도록 보장합니다.

ResilientMessageTransport.cs 파일의 801 번째 라인에서 정의되었습니다.

802 {
803 if (!_reconnectPolicy.Enabled)
804 {
805 return;
806 }
807
808 lock (_loopSync)
809 {
810 if (_disposed)
811 {
812 return;
813 }
814
815 SetResilienceLoopRequested(true);
816
817 if (_resilienceLoopTask is { IsCompleted: false })
818 {
819 return;
820 }
821
822 if (_lifetimeCts.IsCancellationRequested)
823 {
824 _lifetimeCts.Dispose();
825 _lifetimeCts = new CancellationTokenSource();
826 }
827
828 _resilienceLoopTask = Task.Run(
829 () => RunResilienceLoopAsync(_lifetimeCts.Token),
830 CancellationToken.None);
831 }
832 }

다음을 참조함 : _disposed, _lifetimeCts, _loopSync, _reconnectPolicy, _resilienceLoopTask, RunResilienceLoopAsync(), SetResilienceLoopRequested().

다음에 의해서 참조됨 : ConnectAsync(), FlushQueueAsync(), SendAsync(), WaitUntilConnectedAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ FlushQueueAsync()

async Task Dreamine.Communication.Core.Resilience.ResilientMessageTransport.FlushQueueAsync ( CancellationToken cancellationToken = default)
inline

연결된 동안 만료되지 않은 송신 대기 메시지를 순서대로 전송합니다.

매개변수
cancellationToken큐 전송 취소 요청을 감시하는 토큰입니다.
반환값
비동기 큐 전송 작업입니다.
예외
ObjectDisposedException이미 해제된 경우 발생합니다.
OperationCanceledException작업 취소가 요청된 경우 발생할 수 있습니다.

ResilientMessageTransport.cs 파일의 557 번째 라인에서 정의되었습니다.

558 {
559 ThrowIfDisposed();
560
561 if (!_queueOptions.FlushOnReconnect)
562 {
563 return;
564 }
565
566 await _flushLock.WaitAsync(cancellationToken).ConfigureAwait(false);
567
568 try
569 {
570 while (IsOperationalState(_innerTransport.State))
571 {
572 cancellationToken.ThrowIfCancellationRequested();
573
574 var queuedMessage = await _outboundQueue
575 .TryDequeueAsync(cancellationToken)
576 .ConfigureAwait(false);
577
578 if (queuedMessage is null)
579 {
580 NotifyQueueCountChanged();
581 NotifyStateChangedIfNeeded();
582 return;
583 }
584
585 NotifyQueueCountChanged();
586
587 if (queuedMessage.IsExpired(
588 _queueOptions.MaxMessageAge,
589 DateTimeOffset.UtcNow))
590 {
591 continue;
592 }
593
594 try
595 {
596 await _innerTransport
597 .SendAsync(queuedMessage.Message, cancellationToken)
598 .ConfigureAwait(false);
599
600 NotifyQueueCountChanged();
601 NotifyStateChangedIfNeeded();
602 }
603 catch (Exception ex)
604 {
605 await _outboundQueue
606 .EnqueueFrontAsync(queuedMessage.WithFailure(ex), cancellationToken)
607 .ConfigureAwait(false);
608
609 NotifyQueueCountChanged();
610 EnsureResilienceLoopStarted();
611 NotifyStateChangedIfNeeded();
612 return;
613 }
614 }
615 }
616 finally
617 {
618 _flushLock.Release();
619 }
620 }

다음을 참조함 : _flushLock, _innerTransport, _outboundQueue, _queueOptions, EnsureResilienceLoopStarted(), IsOperationalState(), NotifyQueueCountChanged(), NotifyStateChangedIfNeeded(), ThrowIfDisposed().

다음에 의해서 참조됨 : ConnectAsync(), RunResilienceLoopAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ HandleDisconnectedSendAsync()

async Task Dreamine.Communication.Core.Resilience.ResilientMessageTransport.HandleDisconnectedSendAsync ( MessageEnvelope message,
CancellationToken cancellationToken )
inlineprivate

연결 끊김 송신 정책에 따라 실패, 큐 저장 또는 연결 대기 후 송신을 수행합니다.

매개변수
message처리할 송신 메시지입니다.
cancellationToken비동기 처리 취소 토큰입니다.
반환값
정책 처리 작업입니다.
예외
InvalidOperationException정책이 즉시 실패이거나 알 수 없는 값인 경우 발생합니다.

ResilientMessageTransport.cs 파일의 719 번째 라인에서 정의되었습니다.

722 {
723 switch (_queueOptions.DisconnectedSendPolicy)
724 {
725 case DisconnectedSendPolicy.Fail:
726 throw new InvalidOperationException("Transport is not connected.");
727
728 case DisconnectedSendPolicy.Queue:
729 await _outboundQueue
730 .EnqueueAsync(new QueuedOutboundMessage(message), cancellationToken)
731 .ConfigureAwait(false);
732
733 NotifyQueueCountChanged();
734 return;
735
736 case DisconnectedSendPolicy.WaitUntilConnected:
737 await WaitUntilConnectedAsync(cancellationToken).ConfigureAwait(false);
738 await _innerTransport.SendAsync(message, cancellationToken).ConfigureAwait(false);
739 NotifyStateChangedIfNeeded();
740 return;
741
742 default:
743 throw new InvalidOperationException(
744 $"Unsupported disconnected send policy: {_queueOptions.DisconnectedSendPolicy}");
745 }
746 }

다음을 참조함 : _innerTransport, _outboundQueue, _queueOptions, NotifyQueueCountChanged(), NotifyStateChangedIfNeeded(), WaitUntilConnectedAsync().

다음에 의해서 참조됨 : SendAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ IsOperationalState()

bool Dreamine.Communication.Core.Resilience.ResilientMessageTransport.IsOperationalState ( ConnectionState state)
inlinestaticprivate

지정한 상태가 메시지 송신 가능한 연결 또는 수신 대기 상태인지 확인합니다.

매개변수
state검사할 연결 상태입니다.
반환값
동작 가능한 상태이면 true입니다.

ResilientMessageTransport.cs 파일의 965 번째 라인에서 정의되었습니다.

966 {
967 return state is ConnectionState.Connected or ConnectionState.Listening;
968 }

다음에 의해서 참조됨 : FlushQueueAsync(), RunResilienceLoopAsync(), SendAsync(), WaitUntilConnectedAsync().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ NotifyQueueCountChanged()

void Dreamine.Communication.Core.Resilience.ResilientMessageTransport.NotifyQueueCountChanged ( )
inlineprivate

현재 송신 큐 개수로 큐 변경 이벤트를 발생시킵니다.

ResilientMessageTransport.cs 파일의 1149 번째 라인에서 정의되었습니다.

1150 {
1151 QueueCountChanged?.Invoke(this, _outboundQueue.Count);
1152 }

다음을 참조함 : _outboundQueue, QueueCountChanged.

다음에 의해서 참조됨 : FlushQueueAsync(), HandleDisconnectedSendAsync().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ NotifyStateChangedIfNeeded()

void Dreamine.Communication.Core.Resilience.ResilientMessageTransport.NotifyStateChangedIfNeeded ( )
inlineprivate

마지막 알림 이후 유효 연결 상태가 바뀐 경우에만 상태 변경 이벤트를 발생시킵니다.

ResilientMessageTransport.cs 파일의 1122 번째 라인에서 정의되었습니다.

1123 {
1124 var currentState = State;
1125 EventHandler<ConnectionState>? handler;
1126
1127 lock (_notifySync)
1128 {
1129 if (_lastNotifiedState == currentState)
1130 {
1131 return;
1132 }
1133
1134 _lastNotifiedState = currentState;
1135 handler = StateChanged;
1136 }
1137
1138 handler?.Invoke(this, currentState);
1139 }

다음을 참조함 : _lastNotifiedState, _notifySync, State, StateChanged.

다음에 의해서 참조됨 : ConnectAsync(), DisconnectAsync(), FlushQueueAsync(), HandleDisconnectedSendAsync(), RunResilienceLoopAsync(), SendAsync(), WaitUntilConnectedAsync().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ OnInnerMessageReceived()

void Dreamine.Communication.Core.Resilience.ResilientMessageTransport.OnInnerMessageReceived ( object? sender,
MessageEnvelope message )
inlineprivate

내부 수신 이벤트를 현재 전송 계층의 수신 이벤트로 다시 발생시킵니다.

매개변수
sender내부 이벤트 발생 객체이며 사용하지 않습니다.
message수신한 메시지입니다.

ResilientMessageTransport.cs 파일의 1109 번째 라인에서 정의되었습니다.

1110 {
1111 MessageReceived?.Invoke(this, message);
1112 }

다음을 참조함 : MessageReceived.

다음에 의해서 참조됨 : DisposeAsync(), ResilientMessageTransport().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ RunResilienceLoopAsync()

async Task Dreamine.Communication.Core.Resilience.ResilientMessageTransport.RunResilienceLoopAsync ( CancellationToken cancellationToken)
inlineprivate

연결 감시, 재연결 백오프 및 큐 전송을 수행하는 백그라운드 루프를 실행합니다.

매개변수
cancellationToken루프 종료를 요청하는 토큰입니다.
반환값
복원 루프 작업입니다.

ResilientMessageTransport.cs 파일의 858 번째 라인에서 정의되었습니다.

859 {
860 var reconnectAttempt = 0;
861
862 while (!cancellationToken.IsCancellationRequested)
863 {
864 NotifyStateChangedIfNeeded();
865
866 if (IsManualDisconnectRequested)
867 {
868 await DelaySafelyAsync(
869 _reconnectPolicy.WatchInterval,
870 cancellationToken)
871 .ConfigureAwait(false);
872
873 continue;
874 }
875
876 if (IsOperationalState(_innerTransport.State))
877 {
878 reconnectAttempt = 0;
879 NotifyStateChangedIfNeeded();
880
881 if (_queueOptions.FlushOnReconnect && _outboundQueue.Count > 0)
882 {
883 await FlushQueueAsync(cancellationToken).ConfigureAwait(false);
884 }
885
886 await DelaySafelyAsync(
887 _reconnectPolicy.WatchInterval,
888 cancellationToken)
889 .ConfigureAwait(false);
890
891 continue;
892 }
893
894 if (_innerTransport.State == ConnectionState.Disconnecting)
895 {
896 await DelaySafelyAsync(
897 _reconnectPolicy.WatchInterval,
898 cancellationToken)
899 .ConfigureAwait(false);
900
901 continue;
902 }
903
904 if (_reconnectPolicy.MaxRetryCount is not null &&
905 reconnectAttempt >= _reconnectPolicy.MaxRetryCount.Value)
906 {
907 await DelaySafelyAsync(
908 _reconnectPolicy.MaxDelay,
909 cancellationToken)
910 .ConfigureAwait(false);
911
912 continue;
913 }
914
915 reconnectAttempt++;
916 NotifyStateChangedIfNeeded();
917
918 try
919 {
920 await _innerTransport.ConnectAsync(cancellationToken).ConfigureAwait(false);
921 reconnectAttempt = 0;
922 NotifyStateChangedIfNeeded();
923
924 if (_queueOptions.FlushOnReconnect)
925 {
926 await FlushQueueAsync(cancellationToken).ConfigureAwait(false);
927 }
928 }
929 catch
930 {
931 NotifyStateChangedIfNeeded();
932
933 var delay = _delayCalculator.Calculate(reconnectAttempt);
934
935 await DelaySafelyAsync(delay, cancellationToken)
936 .ConfigureAwait(false);
937 }
938 }
939 }

다음을 참조함 : _delayCalculator, _innerTransport, _outboundQueue, _queueOptions, _reconnectPolicy, DelaySafelyAsync(), FlushQueueAsync(), IsManualDisconnectRequested, IsOperationalState(), NotifyStateChangedIfNeeded().

다음에 의해서 참조됨 : EnsureResilienceLoopStarted().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ SendAsync()

async Task Dreamine.Communication.Core.Resilience.ResilientMessageTransport.SendAsync ( MessageEnvelope message,
CancellationToken cancellationToken = default )
inline

연결 상태와 끊김 송신 정책에 따라 즉시 전송하거나 큐에 저장합니다.

매개변수
message전송할 메시지입니다.
cancellationToken송신 또는 큐 저장 취소 요청을 감시하는 토큰입니다.
반환값
비동기 송신 또는 큐 저장 작업입니다.
예외
ArgumentNullExceptionmessagenull인 경우 발생합니다.
InvalidOperationException연결 끊김 정책이 즉시 실패이거나 지원하지 않는 경우 발생합니다.
ObjectDisposedException이미 해제된 경우 발생합니다.
OperationCanceledException작업 취소가 요청된 경우 발생할 수 있습니다.

ResilientMessageTransport.cs 파일의 486 번째 라인에서 정의되었습니다.

489 {
490 ArgumentNullException.ThrowIfNull(message);
491 ThrowIfDisposed();
492
493 SetManualDisconnectRequested(false);
494
495 if (IsOperationalState(_innerTransport.State))
496 {
497 try
498 {
499 await _innerTransport.SendAsync(message, cancellationToken).ConfigureAwait(false);
500 NotifyStateChangedIfNeeded();
501 return;
502 }
503 catch
504 {
505 await HandleDisconnectedSendAsync(message, cancellationToken).ConfigureAwait(false);
506 EnsureResilienceLoopStarted();
507 NotifyStateChangedIfNeeded();
508 return;
509 }
510 }
511
512 await HandleDisconnectedSendAsync(message, cancellationToken).ConfigureAwait(false);
513 EnsureResilienceLoopStarted();
514 NotifyStateChangedIfNeeded();
515 }

다음을 참조함 : _innerTransport, EnsureResilienceLoopStarted(), HandleDisconnectedSendAsync(), IsOperationalState(), NotifyStateChangedIfNeeded(), SetManualDisconnectRequested(), ThrowIfDisposed().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ SetManualDisconnectRequested()

void Dreamine.Communication.Core.Resilience.ResilientMessageTransport.SetManualDisconnectRequested ( bool value)
inlineprivate

수동 연결 해제 요청 플래그를 스레드 안전하게 설정합니다.

매개변수
value설정할 플래그 값입니다.

ResilientMessageTransport.cs 파일의 1008 번째 라인에서 정의되었습니다.

1009 {
1010 Interlocked.Exchange(ref _manualDisconnectRequested, value ? 1 : 0);
1011 }

다음을 참조함 : _manualDisconnectRequested.

다음에 의해서 참조됨 : ConnectAsync(), DisconnectAsync(), DisposeAsync(), SendAsync().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ SetResilienceLoopRequested()

void Dreamine.Communication.Core.Resilience.ResilientMessageTransport.SetResilienceLoopRequested ( bool value)
inlineprivate

복원 루프 실행 요청 플래그를 스레드 안전하게 설정합니다.

매개변수
value설정할 플래그 값입니다.

ResilientMessageTransport.cs 파일의 1029 번째 라인에서 정의되었습니다.

1030 {
1031 Interlocked.Exchange(ref _resilienceLoopRequested, value ? 1 : 0);
1032 }

다음을 참조함 : _resilienceLoopRequested.

다음에 의해서 참조됨 : DisconnectAsync(), DisposeAsync(), EnsureResilienceLoopStarted().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ ThrowIfDisposed()

void Dreamine.Communication.Core.Resilience.ResilientMessageTransport.ThrowIfDisposed ( )
inlineprivate

전송 계층이 이미 해제되었으면 예외를 발생시킵니다.

예외
ObjectDisposedException인스턴스가 해제된 경우 발생합니다.

ResilientMessageTransport.cs 파일의 1170 번째 라인에서 정의되었습니다.

1171 {
1172 ObjectDisposedException.ThrowIf(_disposed, this);
1173 }

다음을 참조함 : _disposed.

다음에 의해서 참조됨 : ConnectAsync(), DisconnectAsync(), FlushQueueAsync(), SendAsync().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ WaitUntilConnectedAsync()

async Task Dreamine.Communication.Core.Resilience.ResilientMessageTransport.WaitUntilConnectedAsync ( CancellationToken cancellationToken)
inlineprivate

복원 루프를 시작하고 내부 전송 계층이 연결될 때까지 비동기 대기합니다.

매개변수
cancellationToken대기 취소 토큰입니다.
반환값
연결 대기 작업입니다.
예외
OperationCanceledException취소가 요청된 경우 발생합니다.

ResilientMessageTransport.cs 파일의 780 번째 라인에서 정의되었습니다.

781 {
782 EnsureResilienceLoopStarted();
783 NotifyStateChangedIfNeeded();
784
785 while (!IsOperationalState(_innerTransport.State))
786 {
787 cancellationToken.ThrowIfCancellationRequested();
788 await Task.Delay(_reconnectPolicy.WatchInterval, cancellationToken)
789 .ConfigureAwait(false);
790 }
791 }

다음을 참조함 : _innerTransport, _reconnectPolicy, EnsureResilienceLoopStarted(), IsOperationalState(), NotifyStateChangedIfNeeded().

다음에 의해서 참조됨 : HandleDisconnectedSendAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

멤버 데이터 문서화

◆ _delayCalculator

readonly ReconnectDelayCalculator Dreamine.Communication.Core.Resilience.ResilientMessageTransport._delayCalculator
private

delay Calculator 값을 보관합니다.

ResilientMessageTransport.cs 파일의 63 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : ResilientMessageTransport(), RunResilienceLoopAsync().

◆ _disposed

bool Dreamine.Communication.Core.Resilience.ResilientMessageTransport._disposed
private

disposed 값을 보관합니다.

ResilientMessageTransport.cs 파일의 145 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : DisposeAsync(), EnsureResilienceLoopStarted(), ThrowIfDisposed().

◆ _disposeGuard

int Dreamine.Communication.Core.Resilience.ResilientMessageTransport._disposeGuard
private

dispose Guard 값을 보관합니다.

ResilientMessageTransport.cs 파일의 136 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : DisposeAsync().

◆ _flushLock

readonly SemaphoreSlim Dreamine.Communication.Core.Resilience.ResilientMessageTransport._flushLock = new(1, 1)
private

flush Lock 값을 보관합니다.

ResilientMessageTransport.cs 파일의 72 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : DisposeAsync(), FlushQueueAsync().

◆ _innerTransport

readonly IMessageTransport Dreamine.Communication.Core.Resilience.ResilientMessageTransport._innerTransport
private

inner Transport 값을 보관합니다.

ResilientMessageTransport.cs 파일의 27 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : ConnectAsync(), DisconnectAsync(), DisposeAsync(), FlushQueueAsync(), HandleDisconnectedSendAsync(), ResilientMessageTransport(), RunResilienceLoopAsync(), SendAsync(), WaitUntilConnectedAsync().

◆ _lastNotifiedState

ConnectionState Dreamine.Communication.Core.Resilience.ResilientMessageTransport._lastNotifiedState = ConnectionState.Disconnected
private

last Notified State 값을 보관합니다.

ResilientMessageTransport.cs 파일의 154 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : NotifyStateChangedIfNeeded(), ResilientMessageTransport().

◆ _lifetimeCts

CancellationTokenSource Dreamine.Communication.Core.Resilience.ResilientMessageTransport._lifetimeCts = new()
private

lifetime Cts 값을 보관합니다.

ResilientMessageTransport.cs 파일의 100 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : DisposeAsync(), EnsureResilienceLoopStarted().

◆ _loopSync

readonly object Dreamine.Communication.Core.Resilience.ResilientMessageTransport._loopSync = new()
private

loop Sync 값을 보관합니다.

ResilientMessageTransport.cs 파일의 81 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : EnsureResilienceLoopStarted().

◆ _manualDisconnectRequested

int Dreamine.Communication.Core.Resilience.ResilientMessageTransport._manualDisconnectRequested = 1
private

manual Disconnect Requested 값을 보관합니다.

ResilientMessageTransport.cs 파일의 118 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : SetManualDisconnectRequested().

◆ _notifySync

readonly object Dreamine.Communication.Core.Resilience.ResilientMessageTransport._notifySync = new()
private

notify Sync 값을 보관합니다.

ResilientMessageTransport.cs 파일의 90 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : NotifyStateChangedIfNeeded().

◆ _outboundQueue

readonly IOutboundMessageQueue Dreamine.Communication.Core.Resilience.ResilientMessageTransport._outboundQueue
private

outbound Queue 값을 보관합니다.

ResilientMessageTransport.cs 파일의 54 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : FlushQueueAsync(), HandleDisconnectedSendAsync(), NotifyQueueCountChanged(), ResilientMessageTransport(), RunResilienceLoopAsync().

◆ _queueOptions

readonly OutboundQueueOptions Dreamine.Communication.Core.Resilience.ResilientMessageTransport._queueOptions
private

queue Options 값을 보관합니다.

ResilientMessageTransport.cs 파일의 45 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : ConnectAsync(), FlushQueueAsync(), HandleDisconnectedSendAsync(), ResilientMessageTransport(), RunResilienceLoopAsync().

◆ _reconnectPolicy

readonly ReconnectPolicy Dreamine.Communication.Core.Resilience.ResilientMessageTransport._reconnectPolicy
private

reconnect Policy 값을 보관합니다.

ResilientMessageTransport.cs 파일의 36 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : ConnectAsync(), EnsureResilienceLoopStarted(), ResilientMessageTransport(), RunResilienceLoopAsync(), WaitUntilConnectedAsync().

◆ _resilienceLoopRequested

int Dreamine.Communication.Core.Resilience.ResilientMessageTransport._resilienceLoopRequested
private

resilience Loop Requested 값을 보관합니다.

ResilientMessageTransport.cs 파일의 127 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : SetResilienceLoopRequested().

◆ _resilienceLoopTask

Task? Dreamine.Communication.Core.Resilience.ResilientMessageTransport._resilienceLoopTask
private

resilience Loop Task 값을 보관합니다.

ResilientMessageTransport.cs 파일의 109 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : DisposeAsync(), EnsureResilienceLoopStarted().

속성 문서화

◆ IsManualDisconnectRequested

bool Dreamine.Communication.Core.Resilience.ResilientMessageTransport.IsManualDisconnectRequested
getprivate

호출자가 수동 연결 해제를 요청했는지 스레드 안전하게 확인합니다.

ResilientMessageTransport.cs 파일의 978 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : RunResilienceLoopAsync().

◆ IsResilienceLoopRequested

bool Dreamine.Communication.Core.Resilience.ResilientMessageTransport.IsResilienceLoopRequested
getprivate

연결 복원 루프 실행이 요청되었는지 스레드 안전하게 확인합니다.

ResilientMessageTransport.cs 파일의 989 번째 라인에서 정의되었습니다.

◆ Kind

TransportKind Dreamine.Communication.Core.Resilience.ResilientMessageTransport.Kind
get

내부 전송 계층의 전송 방식을 가져옵니다.

ResilientMessageTransport.cs 파일의 258 번째 라인에서 정의되었습니다.

◆ QueuedMessageCount

int Dreamine.Communication.Core.Resilience.ResilientMessageTransport.QueuedMessageCount
get

현재 송신 대기 큐에 저장된 메시지 수를 가져옵니다.

ResilientMessageTransport.cs 파일의 296 번째 라인에서 정의되었습니다.

◆ State

ConnectionState Dreamine.Communication.Core.Resilience.ResilientMessageTransport.State
get

내부 상태와 재연결 루프를 반영한 현재 유효 연결 상태를 가져옵니다.

ResilientMessageTransport.cs 파일의 268 번째 라인에서 정의되었습니다.

269 {
270 get
271 {
272 if (IsOperationalState(_innerTransport.State))
273 {
274 return _innerTransport.State;
275 }
276
277 if (_reconnectPolicy.Enabled &&
278 !IsManualDisconnectRequested &&
279 IsResilienceLoopRequested)
280 {
281 return ConnectionState.Connecting;
282 }
283
284 return _innerTransport.State;
285 }
286 }

다음에 의해서 참조됨 : NotifyStateChangedIfNeeded(), ResilientMessageTransport().

이벤트 문서화

◆ MessageReceived

EventHandler<MessageEnvelope>? Dreamine.Communication.Core.Resilience.ResilientMessageTransport.MessageReceived

내부 전송 계층이 메시지를 수신했을 때 발생합니다.

ResilientMessageTransport.cs 파일의 228 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : OnInnerMessageReceived().

◆ QueueCountChanged

EventHandler<int>? Dreamine.Communication.Core.Resilience.ResilientMessageTransport.QueueCountChanged

송신 대기 큐의 메시지 수가 변경될 때 발생합니다.

ResilientMessageTransport.cs 파일의 248 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : NotifyQueueCountChanged().

◆ StateChanged

EventHandler<ConnectionState>? Dreamine.Communication.Core.Resilience.ResilientMessageTransport.StateChanged

복원 동작을 반영한 유효 연결 상태가 변경될 때 발생합니다.

ResilientMessageTransport.cs 파일의 238 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : NotifyStateChangedIfNeeded().


이 클래스에 대한 문서화 페이지는 다음의 파일로부터 생성되었습니다.: