shards

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

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 New

func New(pgConnStr string, cache cache.Cache) (*Shards, error)

func (*Shards) EnsureShard

func (this *Shards) EnsureShard(shardUrl string) (err error)

func (*Shards) EnsureShardForUser

func (this *Shards) EnsureShardForUser(userId string) (shardUrl string, err error)

func (*Shards) GetShardForUser

func (this *Shards) GetShardForUser(userId string) (shardUrl string, err error)

func (*Shards) GetShardUserCount added in v0.0.2

func (this *Shards) GetShardUserCount() (result map[string]int, err error)

func (*Shards) GetShards

func (this *Shards) GetShards() (result []string, err error)

func (*Shards) RemoveShard

func (this *Shards) RemoveShard(shard string) (err error)

func (*Shards) SelectShard added in v0.0.2

func (this *Shards) SelectShard() (shardUrl string, err error)

selects shard with the fewest users

func (*Shards) SetShardForUser

func (this *Shards) SetShardForUser(userId string, shardAddress string) (err error)

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
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL