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
class ReadUncommittedTransaction(Transaction): | |
def record_is_locked(self, record): | |
return record['expired_xid'] != 0 | |
def record_is_visible(self, record): | |
return record['expired_xid'] == 0 |
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
class RollbackException(Exception): | |
pass |
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
class Transaction: | |
def __init__(self, table, xid): | |
self.table = table | |
self.xid = xid | |
self.rollback_actions = [] | |
def add_record(self, id, name): | |
record = { | |
'id': id, | |
'name': name, |
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
import "golang.org/x/crypto/bcrypt" | |
// CheckPassword is used for Basic authentication to check the secret. The logic | |
// has been copied from the existing implementation in: | |
// | |
// protected/models/traits/HasPassword.php | |
// | |
// The PHP source code will be copied verbatim here, just in case something | |
// changes it can be compared: | |
// |
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
package main | |
import ( | |
"fmt" | |
"strings" | |
"sync" | |
"time" | |
) | |
type ChannelPerf struct { |
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
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func BatchStrings(values <-chan string, maxItems int, maxTimeout time.Duration) chan []string { | |
batches := make(chan []string) |
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
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func BatchStrings(values <-chan string, maxItems int, maxTimeout time.Duration) chan []string { | |
batches := make(chan []string) |
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
package main | |
import ( | |
"context" | |
"fmt" | |
"time" | |
) | |
func BatchStringsCtx(ctx context.Context, values <-chan string, maxItems int, maxTimeout time.Duration) chan []string { | |
batches := make(chan []string) |
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
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func BatchStrings(values <-chan string, maxItems int, maxTimeout time.Duration) chan []string { | |
batches := make(chan []string) |
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
{ | |
"foo": "bar", | |
"baz": 123 | |
} |