File tree Expand file tree Collapse file tree
test/java/com/github/sttk/sabi/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,6 +17,11 @@ compile() {
1717 errcheck $?
1818}
1919
20+ format () {
21+ mvn spotless:apply
22+ errcheck $?
23+ }
24+
2025test () {
2126 mvn test
2227 errcheck $?
@@ -60,9 +65,9 @@ deploy() {
6065
6166if [[ " $# " == " 0" ]]; then
6267 clean
68+ format
6369 jar
6470 javadoc
65- # trace_test
6671 native_test
6772else
6873 for a in " $@ " ; do
7378 compile)
7479 compile
7580 ;;
81+ format)
82+ format
83+ ;;
7684 test)
7785 test
7886 ;;
8896 sver)
8997 sver $2
9098 ;;
91- ' trace_test ' )
99+ ' trace-test ' )
92100 trace_test
93101 ;;
94102 ' native-test' )
Original file line number Diff line number Diff line change 153153 <artifactId >maven-surefire-plugin</artifactId >
154154 <version >3.5.3</version >
155155 </plugin >
156+ <plugin >
157+ <groupId >com.diffplug.spotless</groupId >
158+ <artifactId >spotless-maven-plugin</artifactId >
159+ <version >2.44.5</version >
160+ <configuration >
161+ <java >
162+ <googleJavaFormat />
163+ </java >
164+ </configuration >
165+ </plugin >
156166 </plugins >
157167 </build >
158168
Original file line number Diff line number Diff line change 44 */
55package com .github .sttk .sabi ;
66
7- import com .github .sttk .errs .Exc ;
8-
9- import java .util .Map ;
10- import java .util .HashMap ;
11-
127public interface AsyncGroup {
138 record RunnerFailed () {}
9+
1410 record RunnerInterrupted () {}
1511
1612 void add (final Runner runner );
Original file line number Diff line number Diff line change 88
99public interface DataConn {
1010 void commit (AsyncGroup ag ) throws Exc ;
11+
1112 default void preCommit (AsyncGroup ag ) throws Exc {}
13+
1214 default void postCommit (AsyncGroup ag ) {}
13- default boolean shouldForceBack () { return false ; }
15+
16+ default boolean shouldForceBack () {
17+ return false ;
18+ }
19+
1420 void rollback (AsyncGroup ag );
21+
1522 default void forceBack (AsyncGroup ag ) {}
23+
1624 void close ();
1725}
Original file line number Diff line number Diff line change 44 */
55package com .github .sttk .sabi ;
66
7- import com .github .sttk .sabi .internal .DataHubInner ;
87import com .github .sttk .errs .Exc ;
8+ import com .github .sttk .sabi .internal .DataHubInner ;
99import java .util .Map ;
10- import java .util .HashMap ;
11- import java .util .concurrent .atomic .AtomicBoolean ;
1210
13- public class DataHub implements DataAcc , AutoCloseable {
11+ public class DataHub implements DataAcc , AutoCloseable {
1412 public record FailToSetupGlobalDataSrcs (Map <String , Exc > errors ) {}
13+
1514 public record FailToSetupLocalDataSrcs (Map <String , Exc > errors ) {}
15+
1616 public record FailToCommitDataConn (Map <String , Exc > errors ) {}
17+
1718 public record FailToPreCommitDataConn (Map <String , Exc > errors ) {}
19+
1820 public record NoDataSrcToCreateDataConn (String name , String dataConnType ) {}
21+
1922 public record FailToCreateDataConn (String name , String dataConnType ) {}
23+
2024 public record CreatedDataConnIsNull (String name , String dataConnType ) {}
25+
2126 public record FailToCastDataConn (String name , String castToType ) {}
27+
2228 public record FailToCastDataHub (String castFromType ) {}
29+
2330 public record RuntimeExceptionOccured () {}
2431
2532 private final DataHubInner inner = new DataHubInner ();
Original file line number Diff line number Diff line change 88
99public interface DataSrc {
1010 void setup (AsyncGroup ag ) throws Exc ;
11+
1112 void close ();
13+
1214 DataConn createDataConn () throws Exc ;
1315}
Original file line number Diff line number Diff line change 66
77import com .github .sttk .errs .Exc ;
88
9- /**
10- * {@code Runner} is the interface that runs any procedure.
11- */
9+ /** {@code Runner} is the interface that runs any procedure. */
1210@ FunctionalInterface
1311public interface Runner {
1412
1513 /**
16- * Runs the procedure that this instance represents.
17- * This method takes no argument and returns nothing.
18- * And this method throws an {@link Exc} exception if this method failed.
14+ * Runs the procedure that this instance represents. This method takes no argument and returns
15+ * nothing. And this method throws an {@link Exc} exception if this method failed.
1916 *
20- * @throws Exc If this method failed.
17+ * @throws Exc If this method failed.
2118 */
2219 void run () throws Exc ;
2320}
Original file line number Diff line number Diff line change 44 */
55package com .github .sttk .sabi ;
66
7- import com .github .sttk .sabi .internal .DataHubInner ;
87import com .github .sttk .errs .Exc ;
9- import java .util .Map ;
10- import java .util .HashMap ;
11- import java .util .concurrent .atomic .AtomicBoolean ;
8+ import com .github .sttk .sabi .internal .DataHubInner ;
129
1310public final class Sabi {
1411 private Sabi () {}
@@ -21,4 +18,3 @@ public static AutoCloseable setup() throws Exc {
2118 return DataHubInner .setupGlobals ();
2219 }
2320}
24-
Original file line number Diff line number Diff line change 77import com .github .sttk .errs .Exc ;
88import com .github .sttk .sabi .AsyncGroup ;
99import com .github .sttk .sabi .Runner ;
10-
1110import java .util .Map ;
12- import java .util .HashMap ;
1311
1412public class AsyncGroupImpl implements AsyncGroup {
1513 private ExcEntry excHead ;
@@ -23,13 +21,16 @@ public AsyncGroupImpl() {}
2321 @ Override
2422 public void add (final Runner runner ) {
2523 final var name = this .name ;
26- var vth = Thread .ofVirtual ().start (() -> {
27- try {
28- runner .run ();
29- } catch (Exc | RuntimeException e ) {
30- addExc (name , e );
31- }
32- });
24+ var vth =
25+ Thread .ofVirtual ()
26+ .start (
27+ () -> {
28+ try {
29+ runner .run ();
30+ } catch (Exc | RuntimeException e ) {
31+ addExc (name , e );
32+ }
33+ });
3334
3435 var ent = new VthEntry (name , vth );
3536 if (this .vthLast == null ) {
@@ -72,7 +73,8 @@ void joinAndIgnoreExcs() {
7273 for (var ent = this .vthHead ; ent != null ; ent = ent .next ) {
7374 try {
7475 ent .thread .join ();
75- } catch (InterruptedException e ) {}
76+ } catch (InterruptedException e ) {
77+ }
7678 }
7779 clear ();
7880 }
Original file line number Diff line number Diff line change 44 */
55package com .github .sttk .sabi .internal ;
66
7- import com .github .sttk .errs .Exc ;
8-
97public class DataConnList {
108 DataConnContainer head ;
119 DataConnContainer last ;
You can’t perform that action at this time.
0 commit comments