Documentation ¶
Index ¶
- Constants
- Variables
- type Shards
- func (this *Shards) EnsureShard(shardUrl string) (err error)
- func (this *Shards) EnsureShardForUser(userId string) (shardUrl string, err error)
- func (this *Shards) GetShardForUser(userId string) (shardUrl string, err error)
- func (this *Shards) GetShardUserCount() (result map[string]int, err error)
- func (this *Shards) GetShards() (result []string, err error)
- func (this *Shards) RemoveShard(shard string) (err error)
- func (this *Shards) SelectShard() (shardUrl string, err error)
- func (this *Shards) SetShardForUser(userId string, shardAddress string) (err error)
- type Tx
Constants ¶
View Source
const CachePrefix = "user-shard."
View Source
const MaxInt = int(MaxUint >> 1)
View Source
const MaxUint = ^uint(0)
View Source
const MinUint = 0
View Source
const SQLListShards = `SELECT Address FROM Shard`
View Source
const SqlCreateShardTable = `CREATE TABLE IF NOT EXISTS Shard (
Address VARCHAR(255) PRIMARY KEY
);`
View Source
const SqlCreateShardsMappingTable = `` /* 136-byte string literal not displayed */
View Source
const SqlCreateUserShard = "INSERT INTO ShardsMapping (UserId, ShardAddress) VALUES ($1, $2);"
View Source
const SqlDeleteShard = `DELETE FROM Shard WHERE Address = $1;`
View Source
const SqlDeleteShardUsers = "DELETE FROM ShardsMapping WHERE ShardAddress = $1;"
View Source
const SqlDeleteUserShard = "DELETE FROM ShardsMapping WHERE UserId = $1;"
View Source
const SqlEnsureShard = `INSERT INTO Shard(Address) VALUES ($1) ON CONFLICT DO NOTHING;`
View Source
const SqlSelectShardByUser = `SELECT ShardAddress FROM ShardsMapping WHERE UserId = $1;`
View Source
const SqlShardUserCount = `` /* 156-byte string literal not displayed */
Variables ¶
View Source
var ErrorNotFound = errors.New("no shard assigned to user")
Functions ¶
This section is empty.
Types ¶
type Shards ¶
type Shards struct {
// contains filtered or unexported fields
}
func (*Shards) EnsureShard ¶
func (*Shards) EnsureShardForUser ¶
func (*Shards) GetShardForUser ¶
func (*Shards) GetShardUserCount ¶ added in v0.0.2
func (*Shards) RemoveShard ¶
func (*Shards) SelectShard ¶ added in v0.0.2
selects shard with the fewest users
type Tx ¶
type Tx interface { Exec(query string, args ...interface{}) (sql.Result, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) QueryRow(query string, args ...interface{}) *sql.Row QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row }
Click to show internal directories.
Click to hide internal directories.