/* Ċ Ġ* ĠCopyright Ġ 2 0 1 8 ĠNet flix , ĠInc . Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ package Ġcom . netflix . spin n aker . config Ċ Ċ import Ġcom . fasterxml . jackson . databind . ObjectMapper Ċ import Ġcom . netflix . spect ator . api . Registry Ċ import Ġcom . netflix . spin n aker . clo udd river . data . task . Task Repository Ċ import Ġcom . netflix . spin n aker . clo udd river . event . persistence . Event Repository Ċ import Ġcom . netflix . spin n aker . clo udd river . sql . Sql Provider Ċ import Ġcom . netflix . spin n aker . clo udd river . sql . Sql Task Cleanup Agent Ċ import Ġcom . netflix . spin n aker . clo udd river . sql . Sql Task Repository Ċ import Ġcom . netflix . spin n aker . clo udd river . sql . event . Sql Event Cleanup Agent Ċ import Ġcom . netflix . spin n aker . clo udd river . sql . event . Sql Event Repository Ċ import Ġcom . netflix . spin n aker . k ork . jackson . ObjectMapper Subtype Configurer Ċ import Ġcom . netflix . spin n aker . k ork . jackson . ObjectMapper Subtype Configurer . Subtype Locator Ċ import Ġcom . netflix . spin n aker . k ork . sql . config . Default Sql Configuration Ċ import Ġcom . netflix . spin n aker . k ork . sql . config . Sql Properties Ċ import Ġcom . netflix . spin n aker . k ork . telemetry . Instrument ed Proxy Ċ import Ġcom . netflix . spin n aker . k ork . version . Service Version Ċ import Ġio . github . res il ience 4 j . retry . Retry Registry Ċ import Ġorg . jooq . DSL Context Ċ import Ġorg . springframework . boot . autoconfigure . condition . Conditional On Expression Ċ import Ġorg . springframework . boot . autoconfigure . condition . Conditional On Property Ċ import Ġorg . springframework . boot . context . properties . Enable Configuration Properties Ċ import Ġorg . springframework . context . Application Event Publisher Ċ import Ġorg . springframework . context . annotation . Bean Ċ import Ġorg . springframework . context . annotation . Configuration Ċ import Ġorg . springframework . context . annotation . Import Ċ import Ġorg . springframework . validation . Validator Ċ import Ġjava . time . Clock Ċ Ċ @ Configuration Ċ @ Conditional On Property (" sql . enabled ") Ċ @ Import ( Default Sql Configuration :: class ) Ċ @ Enable Configuration Properties ( Sql Task Cleanup Agent Properties :: class , ĠSql Event Cleanup Agent Config Properties :: class ) Ċ class ĠSql Configuration Ġ{ ĊĊĠ Ġ@ Bean ĊĠ Ġ@ Conditional On Property (" sql . task - repository . enabled ") ĊĠ Ġfun Ġsql Task Repository ( ĊĠĠĠ Ġj oo q : ĠDSL Context , ĊĠĠĠ Ġclock : ĠClock , ĊĠĠĠ Ġsql Properties : ĠSql Properties ĊĠ Ġ): ĠTask Repository Ġ= ĊĠĠĠ ĠSql Task Repository ( jooq , ĠObjectMapper (), Ġclock , Ġsql Properties . retries ) ĊĊĠ Ġ@ Bean ĊĠ Ġ@ Conditional On Property (" sql . task - repository . enabled ") ĊĠ Ġ@ Conditional On Expression ("\ ${ sql . read - only : false } Ġ== Ġfalse ") ĊĠ Ġfun Ġsql Task Cleanup Agent ( ĊĠĠĠ Ġj oo q : ĠDSL Context , ĊĠĠĠ Ġclock : ĠClock , ĊĠĠĠ Ġregistry : ĠRegistry , ĊĠĠĠ Ġproperties : ĠSql Task Cleanup Agent Properties , ĊĠĠĠ Ġsql Properties : ĠSql Properties ĊĠ Ġ): ĠSql Task Cleanup Agent Ġ= ĊĠĠĠ ĠSql Task Cleanup Agent ( jooq , Ġclock , Ġregistry , Ġproperties , Ġsql Properties . retries ) ĊĊĠ Ġ@ Bean ĊĠ Ġ@ Conditional On Property (" sql . task - repository . enabled ") ĊĠ Ġ@ Conditional On Expression ("\ ${ sql . read - only : false } Ġ== Ġfalse ") ĊĠ Ġfun Ġsql Provider ( sql Task Cleanup Agent : ĠSql Task Cleanup Agent ): ĠSql Provider Ġ= ĊĠĠĠ ĠSql Provider ( mutable ListOf ( sql Task Cleanup Agent )) ĊĊĠ Ġ@ Bean ĊĠ Ġfun Ġsql Event Repository ( ĊĠĠĠ Ġj oo q : ĠDSL Context , ĊĠĠĠ Ġsql Properties : ĠSql Properties , ĊĠĠĠ Ġservice Version : ĠService Version , ĊĠĠĠ ĠobjectMapper : ĠObjectMapper , ĊĠĠĠ Ġapplication Event Publisher : ĠApplication Event Publisher , ĊĠĠĠ Ġregistry : ĠRegistry , ĊĠĠĠ Ġdefault Validator : ĠValidator , ĊĠĠĠ Ġretry Registry : ĠRetry Registry , ĊĠĠĠ Ġsubtype Loc ators : ĠList < Subtype Locator > ĊĠ Ġ): ĠEvent Repository Ġ{ ĊĠĠĠ Ġ// ĠTODO ( rz ): ĠObjectMapper Subtype Configurer Ġshould Ġbecome Ġa Ġstandard Ġk ork Ġfeature . ĠThis Ġis Ġpretty Ġg ross . ĊĠĠĠ ĠObjectMapper Subtype Configurer ( true ). register Sub types ( object Mapper , Ġsubtype Loc ators ) ĊĠĠĠ Ġreturn ĠSql Event Repository ( ĊĠĠĠĠĠ Ġj oo q , ĊĠĠĠĠĠ Ġsql Properties , ĊĠĠĠĠĠ Ġservice Version , ĊĠĠĠĠĠ ĠobjectMapper , ĊĠĠĠĠĠ Ġapplication Event Publisher , ĊĠĠĠĠĠ Ġregistry , ĊĠĠĠĠĠ Ġdefault Validator , ĊĠĠĠĠĠ Ġretry Registry ĊĠĠĠ Ġ). let Ġ{ ĊĠĠĠĠĠ ĠInstrument ed Proxy . proxy ( registry , Ġit , Ġ" event Repository ", Ġmap Of (" backend " Ġto Ġ" sql ")) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Bean ĊĠ Ġfun Ġsql Event Cleanup Agent ( ĊĠĠĠ Ġj oo q : ĠDSL Context , ĊĠĠĠ Ġregistry : ĠRegistry , ĊĠĠĠ Ġproperties : ĠSql Event Cleanup Agent Config Properties ĊĠ Ġ): ĠSql Event Cleanup Agent Ġ{ ĊĠĠĠ Ġreturn ĠSql Event Cleanup Agent ( jooq , Ġregistry , Ġproperties ) ĊĠ Ġ} Ċ } Ċ