This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Installs the QLDB Shell on AWS CloudShell | |
VERSION="2.0.0-alpha3" | |
sudo yum install -y -q openssl11-libs | |
mkdir qldb | |
curl -sL https://github.com/awslabs/amazon-qldb-shell/releases/download/v$VERSION/qldb-v$VERSION-linux.tar.gz | tar zx -C qldb && export PATH=$PATH:~/qldb/qldb-v$VERSION-linux | |
echo "Run qldb --ledger <your-ledger> to start the shell" | |
echo "Run \`echo \"export PATH=\$PATH:~/qldb/qldb-v$VERSION-linux\" >> ~/.bashrc\` to append this to your path" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function betterGrabMovieTickets(qldb: QldbDriver, seat: string) { | |
const [allocationTime, message] = | |
await qldb.executeLambda( async txn => { | |
const result = await txn.execute( | |
"select * from Showing where seat = ? and allocated = ?", | |
seat, false); | |
const allocationTime = Date.now(); | |
if (result.getResultList().length === 1) { | |
await txn.execute( | |
"update Showing set allocated = ? where seat = ?", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let state = { seat: "a5" }; | |
async function badGrabMovieTickets(qldb: QldbDriver) { | |
// DO NOT USE: This code is deliberately wrong to show what pitfalls to avoid | |
let allocationTime; | |
await qldb.executeLambda(async txn => { | |
// BAD: don't rely on state from outside the function parameters | |
const result = await txn.execute( | |
"select * from Showing where seat = ? and allocated = ?", | |
state.seat, false); | |
// BAD: cannot change external state from inside the function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function grabMovieTickets(qldb: QldbDriver, seat: string) { | |
await qldb.executeLambda(async txn => { | |
const result = await txn.execute( | |
"select * from Showing where seat = ? and allocated = ?", | |
seat, false); | |
if (result.getResultList().length === 1) { | |
await txn.execute( | |
"update Showing set allocated = ? where seat = ?", | |
true, seat); | |
return "you got the seat!"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Scala code: | |
// | |
// trait MyTrait { | |
// def someImplementation() = { | |
// println("Implementation in an interface") | |
// } | |
// | |
// def pureVirtualFuntion() | |
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | |
AAAA2AAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5vdCBiZSBydW4gaW4gRE9TIG1v | |
ZGUuDQ0KJAAAAAAAAAB6U0p8PjIkLz4yJC8+MiQvvS4qLyoyJC8IFC4vBDIkLz4yJS90MiQvXC03 | |
LzsyJC8IFC8vPDIkL/k0Ii8/MiQvwRIgLz8yJC9SaWNoPjIkLwAAAAAAAAAAUEUAAEwBBQDdZZpR | |
AAAAAAAAAADgAA4hCwEGAABQAAAAcAAAAAAAAMgYAAAAEAAAAGAAAAAAABAAEAAAABAAAAQAAAAA | |
AAAABAAAAAAAAAAA0AAAABAAAAAAAAACAAAAAAAQAAAQAAAAABAAABAAAAAAAAAQAAAAsGsAAF0B | |
AAAwZgAAPAAAAACwAAB4CgAAAAAAAAAAAAAAAAAAAAAAAADAAABYBQAAAAAAAAAAAAAAAAAAAAAA | |
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAPQAAAAAAAAAAAAAAAAAAAAAAAAA | |
AAAAAAAAAAAudGV4dAAAAApFAAAAEAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAgAABgLnJkYXRhAAAN | |
DQAAAGAAAAAQAAAAYAAAAAAAAAAAAAAAAAAAQAAAQC5kYXRhAAAAxDIAAABwAAAAMAAAAHAAAAAA |