shards

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 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 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) GetShards

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

func (*Shards) SetShardForUser

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

type StaticShard

type StaticShard string

func (StaticShard) GetShardForUser

func (this StaticShard) GetShardForUser(userId string) (shardUrl string, err error)

func (StaticShard) GetShards

func (this StaticShard) GetShards() (result []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
}

Jump to

Keyboard shortcuts

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