Documentation ¶
Overview ¶
Package topoproto contains utility functions to deal with the proto3 structures defined in proto/topodata.
Index ¶
- Constants
- Variables
- func IsServingType(tabletType topodatapb.TabletType) bool
- func IsTabletInList(tablet *topodatapb.Tablet, allTablets []*topodatapb.Tablet) bool
- func IsTypeInList(tabletType topodatapb.TabletType, types []topodatapb.TabletType) bool
- func KeyspaceShardString(keyspace, shard string) string
- func KeyspaceTypeLString(kt topodatapb.KeyspaceType) string
- func KeyspaceTypeString(kt topodatapb.KeyspaceType) string
- func MakeStringTypeCSV(types []topodatapb.TabletType) string
- func MakeStringTypeList(types []topodatapb.TabletType) []string
- func MakeStringTypeUnsortedList(types []topodatapb.TabletType) []string
- func MakeUniqueStringTypeList(types []topodatapb.TabletType) []string
- func MySQLIP(tablet *topodatapb.Tablet) (string, error)
- func MysqlAddr(tablet *topodatapb.Tablet) string
- func ParseDestination(targetString string, defaultTabletType topodatapb.TabletType) (string, topodatapb.TabletType, key.Destination, error)
- func ParseKeyspaceShard(param string) (string, string, error)
- func ParseKeyspaceType(param string) (topodatapb.KeyspaceType, error)
- func ParseTabletAlias(aliasStr string) (*topodatapb.TabletAlias, error)
- func ParseTabletSet(tabletListStr string) sets.Set[string]
- func ParseTabletType(param string) (topodatapb.TabletType, error)
- func ParseTabletTypes(param string) ([]topodatapb.TabletType, error)
- func ParseUID(value string) (uint32, error)
- func ShardReplicationErrorTypeString(t topodatapb.ShardReplicationError_Type) string
- func SrvKeyspaceGetPartition(sk *topodatapb.SrvKeyspace, tabletType topodatapb.TabletType) *topodatapb.SrvKeyspace_KeyspacePartition
- func TabletAliasEqual(left, right *topodatapb.TabletAlias) bool
- func TabletAliasIsZero(ta *topodatapb.TabletAlias) bool
- func TabletAliasString(ta *topodatapb.TabletAlias) string
- func TabletDbName(tablet *topodatapb.Tablet) string
- func TabletTypeLString(tabletType topodatapb.TabletType) string
- type ShardReferenceArray
- type TabletAliasList
- type TabletTypeFlag
- type TabletTypeListFlag
Constants ¶
const (
// VtDbPrefix + keyspace is the default name for databases.
VtDbPrefix = "vt_"
)
Variables ¶
var AllTabletTypes = []topodatapb.TabletType{ topodatapb.TabletType_PRIMARY, 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
Functions ¶
func IsServingType ¶ added in v0.12.0
func IsServingType(tabletType topodatapb.TabletType) bool
IsServingType returns true if the tablet type is one that should be serving to be healthy, or false if the tablet type should not be serving in it's healthy state.
func IsTabletInList ¶ added in v0.14.0
func IsTabletInList(tablet *topodatapb.Tablet, allTablets []*topodatapb.Tablet) bool
IsTabletInList returns true if the tablet is in the list of tablets given
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 AllTabletTypes for instance.
func KeyspaceShardString ¶
KeyspaceShardString returns a "keyspace/shard" string taking keyspace and shard as separate inputs.
func KeyspaceTypeLString ¶ added in v0.11.0
func KeyspaceTypeLString(kt topodatapb.KeyspaceType) string
KeyspaceTypeLString returns the lowercased string representation of a KeyspaceType.
func KeyspaceTypeString ¶ added in v0.10.0
func KeyspaceTypeString(kt topodatapb.KeyspaceType) string
KeyspaceTypeString returns the string representation of a KeyspaceType.
func MakeStringTypeCSV ¶ added in v0.18.0
func MakeStringTypeCSV(types []topodatapb.TabletType) string
MakeStringTypeCSV returns the tablet types in CSV format.
func MakeStringTypeList ¶
func MakeStringTypeList(types []topodatapb.TabletType) []string
MakeStringTypeList returns a list of strings that match the input list.
func MakeStringTypeUnsortedList ¶ added in v0.18.0
func MakeStringTypeUnsortedList(types []topodatapb.TabletType) []string
MakeStringTypeUnsortedList returns a list of strings that match the input without modifying the order in the list.
func MakeUniqueStringTypeList ¶ added in v0.17.0
func MakeUniqueStringTypeList(types []topodatapb.TabletType) []string
MakeUniqueStringTypeList returns a unique list of strings that match the input list -- with duplicate types removed. This is needed as some types are aliases for others, like BATCH and RDONLY, so e.g. rdonly shows up twice in the list when using AllTabletTypes.
func MySQLIP ¶
func MySQLIP(tablet *topodatapb.Tablet) (string, error)
MySQLIP returns the MySQL server's IP by resolving the hostname.
func MysqlAddr ¶
func MysqlAddr(tablet *topodatapb.Tablet) string
MysqlAddr returns the host:port of the mysql server.
func ParseDestination ¶
func ParseDestination(targetString string, defaultTabletType topodatapb.TabletType) (string, topodatapb.TabletType, key.Destination, error)
ParseDestination parses the string representation of a Destination of the form keyspace:shard@tablet_type. You can use a / instead of a :.
func ParseKeyspaceShard ¶
ParseKeyspaceShard parse a "keyspace/shard" or "keyspace:shard" string and extract both keyspace and shard
func ParseKeyspaceType ¶
func ParseKeyspaceType(param string) (topodatapb.KeyspaceType, error)
ParseKeyspaceType parses a string into a KeyspaceType.
func ParseTabletAlias ¶
func ParseTabletAlias(aliasStr string) (*topodatapb.TabletAlias, error)
ParseTabletAlias returns a TabletAlias for the input string, of the form <cell>-<uid>
func ParseTabletSet ¶ added in v0.8.0
ParseTabletSet returns a set of tablets based on a provided comma separated list of tablets.
func ParseTabletType ¶
func ParseTabletType(param string) (topodatapb.TabletType, error)
ParseTabletType parses the tablet type into the enum.
func ParseTabletTypes ¶
func ParseTabletTypes(param string) ([]topodatapb.TabletType, error)
ParseTabletTypes parses a comma separated list of tablet types and returns a slice with the respective enums.
func ShardReplicationErrorTypeString ¶ added in v0.14.0
func ShardReplicationErrorTypeString(t topodatapb.ShardReplicationError_Type) string
ShardReplicationErrorTypeString returns a string representation of the ShardReplicationError type, or "UNKNOWN" if not known.
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 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 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 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
Less 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)
Swap 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
func (TabletAliasList) ToStringSlice ¶ added in v0.10.0
func (tal TabletAliasList) ToStringSlice() []string
ToStringSlice returns a slice which is the result of mapping TabletAliasString over a slice of TabletAliases.
type TabletTypeFlag ¶
type TabletTypeFlag topodatapb.TabletType
TabletTypeFlag implements the pflag.Value interface, for parsing a command-line value into a TabletType.
func (*TabletTypeFlag) Set ¶
func (ttf *TabletTypeFlag) Set(v string) error
Set is part of the pflag.Value interfaces.
func (*TabletTypeFlag) String ¶
func (ttf *TabletTypeFlag) String() string
String is part of the pflag.Value interfaces.
func (*TabletTypeFlag) Type ¶ added in v0.15.0
func (*TabletTypeFlag) Type() string
Type is part of the pflag.Value interface.
type TabletTypeListFlag ¶ added in v0.15.0
type TabletTypeListFlag []topodatapb.TabletType
TabletTypeListFlag implements the pflag.Value interface, for parsing a command-line comma-separated list of values into a slice of TabletTypes.
func (*TabletTypeListFlag) Set ¶ added in v0.15.0
func (ttlv *TabletTypeListFlag) Set(v string) (err error)
Set is part of the pflag.Value interface.
func (*TabletTypeListFlag) String ¶ added in v0.15.0
func (ttlv *TabletTypeListFlag) String() string
String is part of the pflag.Value interface.
func (*TabletTypeListFlag) Type ¶ added in v0.15.0
func (ttlv *TabletTypeListFlag) Type() string
Type is part of the pflag.Value interface.