-
Notifications
You must be signed in to change notification settings - Fork 12
/
ReplicaConsistency.java
40 lines (34 loc) · 1.07 KB
/
ReplicaConsistency.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.atlassian.db.replica.spi;
import com.atlassian.db.replica.internal.util.ThreadSafe;
import java.sql.Connection;
import java.util.function.Supplier;
/**
* Tracks data consistency between replica and main databases.
*/
@ThreadSafe
public interface ReplicaConsistency {
/**
* Informs that {@code main} received an UPDATE, INSERT or DELETE or transaction commit
* when in a transaction.
*
* @param main connects to the main database
*/
void write(Connection main);
/**
* Invoked just before transaction commit.
* <p>
* Notice: The method will not handle all writes. Writes done outside of a transaction
* needs to be handled in `ReplicaConnection#write`.
*
* @param main connects to the main database
*/
default void preCommit(Connection main) {
}
/**
* Judges if {@code replica} is ready to be queried.
*
* @param replica connects to the replica database
* @return true if {@code replica} is consistent with main
*/
boolean isConsistent(Supplier<Connection> replica);
}