Documentation ¶
Overview ¶
Package topoproto contains utility functions to deal with the proto3 structures defined in proto/topodata.
Index ¶
- Variables
- func IsTypeInList(tabletType topodatapb.TabletType, types []topodatapb.TabletType) bool
- func KeyspaceShardString(keyspace, shard string) string
- func MakeStringTypeList(types []topodatapb.TabletType) []string
- func ParseKeyspaceShard(param string) (string, string, error)
- func ParseTabletAlias(aliasStr string) (*topodatapb.TabletAlias, error)
- func ParseTabletType(param string) (topodatapb.TabletType, error)
- func ParseUID(value string) (uint32, error)
- func ShardHasCell(shard *topodatapb.Shard, cell string) bool
- func SourceShardAsHTML(source *topodatapb.Shard_SourceShard) template.HTML
- func SourceShardString(source *topodatapb.Shard_SourceShard) string
- func SrvKeyspaceGetPartition(sk *topodatapb.SrvKeyspace, tabletType topodatapb.TabletType) *topodatapb.SrvKeyspace_KeyspacePartition
- func TabletAddr(tablet *topodatapb.Tablet) string
- func TabletAliasEqual(left, right *topodatapb.TabletAlias) bool
- func TabletAliasIsZero(ta *topodatapb.TabletAlias) bool
- func TabletAliasString(ta *topodatapb.TabletAlias) string
- func TabletAliasUIDStr(ta *topodatapb.TabletAlias) string
- func TabletDbName(tablet *topodatapb.Tablet) string
- func TabletIsAssigned(tablet *topodatapb.Tablet) bool
- func TabletTypeLString(tabletType topodatapb.TabletType) string
- type ShardReferenceArray
- type TabletAliasList
Constants ¶
This section is empty.
Variables ¶
var AllTabletTypes = []topodatapb.TabletType{ topodatapb.TabletType_MASTER, topodatapb.TabletType_REPLICA, topodatapb.TabletType_RDONLY, topodatapb.TabletType_BATCH, topodatapb.TabletType_SPARE, topodatapb.TabletType_EXPERIMENTAL, topodatapb.TabletType_BACKUP, topodatapb.TabletType_RESTORE, topodatapb.TabletType_DRAINED, }
AllTabletTypes lists all the possible tablet types
var SlaveTabletTypes = []topodatapb.TabletType{ topodatapb.TabletType_REPLICA, topodatapb.TabletType_RDONLY, topodatapb.TabletType_BATCH, topodatapb.TabletType_SPARE, topodatapb.TabletType_EXPERIMENTAL, topodatapb.TabletType_BACKUP, topodatapb.TabletType_RESTORE, topodatapb.TabletType_DRAINED, }
SlaveTabletTypes contains all the tablet type that can have replication enabled.
Functions ¶
func IsTypeInList ¶
func IsTypeInList(tabletType topodatapb.TabletType, types []topodatapb.TabletType) bool
IsTypeInList returns true if the given type is in the list. Use it with AllTabletType and SlaveTabletType for instance.
func KeyspaceShardString ¶
KeyspaceShardString returns a "keyspace/shard" string taking keyspace and shard as separate inputs.
func MakeStringTypeList ¶
func MakeStringTypeList(types []topodatapb.TabletType) []string
MakeStringTypeList returns a list of strings that match the input list.
func ParseKeyspaceShard ¶
ParseKeyspaceShard parse a "keyspace/shard" string and extract both keyspace and shard
func ParseTabletAlias ¶
func ParseTabletAlias(aliasStr string) (*topodatapb.TabletAlias, error)
ParseTabletAlias returns a TabletAlias for the input string, of the form <cell>-<uid>
func ParseTabletType ¶
func ParseTabletType(param string) (topodatapb.TabletType, error)
ParseTabletType parses the tablet type into the enum
func ShardHasCell ¶
func ShardHasCell(shard *topodatapb.Shard, cell string) bool
ShardHasCell returns true if the cell is listed in the Cells for the shard.
func SourceShardAsHTML ¶
func SourceShardAsHTML(source *topodatapb.Shard_SourceShard) template.HTML
SourceShardAsHTML returns a HTML version of the object.
func SourceShardString ¶
func SourceShardString(source *topodatapb.Shard_SourceShard) string
SourceShardString returns a printable view of a SourceShard.
func SrvKeyspaceGetPartition ¶
func SrvKeyspaceGetPartition(sk *topodatapb.SrvKeyspace, tabletType topodatapb.TabletType) *topodatapb.SrvKeyspace_KeyspacePartition
SrvKeyspaceGetPartition returns a Partition for the given tablet type, or nil if it's not there.
func TabletAddr ¶
func TabletAddr(tablet *topodatapb.Tablet) string
TabletAddr returns hostname:vt port associated with a tablet
func TabletAliasEqual ¶
func TabletAliasEqual(left, right *topodatapb.TabletAlias) bool
TabletAliasEqual returns true if two TabletAlias match
func TabletAliasIsZero ¶
func TabletAliasIsZero(ta *topodatapb.TabletAlias) bool
TabletAliasIsZero returns true iff cell and uid are empty
func TabletAliasString ¶
func TabletAliasString(ta *topodatapb.TabletAlias) string
TabletAliasString formats a TabletAlias
func TabletAliasUIDStr ¶
func TabletAliasUIDStr(ta *topodatapb.TabletAlias) string
TabletAliasUIDStr returns a string version of the uid
func TabletDbName ¶
func TabletDbName(tablet *topodatapb.Tablet) string
TabletDbName is usually implied by keyspace. Having the shard information in the database name complicates mysql replication.
func TabletIsAssigned ¶
func TabletIsAssigned(tablet *topodatapb.Tablet) bool
TabletIsAssigned returns if this tablet is assigned to a keyspace and shard. A "scrap" node will show up as assigned even though its data cannot be used for serving.
func TabletTypeLString ¶
func TabletTypeLString(tabletType topodatapb.TabletType) string
TabletTypeLString returns a lower case version of the tablet type, or "unknown" if not known.
Types ¶
type ShardReferenceArray ¶
type ShardReferenceArray []*topodatapb.ShardReference
ShardReferenceArray is used for sorting ShardReference arrays
func (ShardReferenceArray) Len ¶
func (sra ShardReferenceArray) Len() int
Len implements sort.Interface
func (ShardReferenceArray) Less ¶
func (sra ShardReferenceArray) Less(i, j int) bool
Len implements sort.Interface
func (ShardReferenceArray) Sort ¶
func (sra ShardReferenceArray) Sort()
Sort will sort the list according to KeyRange.Start
func (ShardReferenceArray) Swap ¶
func (sra ShardReferenceArray) Swap(i, j int)
Len implements sort.Interface
type TabletAliasList ¶
type TabletAliasList []*topodatapb.TabletAlias
TabletAliasList is used mainly for sorting
func (TabletAliasList) Less ¶
func (tal TabletAliasList) Less(i, j int) bool
Less is part of sort.Interface
func (TabletAliasList) Swap ¶
func (tal TabletAliasList) Swap(i, j int)
Swap is part of sort.Interface