Coucou,
Je te propose en // une bonne source d'inspiration ^^
////////////////////////////////////////////////////////////////////////////////////////////////
// Retry pattern
////////////////////////////////////////////////////////////////////////////////////////////////
An application that communicates with elements running in the cloud has to be sensitive
to the transient faults that can occur in this environment.
Faults include the momentary loss of network connectivity to components and
services, the temporary unavailability of a service,or timeouts that occur when a
service is busy.
These faults are typically self-correcting, and if the action that triggered a fault is
repeated after a suitable delay it's likely to be successful.
For example, a database service that's processing a large number of concurrent
requests can implement a throttling strategy that temporarily rejects any further
requests until its workload has eased.
An application trying to access the database might fail to connect, but if it tries again
after a delay it might succeed.
Reference: https://docs.microsoft.com/en-us/azure/architecture/patterns/retry
////////////////////////////////////////////////////////////////////////////////////////////////
EDelayMode est une Enumération
Unknown = -1
Default = 1
Incremented = 2
Doubled = 3
FIN
APattern_Retry est une Classe, abstraite
GLOBAL
PUBLIC
CONSTANT
__FORMAT_DELAY = "MM:SS:LLL"
END
LOCAL
PRIVÉE
m_eDelayMode est un EDelayMode
m_xTProcedureBefore est une Procedure
m_xTProcedure est une Procedure
m_xTProcedureAfter est une Procedure
m_nRetryCount est un entier sans signe sur 4 octets
m_xDelay est une Durée
m_xDelayIncrement est une Durée
m_taCKSTs est un tableau associatif (*, Null) de chaînes
FIN
Procedure PROTÉGÉE Initialization() <sans pas à pas>: boolean
ErreurChangeParamètre(epGotoCasErreur)
ExceptionChangeParamètre(epGotoCasException)
RETOUR = Faux
:RetryCount = 1
:DelayMode = EDelayMode.Default
:Delay = 1s
:DelayIncrement = 0s
RENVOYER Vrai
CAS ERREUR:
ErreurPropage()
CAS EXCEPTION:
ExceptionPropage()
Procedure PROTÉGÉE CKST() <sans pas à pas>: boolean
ErreurChangeParamètre(epGotoCasErreur)
ExceptionChangeParamètre(epGotoCasException)
RETOUR = Faux
_sCKST est une chaîne
_sCKST = "Delay"
SI :Delay < 0
:CKSTs[_sCKST] = _(__ERROR_SERVER_UNKNOWN_VALUE, ":Delay = '[% :Delay %]'")
FIN
_sCKST = "DelayMode"
SI :DelayMode = EDelayMode.Unknown
:CKSTs[_sCKST] = _(__ERROR_SERVER_UNKNOWN_VALUE, ":DelayMode = '[% :DelayMode..Nom %]'")
FIN
_sCKST = "RetryCount"
SI :RetryCount < 1
:CKSTs[_sCKST] = _(__ERROR_SERVER_UNKNOWN_VALUE, ":RetryCount = '[% :RetryCount %]'")
FIN
RENVOYER (TableauOccurrence(:CKSTs) = 0)
CAS ERREUR:
ErreurPropage()
CAS EXCEPTION:
ExceptionPropage()
Procedure PROTÉGÉE DelayCount(LOCAL _nRetryCount est un entier sans signe sur 4 octets) <sans pas à pas>: Durée
ErreurChangeParamètre(epGotoCasErreur)
ExceptionChangeParamètre(epGotoCasException)
RETOUR = :Delay
_nRetryCount -= 2
_xDelay est une Durée
SELON :DelayMode
CAS Default
_xDelay = :Delay
CAS Incremented
_xDelay = :Delay + (_nRetryCount * :DelayIncrement)
CAS Doubled
_xDelay = (_nRetryCount = 0)? :Delay SINON (:Delay * Puissance(2, _nRetryCount))
FIN
RENVOYER _xDelay
CAS ERREUR:
ErreurPropage()
CAS EXCEPTION:
ExceptionPropage()
Procedure PUBLIC Run(*): boolean
ErreurChangeParamètre(epGotoCasErreur)
ExceptionChangeParamètre(epGotoCasException)
RETOUR = Faux
POUR _nRetryCount = 1 _À_ :RetryCount
SI _nRetryCount > 1 ALORS
SELON Vrai
CAS EnModeService()
ServiceTemporise(:DelayCount(_nRetryCount))
CAS ThreadCourant() <> ""
ThreadPause(:DelayCount(_nRetryCount))
AUTRE CAS
Multitâche(-:DelayCount(_nRetryCount))
FIN
FIN
SI PAS :TProcedureBefore = Null ALORS
:TProcedureBefore(_nRetryCount)
FIN
:TProcedure(MesParamètres)
SI ErreurDétectée ALORS
SELON ErreurInfo(errCode)
CAS __ERROR_SERVER_SERVICE_UNAVAILABLE_CODE
CONTINUE
CAS __ERROR_SERVER_INTERNAL_CODE
ErreurPropage()
RENVOYER Faux
AUTRE CAS
ErreurPropage()
RENVOYER Faux
FIN
SINON
SI PAS :TProcedureAfter = Null ALORS
:TProcedureAfter()
FIN
BREAK
FIN
FIN
RENVOYER Vrai
CAS ERREUR:
ErreurPropage()
CAS EXCEPTION:
ExceptionPropage()
#WLoodies #LaPiraterieNEstJamaisFinie #92i #SombreHistoireTristeMelo
--
In üs we trust - #92i
Message modifié, 05 août 2018 - 20:11