Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodolfo committed Nov 17, 2024
1 parent f0af0c8 commit 19199ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/main/kotlin/CrabletImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,21 @@ class CrabletEventsAppender(private val client: Pool) : EventsAppender {
val resultSet = resultQuery.result()
// Extract the result (last_sequence_id) from the first row
val latestSequenceId = resultSet.firstOrNull()?.getLong("last_sequence_id")
connection.close()
if (latestSequenceId != null) {
promise.complete(SequenceNumber(latestSequenceId))
} else {
promise.fail("No last_sequence_id returned from append_events function")
}
} else {
connection.close()
promise.fail(resultQuery.cause())
}
connection.close()
}
} else {
promise.fail(ar.cause())
}
}
return promise.future()

}

}
Expand Down
8 changes: 5 additions & 3 deletions src/main/kotlin/CrabletTest1.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ fun main() {

// append events
eventsAppender.appendIf(eventPayloads, appendCondition)
.map {
.flatMap {
// print the resulting sequenceId
println(it)
println("New sequence id ---> $it")
// now project a state given the past events
stateBuilder.buildFor(sq)
}
.onSuccess { println(it) /* print the new state */ }
.onSuccess { stateResult: Pair<JsonArray, SequenceNumber> ->
println("New state ---> ${stateResult.first.encodePrettily()}")
}
.onFailure { it.printStackTrace() }

}

0 comments on commit 19199ec

Please sign in to comment.