11package com .binaryigor .eventsql ;
22
3- import com .binaryigor .eventsql .internal .EventSQLOps ;
43import com .binaryigor .eventsql .internal .DefaultEventSQLRegistry ;
4+ import com .binaryigor .eventsql .internal .EventSQLOps ;
55import com .binaryigor .eventsql .internal .TopicDefinitionsCache ;
66import com .binaryigor .eventsql .internal .sharded .ShardedEventSQLConsumers ;
77import com .binaryigor .eventsql .internal .sharded .ShardedEventSQLPublisher ;
1818import java .util .ArrayList ;
1919import java .util .Collection ;
2020import java .util .List ;
21- import java .util .Optional ;
21+
22+ import static java .util .Collections .unmodifiableList ;
2223
2324public class EventSQL {
2425
@@ -27,34 +28,20 @@ public class EventSQL {
2728 private final EventSQLConsumers consumers ;
2829
2930 public EventSQL (DataSource dataSource , SQLDialect sqlDialect ) {
30- this (dataSource , sqlDialect , Clock .systemUTC (), Optional . empty () );
31+ this (dataSource , sqlDialect , Clock .systemUTC ());
3132 }
3233
3334 public EventSQL (DataSource dataSource , SQLDialect sqlDialect , Clock clock ) {
34- this (dataSource , sqlDialect , clock , Optional .empty ());
35- }
36-
37- public EventSQL (DataSource dataSource ,
38- SQLDialect sqlDialect ,
39- Clock clock ,
40- Optional <EventSQLConsumers .DLTEventFactory > dltEventFactory ) {
41- this (List .of (dataSource ), sqlDialect , clock , dltEventFactory );
35+ this (List .of (dataSource ), sqlDialect , clock );
4236 }
4337
4438 public EventSQL (Collection <DataSource > dataSources , SQLDialect sqlDialect ) {
45- this (dataSources , sqlDialect , Clock .systemUTC (), Optional . empty () );
39+ this (dataSources , sqlDialect , Clock .systemUTC ());
4640 }
4741
4842 public EventSQL (Collection <DataSource > dataSources ,
4943 SQLDialect sqlDialect ,
5044 Clock clock ) {
51- this (dataSources , sqlDialect , clock , Optional .empty ());
52- }
53-
54- public EventSQL (Collection <DataSource > dataSources ,
55- SQLDialect sqlDialect ,
56- Clock clock ,
57- Optional <EventSQLConsumers .DLTEventFactory > dltEventFactory ) {
5845 if (dataSources .isEmpty ()) {
5946 throw new IllegalArgumentException ("At least one data source is required" );
6047 }
@@ -72,13 +59,12 @@ public EventSQL(Collection<DataSource> dataSources,
7259
7360 var topicRepository = new SqlTopicRepository (transactions );
7461 var consumerRepository = new SqlConsumerRepository (transactions );
75- var eventRepository = new SqlEventRepository (transactions );
62+ var eventRepository = new SqlEventRepository (transactions , sqlDialect );
7663
7764 var registry = new DefaultEventSQLRegistry (topicRepository , eventRepository , consumerRepository , transactions );
7865
7966 var topicDefinitionsCache = new TopicDefinitionsCache (topicRepository );
8067 var ops = new EventSQLOps (topicDefinitionsCache , transactions , consumerRepository , eventRepository , clock );
81- dltEventFactory .ifPresent (ops ::configureDLTEventFactory );
8268
8369 registryList .add (registry );
8470 publisherList .add (ops );
@@ -91,9 +77,9 @@ public EventSQL(Collection<DataSource> dataSources,
9177 publisher = publisherList .getFirst ();
9278 consumers = consumersList .getFirst ();
9379 } else {
94- registry = new ShardedEventSQLRegistry (registryList );
95- publisher = new ShardedEventSQLPublisher (publisherList );
96- consumers = new ShardedEventSQLConsumers (consumersList );
80+ registry = new ShardedEventSQLRegistry (unmodifiableList ( registryList ) );
81+ publisher = new ShardedEventSQLPublisher (unmodifiableList ( publisherList ) );
82+ consumers = new ShardedEventSQLConsumers (unmodifiableList ( consumersList ) );
9783 }
9884 }
9985
0 commit comments