package Ġcom . k ori it . kotlin . slf 4 j . mdc . correlation Ċ Ċ import Ġkotlinx . coroutines . Coroutine Scope Ċ import Ġkotlinx . coroutines . with Context Ċ import Ġkotlin . coroutines . Coroutine Context Ċ Ċ /** Ċ Ġ* ĠCreates Ġnew Ġcontext Ġelement Ġwith Ġcurrent Ġcorrelation Ġand Ġoptional Ġsub - correlation . Ċ Ġ*/ Ċ fun Ġcontinue Correlation (): ĠCor outine Context Ġ{ ĊĠĠĠ Ġval Ġcorrelation Ġ= Ġcorrelation Id ĊĠĠĠĠĠĠĠ Ġ? . let Ġ{ ĠCorre lation Id ( it ) Ġ} ĊĠĠĠĠĠĠĠ Ġ?: Ġthrow ĠIllegalStateException (" There Ġis Ġno Ġcorrelation Ġto Ġcontinue ") ĊĊĠĠĠ Ġval Ġsub Correlation Ġ= Ġsub Correlation Id ĊĠĠĠĠĠĠĠ Ġ? . let Ġ{ ĠSub Correlation Id ( it ) Ġ} ĊĠĠĠĠĠĠĠ Ġ?: ĠNo Sub Correlation Id ĊĊĠĠĠ Ġreturn Ġcorrelation Ġ+ Ġsub Correlation Ċ } Ċ Ċ /** Ċ Ġ* ĠCreates Ġnew Ġcontext Ġelement Ġwith Ġcorrelation Ġand Ġoptional Ġsub - correlation Ġcopied Ġfrom Ġpassed Ġcoroutine Ġcontext . Ċ Ġ*/ Ċ fun Ġcontinue Correlation ( context : ĠCor outine Context ): ĠCor outine Context Ġ{ ĊĠĠĠ Ġval Ġcorrelation Ġ= Ġcontext [ Correlation Id ] Ġ?: Ġthrow ĠIllegalStateException (" There Ġis Ġno Ġcorrelation Ġto Ġcontinue ") ĊĠĠĠ Ġval Ġsub Correlation Ġ= Ġcontext [ Sub Correlation Id ] Ġ?: ĠNo Sub Correlation Id ĊĊĠĠĠ Ġreturn Ġcorrelation Ġ+ Ġsub Correlation Ċ } Ċ Ċ /** Ċ Ġ* ĠCreates Ġnew Ġcontext Ġelement Ġwith Ġcorrelation Ġand Ġoptional Ġsub - correlation Ġcopied Ġfrom Ġpassed Ġcoroutine Ġscope . Ċ Ġ*/ Ċ fun Ġcontinue Correlation ( scope : ĠCor outine Scope ) Ġ= Ġcontinue Correlation ( scope . coroutine Context ) Ċ Ċ /** Ċ Ġ* ĠCor outine Ġbuilder . ĠP assed Ġcoroutine Ġis Ġexecuted Ġwith Ġcorrelation Ġand Ġoptional Ġsub - correlation Ġof Ġpassed Ġcoroutine Ġcontext . Ċ Ġ*/ Ċ suspend Ġfun Ġ< T > Ġcontinue Correlation ( context : ĠCor outine Context , Ġblock : Ġsuspend ĠCor outine Scope . () Ġ-> ĠT ): ĠT Ġ= Ġwith Context ( continue Correlation ( context ), Ġblock ) Ċ Ċ /** Ċ Ġ* ĠCor outine Ġbuilder . ĠP assed Ġcoroutine Ġis Ġexecuted Ġwith Ġcorrelation Ġand Ġoptional Ġsub - correlation Ġof Ġpassed Ġcoroutine Ġscope . Ċ Ġ*/ Ċ suspend Ġfun Ġ< T > Ġcontinue Correlation ( scope : ĠCor outine Scope , Ġblock : Ġsuspend ĠCor outine Scope . () Ġ-> ĠT ): ĠT Ġ= Ġwith Context ( continue Correlation ( scope . coroutine Context ), Ġblock ) Ċ