Skip to content

Commit

Permalink
Refactor Transaction API (and break client-java dependency to server)…
Browse files Browse the repository at this point in the history
… (#4977)

## What is the goal of this PR?

Issue #4513: we need to remove any direct and transitive dependencies from //client-java (`grakn.core.client`) to //server (`grakn.core.server` and `grakn.core.graql`). In order to do that, we need to split Grakn Transaction API (`Session`, `Transaction`, `Keyspace` interfaces`) into a separate module, which does not carry over any external dependency transitively. 

## What are the changes implemented in this PR?

Continuing from PR #4976, this PR fixes #4513, by completing the following changes.
- Replaced all usage of `Transaction` in `//server` and tests with `TransactionOLTP`
- Replaced all usage of `Session` in `//server` and tests with `SessionImpl`
- Replaced the use of `Transaction.Type.<READ|WRITE>` to open transactions with simpler and more robust API: `session.transaction().read()` and `session.transaction().write()`. This avoids client and server transaction users to import and use `Transaction.Type` class which quite frankly complicates the architecture shared between `//client` and `//server`.
- Extracted `Session`, `Transaction` into its own package `//api` (along with `Keyspace` which was moved there in the previous PR).
- Removed `//client-java` dependency onto `//server` - finally.
  • Loading branch information
haikalpribadi authored Feb 27, 2019
1 parent 1cebf9a commit 1eb56b0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ConsoleSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void load(Path filePath) throws IOException {
consoleReader.println("...");
consoleReader.flush();

tx = session.transaction(GraknClient.Transaction.Type.WRITE);
tx = session.transaction().write();

try {
String queries = readFile(filePath);
Expand All @@ -118,7 +118,7 @@ void run() throws IOException, InterruptedException {
consoleReader.setExpandEvents(false); // Disable JLine feature when seeing a '!'
consoleReader.print(COPYRIGHT);

tx = session.transaction(GraknClient.Transaction.Type.WRITE);
tx = session.transaction().write();
String queryString;

while ((queryString = consoleReader.readLine()) != null) {
Expand Down Expand Up @@ -250,7 +250,7 @@ private void clean() throws IOException {

private void reopenTransaction() {
if (!tx.isClosed()) tx.close();
tx = session.transaction(GraknClient.Transaction.Type.WRITE);
tx = session.transaction().write();
}

@Override
Expand Down

0 comments on commit 1eb56b0

Please sign in to comment.