This file contains hidden or 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 RepeatableReadTransaction(ReadCommittedTransaction): | |
| def record_is_locked(self, record): | |
| return ReadCommittedTransaction.record_is_locked(self, record) or \ | |
| self.table.locks.exists(self, record['id']) | |
| def record_is_visible(self, record): | |
| is_visible = ReadCommittedTransaction.record_is_visible(self, record) | |
| if is_visible: | |
| self.table.locks.add(self, record['id']) | |
This file contains hidden or 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 ReadCommittedTransaction(Transaction): | |
| def record_is_locked(self, record): | |
| return record['expired_xid'] != 0 and \ | |
| row['expired_xid'] in self.table.active_xids | |
| def record_is_visible(self, record): | |
| # The record was created in active transaction that is not our | |
| # own. | |
| if record['created_xid'] in self.table.active_xids and \ | |
| record['created_xid'] != self.xid: |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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) |