package Ġco . nil in . op ex . bc gateway . ports . postgres . impl Ċ Ċ import Ġco . nil in . op ex . bc gateway . core . model . Wallet Sync Schedule Ċ import Ġco . nil in . op ex . bc gateway . core . spi . Wallet Sync Scheduler Handler Ċ import Ġco . nil in . op ex . bc gateway . ports . postgres . dao . Wallet Sync Schedule Repository Ċ import Ġco . nil in . op ex . bc gateway . ports . postgres . model . Wallet Sync Schedule Model Ċ import Ġkotlinx . coroutines . reactive . await First Ċ import Ġkotlinx . coroutines . reactive . await Single OrNull Ċ import Ġorg . springframework . stereotype . Component Ċ import Ġjava . time . LocalDateTime Ċ Ċ @ Component Ċ class ĠWallet Sync Scheduler Handler Impl ( private Ġval Ġwallet Sync Schedule Repository : ĠWallet Sync Schedule Repository ) Ġ: ĊĠĠĠ ĠWallet Sync Scheduler Handler Ġ{ ĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġfetch Active Schedule ( time : ĠLocalDateTime ): ĠWallet Sync Schedule ? Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdao Ġ= Ġwallet Sync Schedule Repository . find Active Schedule ( time ). await Single OrNull () ĊĠĠĠĠĠĠĠ Ġreturn Ġif Ġ( dao Ġ!== Ġnull ) ĠWallet Sync Schedule ( dao . retry Time , Ġdao . delay , Ġdao . batch Size ) Ġelse Ġnull ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġprepare Schedule For Next Try ( sync Schedule : ĠWallet Sync Schedule , Ġtime : ĠLocalDateTime ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdao Ġ= ĠWallet Sync Schedule Model ( 1 , Ġtime , Ġsync Schedule . delay , Ġsync Schedule . batch Size ) ĊĠĠĠĠĠĠĠ Ġwallet Sync Schedule Repository . save ( dao ). await First () ĊĠĠĠ Ġ} Ċ } Ċ