зеркало из https://github.com/github/vitess-gh.git
all: gofmt -w -r 'interface{} -> any' src
Signed-off-by: Vicent Marti <vmg@strn.cat>
This commit is contained in:
Родитель
891bdd3033
Коммит
8de235531d
|
@ -30,7 +30,7 @@ func newSizedPool(size int) *sizedPool {
|
|||
return &sizedPool{
|
||||
size: size,
|
||||
pool: sync.Pool{
|
||||
New: func() interface{} { return makeSlicePointer(size) },
|
||||
New: func() any { return makeSlicePointer(size) },
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ package cache
|
|||
// Cache is a generic interface type for a data structure that keeps recently used
|
||||
// objects in memory and evicts them when it becomes full.
|
||||
type Cache interface {
|
||||
Get(key string) (interface{}, bool)
|
||||
Set(key string, val interface{}) bool
|
||||
ForEach(callback func(interface{}) bool)
|
||||
Get(key string) (any, bool)
|
||||
Set(key string, val any) bool
|
||||
ForEach(callback func(any) bool)
|
||||
|
||||
Delete(key string)
|
||||
Clear()
|
||||
|
@ -56,7 +56,7 @@ func NewDefaultCacheImpl(cfg *Config) Cache {
|
|||
if cfg.MaxEntries == 0 || cfg.MaxMemoryUsage == 0 {
|
||||
return &nullCache{}
|
||||
}
|
||||
return NewRistrettoCache(cfg.MaxEntries, cfg.MaxMemoryUsage, func(val interface{}) int64 {
|
||||
return NewRistrettoCache(cfg.MaxEntries, cfg.MaxMemoryUsage, func(val any) int64 {
|
||||
return val.(cachedObject).CachedSize(true)
|
||||
})
|
||||
|
||||
|
@ -64,7 +64,7 @@ func NewDefaultCacheImpl(cfg *Config) Cache {
|
|||
if cfg.MaxEntries == 0 {
|
||||
return &nullCache{}
|
||||
}
|
||||
return NewLRUCache(cfg.MaxEntries, func(_ interface{}) int64 {
|
||||
return NewLRUCache(cfg.MaxEntries, func(_ any) int64 {
|
||||
return 1
|
||||
})
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ type LRUCache struct {
|
|||
// list & table contain *entry objects.
|
||||
list *list.List
|
||||
table map[string]*list.Element
|
||||
cost func(interface{}) int64
|
||||
cost func(any) int64
|
||||
|
||||
size int64
|
||||
capacity int64
|
||||
|
@ -53,18 +53,18 @@ type LRUCache struct {
|
|||
// Item is what is stored in the cache
|
||||
type Item struct {
|
||||
Key string
|
||||
Value interface{}
|
||||
Value any
|
||||
}
|
||||
|
||||
type entry struct {
|
||||
key string
|
||||
value interface{}
|
||||
value any
|
||||
size int64
|
||||
timeAccessed time.Time
|
||||
}
|
||||
|
||||
// NewLRUCache creates a new empty cache with the given capacity.
|
||||
func NewLRUCache(capacity int64, cost func(interface{}) int64) *LRUCache {
|
||||
func NewLRUCache(capacity int64, cost func(any) int64) *LRUCache {
|
||||
return &LRUCache{
|
||||
list: list.New(),
|
||||
table: make(map[string]*list.Element),
|
||||
|
@ -75,7 +75,7 @@ func NewLRUCache(capacity int64, cost func(interface{}) int64) *LRUCache {
|
|||
|
||||
// Get returns a value from the cache, and marks the entry as most
|
||||
// recently used.
|
||||
func (lru *LRUCache) Get(key string) (v interface{}, ok bool) {
|
||||
func (lru *LRUCache) Get(key string) (v any, ok bool) {
|
||||
lru.mu.Lock()
|
||||
defer lru.mu.Unlock()
|
||||
|
||||
|
@ -90,7 +90,7 @@ func (lru *LRUCache) Get(key string) (v interface{}, ok bool) {
|
|||
}
|
||||
|
||||
// Set sets a value in the cache.
|
||||
func (lru *LRUCache) Set(key string, value interface{}) bool {
|
||||
func (lru *LRUCache) Set(key string, value any) bool {
|
||||
lru.mu.Lock()
|
||||
defer lru.mu.Unlock()
|
||||
|
||||
|
@ -190,7 +190,7 @@ func (lru *LRUCache) Misses() int64 {
|
|||
|
||||
// ForEach yields all the values for the cache, ordered from most recently
|
||||
// used to least recently used.
|
||||
func (lru *LRUCache) ForEach(callback func(value interface{}) bool) {
|
||||
func (lru *LRUCache) ForEach(callback func(value any) bool) {
|
||||
lru.mu.Lock()
|
||||
defer lru.mu.Unlock()
|
||||
|
||||
|
@ -216,7 +216,7 @@ func (lru *LRUCache) Items() []Item {
|
|||
return items
|
||||
}
|
||||
|
||||
func (lru *LRUCache) updateInplace(element *list.Element, value interface{}) {
|
||||
func (lru *LRUCache) updateInplace(element *list.Element, value any) {
|
||||
valueSize := lru.cost(value)
|
||||
sizeDiff := valueSize - element.Value.(*entry).size
|
||||
element.Value.(*entry).value = value
|
||||
|
@ -231,7 +231,7 @@ func (lru *LRUCache) moveToFront(element *list.Element) {
|
|||
element.Value.(*entry).timeAccessed = time.Now()
|
||||
}
|
||||
|
||||
func (lru *LRUCache) addNew(key string, value interface{}) {
|
||||
func (lru *LRUCache) addNew(key string, value any) {
|
||||
newEntry := &entry{key, value, lru.cost(value), time.Now()}
|
||||
element := lru.list.PushFront(newEntry)
|
||||
lru.table[key] = element
|
||||
|
|
|
@ -24,7 +24,7 @@ type CacheValue struct {
|
|||
size int64
|
||||
}
|
||||
|
||||
func cacheValueSize(val interface{}) int64 {
|
||||
func cacheValueSize(val any) int64 {
|
||||
return val.(*CacheValue).size
|
||||
}
|
||||
|
||||
|
|
|
@ -20,17 +20,17 @@ package cache
|
|||
type nullCache struct{}
|
||||
|
||||
// Get never returns anything on the nullCache
|
||||
func (n *nullCache) Get(_ string) (interface{}, bool) {
|
||||
func (n *nullCache) Get(_ string) (any, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// Set is a no-op in the nullCache
|
||||
func (n *nullCache) Set(_ string, _ interface{}) bool {
|
||||
func (n *nullCache) Set(_ string, _ any) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// ForEach iterates the nullCache, which is always empty
|
||||
func (n *nullCache) ForEach(_ func(interface{}) bool) {}
|
||||
func (n *nullCache) ForEach(_ func(any) bool) {}
|
||||
|
||||
// Delete is a no-op in the nullCache
|
||||
func (n *nullCache) Delete(_ string) {}
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
)
|
||||
|
||||
func BenchmarkGet(b *testing.B) {
|
||||
cache := NewLRUCache(64*1024*1024, func(val interface{}) int64 {
|
||||
cache := NewLRUCache(64*1024*1024, func(val any) int64 {
|
||||
return int64(cap(val.([]byte)))
|
||||
})
|
||||
value := make([]byte, 1000)
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
var _ Cache = &ristretto.Cache{}
|
||||
|
||||
// NewRistrettoCache returns a Cache implementation based on Ristretto
|
||||
func NewRistrettoCache(maxEntries, maxCost int64, cost func(interface{}) int64) *ristretto.Cache {
|
||||
func NewRistrettoCache(maxEntries, maxCost int64, cost func(any) int64) *ristretto.Cache {
|
||||
// The TinyLFU paper recommends to allocate 10x times the max entries amount as counters
|
||||
// for the admission policy; since our caches are small and we're very interested on admission
|
||||
// accuracy, we're a bit more greedy than 10x
|
||||
|
|
|
@ -67,7 +67,7 @@ type Cache struct {
|
|||
// onReject is called when an item is rejected via admission policy.
|
||||
onReject itemCallback
|
||||
// onExit is called whenever a value goes out of scope from the cache.
|
||||
onExit func(interface{})
|
||||
onExit func(any)
|
||||
// KeyToHash function is used to customize the key hashing algorithm.
|
||||
// Each key will be hashed using the provided function. If keyToHash value
|
||||
// is not set, the default keyToHash function is used.
|
||||
|
@ -77,7 +77,7 @@ type Cache struct {
|
|||
// indicates whether cache is closed.
|
||||
isClosed bool
|
||||
// cost calculates cost from a value.
|
||||
cost func(value interface{}) int64
|
||||
cost func(value any) int64
|
||||
// ignoreInternalCost dictates whether to ignore the cost of internally storing
|
||||
// the item in the cost calculation.
|
||||
ignoreInternalCost bool
|
||||
|
@ -124,7 +124,7 @@ type Config struct {
|
|||
// OnExit is called whenever a value is removed from cache. This can be
|
||||
// used to do manual memory deallocation. Would also be called on eviction
|
||||
// and rejection of the value.
|
||||
OnExit func(val interface{})
|
||||
OnExit func(val any)
|
||||
// KeyToHash function is used to customize the key hashing algorithm.
|
||||
// Each key will be hashed using the provided function. If keyToHash value
|
||||
// is not set, the default keyToHash function is used.
|
||||
|
@ -132,7 +132,7 @@ type Config struct {
|
|||
// Cost evaluates a value and outputs a corresponding cost. This function
|
||||
// is ran after Set is called for a new item or an item update with a cost
|
||||
// param of 0.
|
||||
Cost func(value interface{}) int64
|
||||
Cost func(value any) int64
|
||||
// IgnoreInternalCost set to true indicates to the cache that the cost of
|
||||
// internally storing the value should be ignored. This is useful when the
|
||||
// cost passed to set is not using bytes as units. Keep in mind that setting
|
||||
|
@ -153,7 +153,7 @@ type Item struct {
|
|||
flag itemFlag
|
||||
Key uint64
|
||||
Conflict uint64
|
||||
Value interface{}
|
||||
Value any
|
||||
Cost int64
|
||||
wg *sync.WaitGroup
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ func NewCache(config *Config) (*Cache, error) {
|
|||
cost: config.Cost,
|
||||
ignoreInternalCost: config.IgnoreInternalCost,
|
||||
}
|
||||
cache.onExit = func(val interface{}) {
|
||||
cache.onExit = func(val any) {
|
||||
if config.OnExit != nil && val != nil {
|
||||
config.OnExit(val)
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ func (c *Cache) Wait() {
|
|||
// Get returns the value (if any) and a boolean representing whether the
|
||||
// value was found or not. The value can be nil and the boolean can be true at
|
||||
// the same time.
|
||||
func (c *Cache) Get(key string) (interface{}, bool) {
|
||||
func (c *Cache) Get(key string) (any, bool) {
|
||||
if c == nil || c.isClosed {
|
||||
return nil, false
|
||||
}
|
||||
|
@ -245,14 +245,14 @@ func (c *Cache) Get(key string) (interface{}, bool) {
|
|||
// item will be added and other items will be evicted in order to make room.
|
||||
//
|
||||
// The cost of the entry will be evaluated lazily by the cache's Cost function.
|
||||
func (c *Cache) Set(key string, value interface{}) bool {
|
||||
func (c *Cache) Set(key string, value any) bool {
|
||||
return c.SetWithCost(key, value, 0)
|
||||
}
|
||||
|
||||
// SetWithCost works like Set but adds a key-value pair to the cache with a specific
|
||||
// cost. The built-in Cost function will not be called to evaluate the object's cost
|
||||
// and instead the given value will be used.
|
||||
func (c *Cache) SetWithCost(key string, value interface{}, cost int64) bool {
|
||||
func (c *Cache) SetWithCost(key string, value any, cost int64) bool {
|
||||
if c == nil || c.isClosed {
|
||||
return false
|
||||
}
|
||||
|
@ -421,7 +421,7 @@ func (c *Cache) Misses() int64 {
|
|||
|
||||
// ForEach yields all the values currently stored in the cache to the given callback.
|
||||
// The callback may return `false` to stop the iteration early.
|
||||
func (c *Cache) ForEach(forEach func(interface{}) bool) {
|
||||
func (c *Cache) ForEach(forEach func(any) bool) {
|
||||
if c == nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -237,7 +237,7 @@ func TestCacheProcessItems(t *testing.T) {
|
|||
MaxCost: 10,
|
||||
BufferItems: 64,
|
||||
IgnoreInternalCost: true,
|
||||
Cost: func(value interface{}) int64 {
|
||||
Cost: func(value any) int64 {
|
||||
return int64(value.(int))
|
||||
},
|
||||
OnEvict: func(item *Item) {
|
||||
|
@ -625,7 +625,7 @@ func TestDropUpdates(t *testing.T) {
|
|||
lastEvictedSet := int64(-1)
|
||||
|
||||
var err error
|
||||
handler := func(_ interface{}, value interface{}) {
|
||||
handler := func(_ any, value any) {
|
||||
v := value.(string)
|
||||
lastEvictedSet, err = strconv.ParseInt(string(v), 10, 32)
|
||||
require.NoError(t, err)
|
||||
|
|
|
@ -77,7 +77,7 @@ func newRingBuffer(cons ringConsumer, capa int64) *ringBuffer {
|
|||
// available to us (such as runtime_procPin()).
|
||||
return &ringBuffer{
|
||||
pool: &sync.Pool{
|
||||
New: func() interface{} { return newRingStripe(cons, capa) },
|
||||
New: func() any { return newRingStripe(cons, capa) },
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
type storeItem struct {
|
||||
key uint64
|
||||
conflict uint64
|
||||
value interface{}
|
||||
value any
|
||||
}
|
||||
|
||||
// store is the interface fulfilled by all hash map implementations in this
|
||||
|
@ -36,20 +36,20 @@ type storeItem struct {
|
|||
// Every store is safe for concurrent usage.
|
||||
type store interface {
|
||||
// Get returns the value associated with the key parameter.
|
||||
Get(uint64, uint64) (interface{}, bool)
|
||||
Get(uint64, uint64) (any, bool)
|
||||
// Set adds the key-value pair to the Map or updates the value if it's
|
||||
// already present. The key-value pair is passed as a pointer to an
|
||||
// item object.
|
||||
Set(*Item)
|
||||
// Del deletes the key-value pair from the Map.
|
||||
Del(uint64, uint64) (uint64, interface{})
|
||||
Del(uint64, uint64) (uint64, any)
|
||||
// Update attempts to update the key with a new value and returns true if
|
||||
// successful.
|
||||
Update(*Item) (interface{}, bool)
|
||||
Update(*Item) (any, bool)
|
||||
// Clear clears all contents of the store.
|
||||
Clear(onEvict itemCallback)
|
||||
// ForEach yields all the values in the store
|
||||
ForEach(forEach func(interface{}) bool)
|
||||
ForEach(forEach func(any) bool)
|
||||
// Len returns the number of entries in the store
|
||||
Len() int
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ func newShardedMap() *shardedMap {
|
|||
return sm
|
||||
}
|
||||
|
||||
func (sm *shardedMap) Get(key, conflict uint64) (interface{}, bool) {
|
||||
func (sm *shardedMap) Get(key, conflict uint64) (any, bool) {
|
||||
return sm.shards[key%numShards].get(key, conflict)
|
||||
}
|
||||
|
||||
|
@ -88,15 +88,15 @@ func (sm *shardedMap) Set(i *Item) {
|
|||
sm.shards[i.Key%numShards].Set(i)
|
||||
}
|
||||
|
||||
func (sm *shardedMap) Del(key, conflict uint64) (uint64, interface{}) {
|
||||
func (sm *shardedMap) Del(key, conflict uint64) (uint64, any) {
|
||||
return sm.shards[key%numShards].Del(key, conflict)
|
||||
}
|
||||
|
||||
func (sm *shardedMap) Update(newItem *Item) (interface{}, bool) {
|
||||
func (sm *shardedMap) Update(newItem *Item) (any, bool) {
|
||||
return sm.shards[newItem.Key%numShards].Update(newItem)
|
||||
}
|
||||
|
||||
func (sm *shardedMap) ForEach(forEach func(interface{}) bool) {
|
||||
func (sm *shardedMap) ForEach(forEach func(any) bool) {
|
||||
for _, shard := range sm.shards {
|
||||
if !shard.foreach(forEach) {
|
||||
break
|
||||
|
@ -129,7 +129,7 @@ func newLockedMap() *lockedMap {
|
|||
}
|
||||
}
|
||||
|
||||
func (m *lockedMap) get(key, conflict uint64) (interface{}, bool) {
|
||||
func (m *lockedMap) get(key, conflict uint64) (any, bool) {
|
||||
m.RLock()
|
||||
item, ok := m.data[key]
|
||||
m.RUnlock()
|
||||
|
@ -167,7 +167,7 @@ func (m *lockedMap) Set(i *Item) {
|
|||
}
|
||||
}
|
||||
|
||||
func (m *lockedMap) Del(key, conflict uint64) (uint64, interface{}) {
|
||||
func (m *lockedMap) Del(key, conflict uint64) (uint64, any) {
|
||||
m.Lock()
|
||||
item, ok := m.data[key]
|
||||
if !ok {
|
||||
|
@ -184,7 +184,7 @@ func (m *lockedMap) Del(key, conflict uint64) (uint64, interface{}) {
|
|||
return item.conflict, item.value
|
||||
}
|
||||
|
||||
func (m *lockedMap) Update(newItem *Item) (interface{}, bool) {
|
||||
func (m *lockedMap) Update(newItem *Item) (any, bool) {
|
||||
m.Lock()
|
||||
item, ok := m.data[newItem.Key]
|
||||
if !ok {
|
||||
|
@ -228,7 +228,7 @@ func (m *lockedMap) Clear(onEvict itemCallback) {
|
|||
m.Unlock()
|
||||
}
|
||||
|
||||
func (m *lockedMap) foreach(forEach func(interface{}) bool) bool {
|
||||
func (m *lockedMap) foreach(forEach func(any) bool) bool {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
for _, si := range m.data {
|
||||
|
|
|
@ -29,7 +29,7 @@ func List() *cobra.Command {
|
|||
listCmd.Run = func(cmd *cobra.Command, args []string) {
|
||||
rules := common.GetRules(configFile)
|
||||
|
||||
var out interface{}
|
||||
var out any
|
||||
if listOptName == "" {
|
||||
if listOptNamesOnly {
|
||||
out = []string{}
|
||||
|
|
|
@ -18,7 +18,7 @@ func GetRules(path string) *rules.Rules {
|
|||
return rules
|
||||
}
|
||||
|
||||
func MustPrintJSON(obj interface{}) {
|
||||
func MustPrintJSON(obj any) {
|
||||
enc, err := json.MarshalIndent(obj, "", " ")
|
||||
if err != nil {
|
||||
log.Fatalf("Unable to marshal object: %v", err)
|
||||
|
@ -26,7 +26,7 @@ func MustPrintJSON(obj interface{}) {
|
|||
fmt.Printf("%v\n", string(enc))
|
||||
}
|
||||
|
||||
func MustWriteJSON(obj interface{}, path string) {
|
||||
func MustWriteJSON(obj any, path string) {
|
||||
enc, err := json.MarshalIndent(obj, "", " ")
|
||||
if err != nil {
|
||||
log.Fatalf("Unable to marshal object: %v", err)
|
||||
|
|
|
@ -67,7 +67,7 @@ var (
|
|||
|
||||
// fatal ensures the tracer is closed and final spans are sent before issuing
|
||||
// a log.Fatal call with the given args.
|
||||
func fatal(args ...interface{}) {
|
||||
func fatal(args ...any) {
|
||||
trace.LogErrorsWhenClosing(traceCloser)
|
||||
log.Fatal(args...)
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ func init() {
|
|||
})
|
||||
}
|
||||
|
||||
type bindvars []interface{}
|
||||
type bindvars []any
|
||||
|
||||
func (bv *bindvars) String() string {
|
||||
b, err := json.Marshal(bv)
|
||||
|
@ -116,7 +116,7 @@ func (bv *bindvars) Set(s string) (err error) {
|
|||
}
|
||||
|
||||
// For internal flag compatibility
|
||||
func (bv *bindvars) Get() interface{} {
|
||||
func (bv *bindvars) Get() any {
|
||||
return bv
|
||||
}
|
||||
|
||||
|
@ -191,8 +191,8 @@ func run() (*results, error) {
|
|||
return execMulti(ctx, db, args[0])
|
||||
}
|
||||
|
||||
func prepareBindVariables() []interface{} {
|
||||
bv := make([]interface{}, 0, len(*bindVariables)+1)
|
||||
func prepareBindVariables() []any {
|
||||
bv := make([]any, 0, len(*bindVariables)+1)
|
||||
bv = append(bv, (*bindVariables)...)
|
||||
if *maxSeqID > *minSeqID {
|
||||
bv = append(bv, <-seqChan)
|
||||
|
@ -263,7 +263,7 @@ func execDml(ctx context.Context, db *sql.DB, sql string) (*results, error) {
|
|||
return nil, vterrors.Wrap(err, "BEGIN failed")
|
||||
}
|
||||
|
||||
result, err := tx.ExecContext(ctx, sql, []interface{}(prepareBindVariables())...)
|
||||
result, err := tx.ExecContext(ctx, sql, []any(prepareBindVariables())...)
|
||||
if err != nil {
|
||||
return nil, vterrors.Wrap(err, "failed to execute DML")
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ func execDml(ctx context.Context, db *sql.DB, sql string) (*results, error) {
|
|||
|
||||
func execNonDml(ctx context.Context, db *sql.DB, sql string) (*results, error) {
|
||||
start := time.Now()
|
||||
rows, err := db.QueryContext(ctx, sql, []interface{}(prepareBindVariables())...)
|
||||
rows, err := db.QueryContext(ctx, sql, []any(prepareBindVariables())...)
|
||||
if err != nil {
|
||||
return nil, vterrors.Wrap(err, "client error")
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ func execNonDml(ctx context.Context, db *sql.DB, sql string) (*results, error) {
|
|||
|
||||
// get the rows
|
||||
for rows.Next() {
|
||||
row := make([]interface{}, len(cols))
|
||||
row := make([]any, len(cols))
|
||||
for i := range row {
|
||||
var col string
|
||||
row[i] = &col
|
||||
|
|
|
@ -30,20 +30,20 @@ func addStatusParts(vtg *vtgate.VTGate) {
|
|||
*discovery.TabletURLTemplateString = "{{.NamedStatusURL}}"
|
||||
discovery.ParseTabletURLTemplateFromFlag()
|
||||
|
||||
servenv.AddStatusPart("Executor", vtgate.ExecutorTemplate, func() interface{} {
|
||||
servenv.AddStatusPart("Executor", vtgate.ExecutorTemplate, func() any {
|
||||
return nil
|
||||
})
|
||||
servenv.AddStatusPart("VSchema", vtgate.VSchemaTemplate, func() interface{} {
|
||||
servenv.AddStatusPart("VSchema", vtgate.VSchemaTemplate, func() any {
|
||||
return vtg.VSchemaStats()
|
||||
})
|
||||
servenv.AddStatusFuncs(srvtopo.StatusFuncs)
|
||||
servenv.AddStatusPart("Topology Cache", srvtopo.TopoTemplate, func() interface{} {
|
||||
servenv.AddStatusPart("Topology Cache", srvtopo.TopoTemplate, func() any {
|
||||
return resilientServer.CacheStatus()
|
||||
})
|
||||
servenv.AddStatusPart("Gateway Status", vtgate.StatusTemplate, func() interface{} {
|
||||
servenv.AddStatusPart("Gateway Status", vtgate.StatusTemplate, func() any {
|
||||
return vtg.GetGatewayCacheStatus()
|
||||
})
|
||||
servenv.AddStatusPart("Health Check Cache", discovery.HealthCheckTemplate, func() interface{} {
|
||||
servenv.AddStatusPart("Health Check Cache", discovery.HealthCheckTemplate, func() any {
|
||||
return vtg.Gateway().TabletsCacheStatus()
|
||||
})
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ import (
|
|||
// either by being a proto message type or by anonymously embedding one, so for
|
||||
// other types that may have nested struct fields, we still use the standard Go
|
||||
// marshaler, which will result in different formattings.
|
||||
func MarshalJSON(obj interface{}) ([]byte, error) {
|
||||
func MarshalJSON(obj any) ([]byte, error) {
|
||||
switch obj := obj.(type) {
|
||||
case proto.Message:
|
||||
m := protojson.MarshalOptions{
|
||||
|
|
|
@ -25,20 +25,20 @@ import (
|
|||
)
|
||||
|
||||
func addStatusParts(vtg *vtgate.VTGate) {
|
||||
servenv.AddStatusPart("Executor", vtgate.ExecutorTemplate, func() interface{} {
|
||||
servenv.AddStatusPart("Executor", vtgate.ExecutorTemplate, func() any {
|
||||
return nil
|
||||
})
|
||||
servenv.AddStatusPart("VSchema", vtgate.VSchemaTemplate, func() interface{} {
|
||||
servenv.AddStatusPart("VSchema", vtgate.VSchemaTemplate, func() any {
|
||||
return vtg.VSchemaStats()
|
||||
})
|
||||
servenv.AddStatusFuncs(srvtopo.StatusFuncs)
|
||||
servenv.AddStatusPart("Topology Cache", srvtopo.TopoTemplate, func() interface{} {
|
||||
servenv.AddStatusPart("Topology Cache", srvtopo.TopoTemplate, func() any {
|
||||
return resilientServer.CacheStatus()
|
||||
})
|
||||
servenv.AddStatusPart("Gateway Status", vtgate.StatusTemplate, func() interface{} {
|
||||
servenv.AddStatusPart("Gateway Status", vtgate.StatusTemplate, func() any {
|
||||
return vtg.GetGatewayCacheStatus()
|
||||
})
|
||||
servenv.AddStatusPart("Health Check Cache", discovery.HealthCheckTemplate, func() interface{} {
|
||||
servenv.AddStatusPart("Health Check Cache", discovery.HealthCheckTemplate, func() any {
|
||||
return vtg.Gateway().TabletsCacheStatus()
|
||||
})
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ func printSortedMap(val reflect.Value) []byte {
|
|||
return buf.Bytes()
|
||||
}
|
||||
|
||||
func echoQueryResult(vals map[string]interface{}) *sqltypes.Result {
|
||||
func echoQueryResult(vals map[string]any) *sqltypes.Result {
|
||||
qr := &sqltypes.Result{}
|
||||
|
||||
var row []sqltypes.Value
|
||||
|
@ -100,7 +100,7 @@ func echoQueryResult(vals map[string]interface{}) *sqltypes.Result {
|
|||
|
||||
func (c *echoClient) Execute(ctx context.Context, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable) (*vtgatepb.Session, *sqltypes.Result, error) {
|
||||
if strings.HasPrefix(sql, EchoPrefix) {
|
||||
return session, echoQueryResult(map[string]interface{}{
|
||||
return session, echoQueryResult(map[string]any{
|
||||
"callerId": callerid.EffectiveCallerIDFromContext(ctx),
|
||||
"query": sql,
|
||||
"bindVars": bindVariables,
|
||||
|
@ -112,7 +112,7 @@ func (c *echoClient) Execute(ctx context.Context, session *vtgatepb.Session, sql
|
|||
|
||||
func (c *echoClient) StreamExecute(ctx context.Context, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable, callback func(*sqltypes.Result) error) error {
|
||||
if strings.HasPrefix(sql, EchoPrefix) {
|
||||
callback(echoQueryResult(map[string]interface{}{
|
||||
callback(echoQueryResult(map[string]any{
|
||||
"callerId": callerid.EffectiveCallerIDFromContext(ctx),
|
||||
"query": sql,
|
||||
"bindVars": bindVariables,
|
||||
|
@ -130,7 +130,7 @@ func (c *echoClient) ExecuteBatch(ctx context.Context, session *vtgatepb.Session
|
|||
bindVariablesList = make([]map[string]*querypb.BindVariable, len(sqlList))
|
||||
}
|
||||
for queryNum, query := range sqlList {
|
||||
result := echoQueryResult(map[string]interface{}{
|
||||
result := echoQueryResult(map[string]any{
|
||||
"callerId": callerid.EffectiveCallerIDFromContext(ctx),
|
||||
"query": query,
|
||||
"bindVars": bindVariablesList[queryNum],
|
||||
|
@ -175,7 +175,7 @@ func (c *echoClient) VStream(ctx context.Context, tabletType topodatapb.TabletTy
|
|||
|
||||
func (c *echoClient) Prepare(ctx context.Context, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable) (*vtgatepb.Session, []*querypb.Field, error) {
|
||||
if strings.HasPrefix(sql, EchoPrefix) {
|
||||
return session, echoQueryResult(map[string]interface{}{
|
||||
return session, echoQueryResult(map[string]any{
|
||||
"callerId": callerid.EffectiveCallerIDFromContext(ctx),
|
||||
"query": sql,
|
||||
"bindVars": bindVariables,
|
||||
|
|
|
@ -85,8 +85,8 @@ var (
|
|||
)
|
||||
|
||||
func addStatusParts(qsc tabletserver.Controller) {
|
||||
servenv.AddStatusPart("Tablet", tabletTemplate, func() interface{} {
|
||||
return map[string]interface{}{
|
||||
servenv.AddStatusPart("Tablet", tabletTemplate, func() any {
|
||||
return map[string]any{
|
||||
"Tablet": topo.NewTabletInfo(tm.Tablet(), nil),
|
||||
"DeniedTables": tm.DeniedTables(),
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ import (
|
|||
|
||||
var (
|
||||
listenersMutex sync.RWMutex // protects listeners and interfaces
|
||||
listeners = make(map[reflect.Type][]interface{})
|
||||
listeners = make(map[reflect.Type][]any)
|
||||
interfaces = make([]reflect.Type, 0)
|
||||
)
|
||||
|
||||
|
@ -99,7 +99,7 @@ func (why BadListenerError) Error() string {
|
|||
// AddListener registers a listener function that will be called when a matching
|
||||
// event is dispatched. The type of the function's first (and only) argument
|
||||
// declares the event type (or interface) to listen for.
|
||||
func AddListener(fn interface{}) {
|
||||
func AddListener(fn any) {
|
||||
listenersMutex.Lock()
|
||||
defer listenersMutex.Unlock()
|
||||
|
||||
|
@ -129,7 +129,7 @@ func AddListener(fn interface{}) {
|
|||
|
||||
// Dispatch sends an event to all registered listeners that were declared
|
||||
// to accept values of the event's type, or interfaces that the value implements.
|
||||
func Dispatch(ev interface{}) {
|
||||
func Dispatch(ev any) {
|
||||
listenersMutex.RLock()
|
||||
defer listenersMutex.RUnlock()
|
||||
|
||||
|
@ -157,12 +157,12 @@ func callListeners(t reflect.Type, vals []reflect.Value) {
|
|||
// dispatching into one call.
|
||||
type Updater interface {
|
||||
// Update is called by DispatchUpdate() before the event is dispatched.
|
||||
Update(update interface{})
|
||||
Update(update any)
|
||||
}
|
||||
|
||||
// DispatchUpdate calls Update() on the event and then dispatches it. This is a
|
||||
// shortcut for combining updates and dispatches into a single call.
|
||||
func DispatchUpdate(ev Updater, update interface{}) {
|
||||
func DispatchUpdate(ev Updater, update any) {
|
||||
ev.Update(update)
|
||||
Dispatch(ev)
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ func clearListeners() {
|
|||
listenersMutex.Lock()
|
||||
defer listenersMutex.Unlock()
|
||||
|
||||
listeners = make(map[reflect.Type][]interface{})
|
||||
listeners = make(map[reflect.Type][]any)
|
||||
interfaces = make([]reflect.Type, 0)
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ func TestEmptyInterfaceListener(t *testing.T) {
|
|||
clearListeners()
|
||||
|
||||
triggered := false
|
||||
AddListener(func(interface{}) { triggered = true })
|
||||
AddListener(func(any) { triggered = true })
|
||||
Dispatch("this should match interface{}")
|
||||
|
||||
if !triggered {
|
||||
|
@ -228,10 +228,10 @@ func TestDispatchValueToPointerInterfaceListener(t *testing.T) {
|
|||
}
|
||||
|
||||
type testUpdateEvent struct {
|
||||
update interface{}
|
||||
update any
|
||||
}
|
||||
|
||||
func (ev *testUpdateEvent) Update(update interface{}) {
|
||||
func (ev *testUpdateEvent) Update(update any) {
|
||||
ev.update = update
|
||||
}
|
||||
|
||||
|
|
|
@ -69,9 +69,9 @@ type loggerMsg struct {
|
|||
}
|
||||
type testLogger struct {
|
||||
logs []loggerMsg
|
||||
savedInfof func(format string, args ...interface{})
|
||||
savedWarningf func(format string, args ...interface{})
|
||||
savedErrorf func(format string, args ...interface{})
|
||||
savedInfof func(format string, args ...any)
|
||||
savedWarningf func(format string, args ...any)
|
||||
savedErrorf func(format string, args ...any)
|
||||
}
|
||||
|
||||
func newTestLogger() *testLogger {
|
||||
|
@ -92,19 +92,19 @@ func (tl *testLogger) Close() {
|
|||
log.Errorf = tl.savedErrorf
|
||||
}
|
||||
|
||||
func (tl *testLogger) recordInfof(format string, args ...interface{}) {
|
||||
func (tl *testLogger) recordInfof(format string, args ...any) {
|
||||
msg := fmt.Sprintf(format, args...)
|
||||
tl.logs = append(tl.logs, loggerMsg{msg, "INFO"})
|
||||
tl.savedInfof(msg)
|
||||
}
|
||||
|
||||
func (tl *testLogger) recordWarningf(format string, args ...interface{}) {
|
||||
func (tl *testLogger) recordWarningf(format string, args ...any) {
|
||||
msg := fmt.Sprintf(format, args...)
|
||||
tl.logs = append(tl.logs, loggerMsg{msg, "WARNING"})
|
||||
tl.savedWarningf(msg)
|
||||
}
|
||||
|
||||
func (tl *testLogger) recordErrorf(format string, args ...interface{}) {
|
||||
func (tl *testLogger) recordErrorf(format string, args ...any) {
|
||||
msg := fmt.Sprintf(format, args...)
|
||||
tl.logs = append(tl.logs, loggerMsg{msg, "ERROR"})
|
||||
tl.savedErrorf(msg)
|
||||
|
|
|
@ -76,7 +76,7 @@ func RecoverAll() {
|
|||
doRecover(recover(), true)
|
||||
}
|
||||
|
||||
func doRecover(err interface{}, recoverAll bool) {
|
||||
func doRecover(err any, recoverAll bool) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ var (
|
|||
type StringListValue []string
|
||||
|
||||
// Get returns the []string value of this flag.
|
||||
func (value StringListValue) Get() interface{} {
|
||||
func (value StringListValue) Get() any {
|
||||
return []string(value)
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ func (value *StringMapValue) Set(v string) error {
|
|||
}
|
||||
|
||||
// Get returns the map[string]string value of this flag.
|
||||
func (value StringMapValue) Get() interface{} {
|
||||
func (value StringMapValue) Get() any {
|
||||
return map[string]string(value)
|
||||
}
|
||||
|
||||
|
|
|
@ -27,29 +27,29 @@ import (
|
|||
type Deduplicable interface {
|
||||
// IsDuplicate returns true if other is considered to be a
|
||||
// duplicate of the calling instance.
|
||||
IsDuplicate(interface{}) bool
|
||||
IsDuplicate(any) bool
|
||||
}
|
||||
|
||||
// History is a data structure that allows you to keep some number of
|
||||
// records.
|
||||
type History struct {
|
||||
mu sync.Mutex
|
||||
records []interface{}
|
||||
lastAdded interface{}
|
||||
latest interface{}
|
||||
records []any
|
||||
lastAdded any
|
||||
latest any
|
||||
next int
|
||||
length int
|
||||
}
|
||||
|
||||
// New returns a History with the specified maximum length.
|
||||
func New(length int) *History {
|
||||
return &History{records: make([]interface{}, length)}
|
||||
return &History{records: make([]any, length)}
|
||||
}
|
||||
|
||||
// Add a new record in a threadsafe manner. If record implements
|
||||
// Deduplicable, and IsDuplicate returns true when called on the last
|
||||
// previously added record, it will not be added.
|
||||
func (history *History) Add(record interface{}) {
|
||||
func (history *History) Add(record any) {
|
||||
history.mu.Lock()
|
||||
defer history.mu.Unlock()
|
||||
|
||||
|
@ -73,11 +73,11 @@ func (history *History) Add(record interface{}) {
|
|||
|
||||
// Records returns the kept records in reverse chronological order in a
|
||||
// threadsafe manner.
|
||||
func (history *History) Records() []interface{} {
|
||||
func (history *History) Records() []any {
|
||||
history.mu.Lock()
|
||||
defer history.mu.Unlock()
|
||||
|
||||
records := make([]interface{}, 0, history.length)
|
||||
records := make([]any, 0, history.length)
|
||||
records = append(records, history.records[history.next:history.length]...)
|
||||
records = append(records, history.records[:history.next]...)
|
||||
|
||||
|
@ -91,7 +91,7 @@ func (history *History) Records() []interface{} {
|
|||
|
||||
// Latest returns the record most recently passed to Add(),
|
||||
// regardless of whether it was actually added or dropped as a duplicate.
|
||||
func (history *History) Latest() interface{} {
|
||||
func (history *History) Latest() any {
|
||||
history.mu.Lock()
|
||||
defer history.mu.Unlock()
|
||||
return history.latest
|
||||
|
|
|
@ -89,7 +89,7 @@ func TestLatest(t *testing.T) {
|
|||
|
||||
type duplic int
|
||||
|
||||
func (d duplic) IsDuplicate(other interface{}) bool {
|
||||
func (d duplic) IsDuplicate(other any) bool {
|
||||
return d == other
|
||||
}
|
||||
|
||||
|
@ -104,6 +104,6 @@ func TestIsEquivalent(t *testing.T) {
|
|||
|
||||
type mod10 int
|
||||
|
||||
func (m mod10) IsDuplicate(other interface{}) bool {
|
||||
func (m mod10) IsDuplicate(other any) bool {
|
||||
return m%10 == other.(mod10)%10
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ const (
|
|||
)
|
||||
|
||||
// Check and warn on any single-dash flags.
|
||||
func warnOnSingleDashLongFlags(fs *goflag.FlagSet, argv []string, warningf func(msg string, args ...interface{})) {
|
||||
func warnOnSingleDashLongFlags(fs *goflag.FlagSet, argv []string, warningf func(msg string, args ...any)) {
|
||||
fs.Visit(func(f *goflag.Flag) {
|
||||
// Boolean flags with single-character names are okay to use the
|
||||
// single-dash form. I don't _think_ we have any of these, but I'm being
|
||||
|
@ -113,7 +113,7 @@ func warnOnSingleDashLongFlags(fs *goflag.FlagSet, argv []string, warningf func(
|
|||
}
|
||||
|
||||
// Check and warn for any mixed posarg / dashed-arg on the CLI.
|
||||
func warnOnMixedPositionalAndFlagArguments(posargs []string, warningf func(msg string, args ...interface{})) {
|
||||
func warnOnMixedPositionalAndFlagArguments(posargs []string, warningf func(msg string, args ...any)) {
|
||||
for _, arg := range posargs {
|
||||
if arg == "--" {
|
||||
break
|
||||
|
|
|
@ -31,7 +31,7 @@ var carriageReturn = []byte("\n")
|
|||
// Unmarshal wraps json.Unmarshal, but returns errors that
|
||||
// also mention the line number. This function is not very
|
||||
// efficient and should not be used for high QPS operations.
|
||||
func Unmarshal(data []byte, v interface{}) error {
|
||||
func Unmarshal(data []byte, v any) error {
|
||||
if pb, ok := v.(proto.Message); ok {
|
||||
return annotate(data, protojson.Unmarshal(data, pb))
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ func TestUnmarshal(t *testing.T) {
|
|||
err: "",
|
||||
}}
|
||||
for _, tcase := range tcases {
|
||||
out := make(map[string]interface{})
|
||||
out := make(map[string]any)
|
||||
err := Unmarshal([]byte(tcase.in), &out)
|
||||
got := ""
|
||||
if err != nil {
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
|
||||
// MarshalNoEscape is the same functionality as json.Marshal but
|
||||
// with HTML escaping disabled
|
||||
func MarshalNoEscape(v interface{}) ([]byte, error) {
|
||||
func MarshalNoEscape(v any) ([]byte, error) {
|
||||
buf := bytes.Buffer{}
|
||||
enc := json.NewEncoder(&buf)
|
||||
enc.SetEscapeHTML(false)
|
||||
|
@ -37,7 +37,7 @@ func MarshalNoEscape(v interface{}) ([]byte, error) {
|
|||
|
||||
// MarshalIndentNoEscape is the same functionality as json.MarshalIndent but with HTML escaping
|
||||
// disabled
|
||||
func MarshalIndentNoEscape(v interface{}, prefix, indent string) ([]byte, error) {
|
||||
func MarshalIndentNoEscape(v any, prefix, indent string) ([]byte, error) {
|
||||
buf := bytes.Buffer{}
|
||||
enc := json.NewEncoder(&buf)
|
||||
enc.SetEscapeHTML(false)
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
func TestMarshalNoEscape(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
v interface{}
|
||||
v any
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
|
@ -63,7 +63,7 @@ func TestMarshalNoEscape(t *testing.T) {
|
|||
func TestMarshalIndentNoEscape(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
v interface{}
|
||||
v any
|
||||
prefix string
|
||||
ident string
|
||||
expected string
|
||||
|
|
|
@ -48,7 +48,7 @@ https://github.com/noplay/python-mysql-replication/blob/175df28cc8b536a68522ff9b
|
|||
//TODO remove once the json refactor is tested live
|
||||
var jsonDebug = false
|
||||
|
||||
func jlog(tpl string, vals ...interface{}) {
|
||||
func jlog(tpl string, vals ...any) {
|
||||
if !jsonDebug {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ func TestJSONTypes(t *testing.T) {
|
|||
return
|
||||
}
|
||||
if tc.isMap { // map keys sorting order is not guaranteed, so we convert back to golang maps and compare
|
||||
var gotJSON, wantJSON map[string]interface{}
|
||||
var gotJSON, wantJSON map[string]any
|
||||
err = json.Unmarshal([]byte(val), &gotJSON)
|
||||
require.NoError(t, err)
|
||||
err = json.Unmarshal([]byte(tc.expected), &wantJSON)
|
||||
|
|
|
@ -78,18 +78,18 @@ func NewCollation(name string, weights Weights, weightPatches []Patch, reorder [
|
|||
|
||||
switch {
|
||||
case coll.param == nil && len(weightPatches) == 0 && coll.contract == nil:
|
||||
coll.iterpool.New = func() interface{} {
|
||||
coll.iterpool.New = func() any {
|
||||
return &FastIterator900{iterator900: iterator900{Collation900: *coll}}
|
||||
}
|
||||
case name == "utf8mb4_ja_0900_as_cs_ks" || name == "utf8mb4_ja_0900_as_cs":
|
||||
coll.iterpool.New = func() interface{} {
|
||||
coll.iterpool.New = func() any {
|
||||
return &jaIterator900{iterator900: iterator900{Collation900: *coll}}
|
||||
}
|
||||
case name == "utf8mb4_zh_0900_as_cs":
|
||||
coll.implicits = unicodeImplicitChineseWeights
|
||||
fallthrough
|
||||
default:
|
||||
coll.iterpool.New = func() interface{} {
|
||||
coll.iterpool.New = func() any {
|
||||
return &slowIterator900{iterator900: iterator900{Collation900: *coll}}
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ func NewCollationLegacy(cs charset.Charset, weights Weights, weightPatches []Pat
|
|||
iterpool: &sync.Pool{},
|
||||
}
|
||||
|
||||
coll.iterpool.New = func() interface{} {
|
||||
coll.iterpool.New = func() any {
|
||||
return &WeightIteratorLegacy{CollationLegacy: *coll}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ func (g *Generator) Fail(err string) {
|
|||
os.Exit(1)
|
||||
}
|
||||
|
||||
func (g *Generator) printArray(iface interface{}) {
|
||||
func (g *Generator) printArray(iface any) {
|
||||
switch ary := iface.(type) {
|
||||
case Array8:
|
||||
g.WriteString("[...]uint8{")
|
||||
|
@ -156,7 +156,7 @@ func (g *Generator) UsePackage(pkg Package) {
|
|||
g.imported[pkg] = false
|
||||
}
|
||||
|
||||
func (g *Generator) printAtom(v interface{}) {
|
||||
func (g *Generator) printAtom(v any) {
|
||||
switch v := v.(type) {
|
||||
case string:
|
||||
g.WriteString(v)
|
||||
|
@ -199,7 +199,7 @@ func (pkg Package) Name() string {
|
|||
return path.Base(string(pkg))
|
||||
}
|
||||
|
||||
func (g *Generator) P(str ...interface{}) {
|
||||
func (g *Generator) P(str ...any) {
|
||||
for _, v := range str {
|
||||
g.printAtom(v)
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ func diffMaps(orgWeights, modWeights TailoringWeights) (diff []uca.Patch) {
|
|||
return
|
||||
}
|
||||
|
||||
func (g *TableGenerator) dedupTable(name, coll string, val interface{}) (string, bool) {
|
||||
func (g *TableGenerator) dedupTable(name, coll string, val any) (string, bool) {
|
||||
raw := fmt.Sprintf("%#v", val)
|
||||
if exist, ok := g.dedup[raw]; ok {
|
||||
return exist, true
|
||||
|
@ -242,7 +242,7 @@ func (g *Generator) printCollationUca900(meta *CollationMetadata) {
|
|||
g.P("})")
|
||||
}
|
||||
|
||||
func (g *TableGenerator) printSlice(name, coll string, slice interface{}) string {
|
||||
func (g *TableGenerator) printSlice(name, coll string, slice any) string {
|
||||
tableName, dedup := g.dedupTable(name, coll, slice)
|
||||
if !dedup {
|
||||
g.P("var ", tableName, " = ", slice)
|
||||
|
|
|
@ -33,7 +33,7 @@ import (
|
|||
"vitess.io/vitess/go/mysql/collations/internal/testutil"
|
||||
)
|
||||
|
||||
func wikiRequest(lang testutil.Lang, args map[string]string, output interface{}) error {
|
||||
func wikiRequest(lang testutil.Lang, args map[string]string, output any) error {
|
||||
wikipedia := fmt.Sprintf("https://%s.wikipedia.org/w/api.php", lang)
|
||||
req, err := http.NewRequest("GET", wikipedia, nil)
|
||||
if err != nil {
|
||||
|
|
|
@ -105,7 +105,7 @@ type Conn struct {
|
|||
// ClientData is a place where an application can store any
|
||||
// connection-related data. Mostly used on the server side, to
|
||||
// avoid maps indexed by ConnectionID for instance.
|
||||
ClientData interface{}
|
||||
ClientData any
|
||||
|
||||
// conn is the underlying network connection.
|
||||
// Calling Close() on the Conn will close this connection.
|
||||
|
@ -230,7 +230,7 @@ const (
|
|||
var bufPool = bucketpool.New(connBufferSize, MaxPacketSize)
|
||||
|
||||
// writersPool is used for pooling bufio.Writer objects.
|
||||
var writersPool = sync.Pool{New: func() interface{} { return bufio.NewWriterSize(nil, connBufferSize) }}
|
||||
var writersPool = sync.Pool{New: func() any { return bufio.NewWriterSize(nil, connBufferSize) }}
|
||||
|
||||
// newConn is an internal method to create a Conn. Used by client and server
|
||||
// side for common creation code.
|
||||
|
@ -801,7 +801,7 @@ func getLenEncInt(i uint64) []byte {
|
|||
return data
|
||||
}
|
||||
|
||||
func (c *Conn) writeErrorAndLog(errorCode uint16, sqlState string, format string, args ...interface{}) bool {
|
||||
func (c *Conn) writeErrorAndLog(errorCode uint16, sqlState string, format string, args ...any) bool {
|
||||
if err := c.writeErrorPacket(errorCode, sqlState, format, args...); err != nil {
|
||||
log.Errorf("Error writing error to %s: %v", c, err)
|
||||
return false
|
||||
|
@ -821,7 +821,7 @@ func (c *Conn) writeErrorPacketFromErrorAndLog(err error) bool {
|
|||
// writeErrorPacket writes an error packet.
|
||||
// Server -> Client.
|
||||
// This method returns a generic error, not a SQLError.
|
||||
func (c *Conn) writeErrorPacket(errorCode uint16, sqlState string, format string, args ...interface{}) error {
|
||||
func (c *Conn) writeErrorPacket(errorCode uint16, sqlState string, format string, args ...any) error {
|
||||
errorMessage := fmt.Sprintf(format, args...)
|
||||
length := 1 + 2 + 1 + 5 + len(errorMessage)
|
||||
data, pos := c.startEphemeralPacketWithHeader(length)
|
||||
|
@ -1419,7 +1419,7 @@ func (c *Conn) parseOKPacket(in []byte) (*PacketOK, error) {
|
|||
}
|
||||
packetOK := &PacketOK{}
|
||||
|
||||
fail := func(format string, args ...interface{}) (*PacketOK, error) {
|
||||
fail := func(format string, args ...any) (*PacketOK, error) {
|
||||
return nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, format, args...)
|
||||
}
|
||||
|
||||
|
|
|
@ -70,17 +70,17 @@ func (gtid filePosGTID) Flavor() string {
|
|||
}
|
||||
|
||||
// SequenceDomain implements GTID.SequenceDomain().
|
||||
func (gtid filePosGTID) SequenceDomain() interface{} {
|
||||
func (gtid filePosGTID) SequenceDomain() any {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SourceServer implements GTID.SourceServer().
|
||||
func (gtid filePosGTID) SourceServer() interface{} {
|
||||
func (gtid filePosGTID) SourceServer() any {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SequenceNumber implements GTID.SequenceNumber().
|
||||
func (gtid filePosGTID) SequenceNumber() interface{} {
|
||||
func (gtid filePosGTID) SequenceNumber() any {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -40,16 +40,16 @@ type GTID interface {
|
|||
Flavor() string
|
||||
|
||||
// SourceServer returns the ID of the server that generated the transaction.
|
||||
SourceServer() interface{}
|
||||
SourceServer() any
|
||||
|
||||
// SequenceNumber returns the ID number that increases with each transaction.
|
||||
// It is only valid to compare the sequence numbers of two GTIDs if they have
|
||||
// the same domain value.
|
||||
SequenceNumber() interface{}
|
||||
SequenceNumber() any
|
||||
|
||||
// SequenceDomain returns the ID of the domain within which two sequence
|
||||
// numbers can be meaningfully compared.
|
||||
SequenceDomain() interface{}
|
||||
SequenceDomain() any
|
||||
|
||||
// GTIDSet returns a GTIDSet of the same flavor as this GTID, containing only
|
||||
// this GTID.
|
||||
|
|
|
@ -192,13 +192,13 @@ type fakeGTID struct {
|
|||
flavor, value string
|
||||
}
|
||||
|
||||
func (f fakeGTID) String() string { return f.value }
|
||||
func (f fakeGTID) Last() string { panic("not implemented") }
|
||||
func (f fakeGTID) Flavor() string { return f.flavor }
|
||||
func (fakeGTID) SourceServer() interface{} { return int(1) }
|
||||
func (fakeGTID) SequenceNumber() interface{} { return int(1) }
|
||||
func (fakeGTID) SequenceDomain() interface{} { return int(1) }
|
||||
func (f fakeGTID) GTIDSet() GTIDSet { return nil }
|
||||
func (f fakeGTID) String() string { return f.value }
|
||||
func (f fakeGTID) Last() string { panic("not implemented") }
|
||||
func (f fakeGTID) Flavor() string { return f.flavor }
|
||||
func (fakeGTID) SourceServer() any { return int(1) }
|
||||
func (fakeGTID) SequenceNumber() any { return int(1) }
|
||||
func (fakeGTID) SequenceDomain() any { return int(1) }
|
||||
func (f fakeGTID) GTIDSet() GTIDSet { return nil }
|
||||
|
||||
func (fakeGTID) ContainsGTID(GTID) bool { return false }
|
||||
func (fakeGTID) Contains(GTIDSet) bool { return false }
|
||||
|
|
|
@ -98,17 +98,17 @@ func (gtid MariadbGTID) Flavor() string {
|
|||
}
|
||||
|
||||
// SequenceDomain implements GTID.SequenceDomain().
|
||||
func (gtid MariadbGTID) SequenceDomain() interface{} {
|
||||
func (gtid MariadbGTID) SequenceDomain() any {
|
||||
return gtid.Domain
|
||||
}
|
||||
|
||||
// SourceServer implements GTID.SourceServer().
|
||||
func (gtid MariadbGTID) SourceServer() interface{} {
|
||||
func (gtid MariadbGTID) SourceServer() any {
|
||||
return gtid.Server
|
||||
}
|
||||
|
||||
// SequenceNumber implements GTID.SequenceNumber().
|
||||
func (gtid MariadbGTID) SequenceNumber() interface{} {
|
||||
func (gtid MariadbGTID) SequenceNumber() any {
|
||||
return gtid.Sequence
|
||||
}
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ func TestMariaGTIDFlavor(t *testing.T) {
|
|||
|
||||
func TestMariaGTIDSequenceDomain(t *testing.T) {
|
||||
input := MariadbGTID{Domain: 12, Server: 345, Sequence: 6789}
|
||||
want := interface{}(uint32(12))
|
||||
want := any(uint32(12))
|
||||
|
||||
got := input.SequenceDomain()
|
||||
if got != want {
|
||||
|
@ -151,7 +151,7 @@ func TestMariaGTIDSequenceDomain(t *testing.T) {
|
|||
|
||||
func TestMariaGTIDSourceServer(t *testing.T) {
|
||||
input := MariadbGTID{Domain: 12, Server: 345, Sequence: 6789}
|
||||
want := interface{}(uint32(345))
|
||||
want := any(uint32(345))
|
||||
|
||||
got := input.SourceServer()
|
||||
if got != want {
|
||||
|
@ -161,7 +161,7 @@ func TestMariaGTIDSourceServer(t *testing.T) {
|
|||
|
||||
func TestMariaGTIDSequenceNumber(t *testing.T) {
|
||||
input := MariadbGTID{Domain: 12, Server: 345, Sequence: 6789}
|
||||
want := interface{}(uint64(6789))
|
||||
want := any(uint64(6789))
|
||||
|
||||
got := input.SequenceNumber()
|
||||
if got != want {
|
||||
|
|
|
@ -106,17 +106,17 @@ func (gtid Mysql56GTID) Flavor() string {
|
|||
}
|
||||
|
||||
// SequenceDomain implements GTID.SequenceDomain().
|
||||
func (gtid Mysql56GTID) SequenceDomain() interface{} {
|
||||
func (gtid Mysql56GTID) SequenceDomain() any {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SourceServer implements GTID.SourceServer().
|
||||
func (gtid Mysql56GTID) SourceServer() interface{} {
|
||||
func (gtid Mysql56GTID) SourceServer() any {
|
||||
return gtid.Server
|
||||
}
|
||||
|
||||
// SequenceNumber implements GTID.SequenceNumber().
|
||||
func (gtid Mysql56GTID) SequenceNumber() interface{} {
|
||||
func (gtid Mysql56GTID) SequenceNumber() any {
|
||||
return gtid.Sequence
|
||||
}
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ func TestMysql56GTIDFlavor(t *testing.T) {
|
|||
|
||||
func TestMysql56SequenceDomain(t *testing.T) {
|
||||
input := Mysql56GTID{}
|
||||
if got, want := input.SequenceDomain(), interface{}(nil); got != want {
|
||||
if got, want := input.SequenceDomain(), any(nil); got != want {
|
||||
t.Errorf("%#v.SequenceDomain() = %#v, want %#v", input, got, want)
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ func TestMysql56SourceServer(t *testing.T) {
|
|||
input := Mysql56GTID{
|
||||
Server: SID{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
|
||||
}
|
||||
want := interface{}(SID{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15})
|
||||
want := any(SID{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15})
|
||||
if got := input.SourceServer(); got != want {
|
||||
t.Errorf("%#v.SourceServer() = %#v, want %#v", input, got, want)
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ func TestMysql56SequenceNumber(t *testing.T) {
|
|||
Server: SID{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
|
||||
Sequence: 5432,
|
||||
}
|
||||
want := interface{}(int64(5432))
|
||||
want := any(int64(5432))
|
||||
if got := input.SequenceNumber(); got != want {
|
||||
t.Errorf("%#v.SequenceNumber() = %#v, want %#v", input, got, want)
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ type SQLError struct {
|
|||
// NewSQLError creates a new SQLError.
|
||||
// If sqlState is left empty, it will default to "HY000" (general error).
|
||||
// TODO: Should be aligned with vterrors, stack traces and wrapping
|
||||
func NewSQLError(number int, sqlState string, format string, args ...interface{}) *SQLError {
|
||||
func NewSQLError(number int, sqlState string, format string, args ...any) *SQLError {
|
||||
if sqlState == "" {
|
||||
sqlState = SSUnknownSQLState
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ type Numbered struct {
|
|||
}
|
||||
|
||||
type numberedWrapper struct {
|
||||
val interface{}
|
||||
val any
|
||||
inUse bool
|
||||
purpose string
|
||||
timeCreated time.Time
|
||||
|
@ -51,7 +51,7 @@ type unregistered struct {
|
|||
func NewNumbered() *Numbered {
|
||||
n := &Numbered{
|
||||
resources: make(map[int64]*numberedWrapper),
|
||||
recentlyUnregistered: cache.NewLRUCache(1000, func(_ interface{}) int64 {
|
||||
recentlyUnregistered: cache.NewLRUCache(1000, func(_ any) int64 {
|
||||
return 1
|
||||
}),
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ func NewNumbered() *Numbered {
|
|||
// Register starts tracking a resource by the supplied id.
|
||||
// It does not lock the object.
|
||||
// It returns an error if the id already exists.
|
||||
func (nu *Numbered) Register(id int64, val interface{}, enforceTimeout bool) error {
|
||||
func (nu *Numbered) Register(id int64, val any, enforceTimeout bool) error {
|
||||
// Optimistically assume we're not double registering.
|
||||
now := time.Now()
|
||||
resource := &numberedWrapper{
|
||||
|
@ -109,7 +109,7 @@ func (nu *Numbered) unregister(id int64) bool {
|
|||
// Get locks the resource for use. It accepts a purpose as a string.
|
||||
// If it cannot be found, it returns a "not found" error. If in use,
|
||||
// it returns a "in use: purpose" error.
|
||||
func (nu *Numbered) Get(id int64, purpose string) (val interface{}, err error) {
|
||||
func (nu *Numbered) Get(id int64, purpose string) (val any, err error) {
|
||||
nu.mu.Lock()
|
||||
defer nu.mu.Unlock()
|
||||
nw, ok := nu.resources[id]
|
||||
|
@ -142,10 +142,10 @@ func (nu *Numbered) Put(id int64, updateTime bool) {
|
|||
}
|
||||
|
||||
// GetAll returns the list of all resources in the pool.
|
||||
func (nu *Numbered) GetAll() (vals []interface{}) {
|
||||
func (nu *Numbered) GetAll() (vals []any) {
|
||||
nu.mu.Lock()
|
||||
defer nu.mu.Unlock()
|
||||
vals = make([]interface{}, 0, len(nu.resources))
|
||||
vals = make([]any, 0, len(nu.resources))
|
||||
for _, nw := range nu.resources {
|
||||
vals = append(vals, nw.val)
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ func (nu *Numbered) GetAll() (vals []interface{}) {
|
|||
|
||||
// GetByFilter returns a list of resources that match the filter.
|
||||
// It does not return any resources that are already locked.
|
||||
func (nu *Numbered) GetByFilter(purpose string, match func(val interface{}) bool) (vals []interface{}) {
|
||||
func (nu *Numbered) GetByFilter(purpose string, match func(val any) bool) (vals []any) {
|
||||
nu.mu.Lock()
|
||||
defer nu.mu.Unlock()
|
||||
for _, nw := range nu.resources {
|
||||
|
@ -172,7 +172,7 @@ func (nu *Numbered) GetByFilter(purpose string, match func(val interface{}) bool
|
|||
|
||||
// GetOutdated returns a list of resources that are older than age, and locks them.
|
||||
// It does not return any resources that are already locked.
|
||||
func (nu *Numbered) GetOutdated(age time.Duration, purpose string) (vals []interface{}) {
|
||||
func (nu *Numbered) GetOutdated(age time.Duration, purpose string) (vals []any) {
|
||||
nu.mu.Lock()
|
||||
defer nu.mu.Unlock()
|
||||
now := time.Now()
|
||||
|
@ -192,7 +192,7 @@ func (nu *Numbered) GetOutdated(age time.Duration, purpose string) (vals []inter
|
|||
// GetIdle returns a list of resurces that have been idle for longer
|
||||
// than timeout, and locks them. It does not return any resources that
|
||||
// are already locked.
|
||||
func (nu *Numbered) GetIdle(timeout time.Duration, purpose string) (vals []interface{}) {
|
||||
func (nu *Numbered) GetIdle(timeout time.Duration, purpose string) (vals []any) {
|
||||
nu.mu.Lock()
|
||||
defer nu.mu.Unlock()
|
||||
now := time.Now()
|
||||
|
|
|
@ -36,7 +36,7 @@ func TestNumberedGeneral(t *testing.T) {
|
|||
err = p.Register(id, id, true)
|
||||
assert.Contains(t, "already present", err.Error())
|
||||
|
||||
var v interface{}
|
||||
var v any
|
||||
v, err = p.Get(id, "test")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, id, v.(int64))
|
||||
|
@ -112,10 +112,10 @@ func TestNumberedGetByFilter(t *testing.T) {
|
|||
p.Register(3, 3, true)
|
||||
p.Get(1, "locked")
|
||||
|
||||
vals := p.GetByFilter("filtered", func(v interface{}) bool {
|
||||
vals := p.GetByFilter("filtered", func(v any) bool {
|
||||
return v.(int) <= 2
|
||||
})
|
||||
want := []interface{}{2}
|
||||
want := []any{2}
|
||||
assert.Equal(t, want, vals)
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ func ProtoToValue(v *querypb.Value) Value {
|
|||
}
|
||||
|
||||
// BuildBindVariables builds a map[string]*querypb.BindVariable from a map[string]interface{}.
|
||||
func BuildBindVariables(in map[string]interface{}) (map[string]*querypb.BindVariable, error) {
|
||||
func BuildBindVariables(in map[string]any) (map[string]*querypb.BindVariable, error) {
|
||||
if len(in) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ func ValueBindVariable(v Value) *querypb.BindVariable {
|
|||
}
|
||||
|
||||
// BuildBindVariable builds a *querypb.BindVariable from a valid input type.
|
||||
func BuildBindVariable(v interface{}) (*querypb.BindVariable, error) {
|
||||
func BuildBindVariable(v any) (*querypb.BindVariable, error) {
|
||||
switch v := v.(type) {
|
||||
case string:
|
||||
return StringBindVariable(v), nil
|
||||
|
@ -166,7 +166,7 @@ func BuildBindVariable(v interface{}) (*querypb.BindVariable, error) {
|
|||
return ValueBindVariable(v), nil
|
||||
case *querypb.BindVariable:
|
||||
return v, nil
|
||||
case []interface{}:
|
||||
case []any:
|
||||
bv := &querypb.BindVariable{
|
||||
Type: querypb.Type_TUPLE,
|
||||
Values: make([]*querypb.Value, len(v)),
|
||||
|
|
|
@ -43,21 +43,21 @@ func TestProtoConversions(t *testing.T) {
|
|||
|
||||
func TestBuildBindVariables(t *testing.T) {
|
||||
tcases := []struct {
|
||||
in map[string]interface{}
|
||||
in map[string]any
|
||||
out map[string]*querypb.BindVariable
|
||||
err string
|
||||
}{{
|
||||
in: nil,
|
||||
out: nil,
|
||||
}, {
|
||||
in: map[string]interface{}{
|
||||
in: map[string]any{
|
||||
"k": int64(1),
|
||||
},
|
||||
out: map[string]*querypb.BindVariable{
|
||||
"k": Int64BindVariable(1),
|
||||
},
|
||||
}, {
|
||||
in: map[string]interface{}{
|
||||
in: map[string]any{
|
||||
"k": byte(1),
|
||||
},
|
||||
err: "k: type uint8 not supported as bind var: 1",
|
||||
|
@ -82,7 +82,7 @@ func TestBuildBindVariables(t *testing.T) {
|
|||
|
||||
func TestBuildBindVariable(t *testing.T) {
|
||||
tcases := []struct {
|
||||
in interface{}
|
||||
in any
|
||||
out *querypb.BindVariable
|
||||
err string
|
||||
}{{
|
||||
|
@ -152,7 +152,7 @@ func TestBuildBindVariable(t *testing.T) {
|
|||
Value: []byte("1"),
|
||||
},
|
||||
}, {
|
||||
in: []interface{}{"aa", int64(1)},
|
||||
in: []any{"aa", int64(1)},
|
||||
out: &querypb.BindVariable{
|
||||
Type: querypb.Type_TUPLE,
|
||||
Values: []*querypb.Value{{
|
||||
|
@ -239,7 +239,7 @@ func TestBuildBindVariable(t *testing.T) {
|
|||
in: byte(1),
|
||||
err: "type uint8 not supported as bind var: 1",
|
||||
}, {
|
||||
in: []interface{}{1, byte(1)},
|
||||
in: []any{1, byte(1)},
|
||||
err: "type uint8 not supported as bind var: 1",
|
||||
}}
|
||||
for _, tcase := range tcases {
|
||||
|
|
|
@ -113,7 +113,7 @@ func MakeTestStreamingResults(fields []*querypb.Field, rows ...string) []*Result
|
|||
// TestBindVariable makes a *querypb.BindVariable from
|
||||
// an interface{}.It panics on invalid input.
|
||||
// This function should only be used for testing.
|
||||
func TestBindVariable(v interface{}) *querypb.BindVariable {
|
||||
func TestBindVariable(v any) *querypb.BindVariable {
|
||||
if v == nil {
|
||||
return NullBindVariable
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ func NewIntegral(val string) (n Value, err error) {
|
|||
// string and []byte.
|
||||
// This function is deprecated. Use the type-specific
|
||||
// functions instead.
|
||||
func InterfaceToValue(goval interface{}) (Value, error) {
|
||||
func InterfaceToValue(goval any) (Value, error) {
|
||||
switch goval := goval.(type) {
|
||||
case nil:
|
||||
return NULL, nil
|
||||
|
@ -458,7 +458,7 @@ func (v *Value) UnmarshalJSON(b []byte) error {
|
|||
if len(b) == 0 {
|
||||
return fmt.Errorf("error unmarshaling empty bytes")
|
||||
}
|
||||
var val interface{}
|
||||
var val any
|
||||
var err error
|
||||
switch b[0] {
|
||||
case '-':
|
||||
|
|
|
@ -261,7 +261,7 @@ func TestIntegralValue(t *testing.T) {
|
|||
|
||||
func TestInterfaceValue(t *testing.T) {
|
||||
testcases := []struct {
|
||||
in interface{}
|
||||
in any
|
||||
out Value
|
||||
}{{
|
||||
in: nil,
|
||||
|
|
|
@ -247,7 +247,7 @@ func (dc *dataCollector) addExpVar(kv expvar.KeyValue) {
|
|||
default:
|
||||
// Deal with generic expvars by converting them to JSON and pulling out
|
||||
// all the floats. Strings and lists will not be exported to opentsdb.
|
||||
var obj map[string]interface{}
|
||||
var obj map[string]any
|
||||
if err := json.Unmarshal([]byte(v.String()), &obj); err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -274,11 +274,11 @@ func makeLabels(labelNames []string, labelValsCombined string) map[string]string
|
|||
}
|
||||
|
||||
// addUnrecognizedExpvars recurses into a json object to pull out float64 variables to report.
|
||||
func (dc *dataCollector) addUnrecognizedExpvars(prefix string, obj map[string]interface{}) {
|
||||
func (dc *dataCollector) addUnrecognizedExpvars(prefix string, obj map[string]any) {
|
||||
for k, v := range obj {
|
||||
prefix := combineMetricName(prefix, k)
|
||||
switch v := v.(type) {
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
dc.addUnrecognizedExpvars(prefix, v)
|
||||
case float64:
|
||||
dc.addFloat(prefix, v, nil)
|
||||
|
|
|
@ -375,14 +375,14 @@ func checkOutput(t *testing.T, statName string, wantJSON string) {
|
|||
t.Errorf("Failed to marshal json: %v", err)
|
||||
return
|
||||
}
|
||||
var got interface{}
|
||||
var got any
|
||||
err = json.Unmarshal(gotBytes, &got)
|
||||
if err != nil {
|
||||
t.Errorf("Failed to marshal json: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
var want interface{}
|
||||
var want any
|
||||
err = json.Unmarshal([]byte(wantJSON), &want)
|
||||
if err != nil {
|
||||
t.Errorf("Failed to marshal json: %v", err)
|
||||
|
|
|
@ -174,7 +174,7 @@ func (sb StatsBackend) addExpVar(kv expvar.KeyValue) {
|
|||
case expvar.Func:
|
||||
// Export memstats as gauge so that we don't need to call extra ReadMemStats
|
||||
if k == "memstats" {
|
||||
var obj map[string]interface{}
|
||||
var obj map[string]any
|
||||
if err := json.Unmarshal([]byte(v.String()), &obj); err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -72,12 +72,12 @@ type StreamLogger struct {
|
|||
name string
|
||||
size int
|
||||
mu sync.Mutex
|
||||
subscribed map[chan interface{}]string
|
||||
subscribed map[chan any]string
|
||||
}
|
||||
|
||||
// LogFormatter is the function signature used to format an arbitrary
|
||||
// message for the given output writer.
|
||||
type LogFormatter func(out io.Writer, params url.Values, message interface{}) error
|
||||
type LogFormatter func(out io.Writer, params url.Values, message any) error
|
||||
|
||||
// New returns a new StreamLogger that can stream events to subscribers.
|
||||
// The size parameter defines the channel size for the subscribers.
|
||||
|
@ -85,13 +85,13 @@ func New(name string, size int) *StreamLogger {
|
|||
return &StreamLogger{
|
||||
name: name,
|
||||
size: size,
|
||||
subscribed: make(map[chan interface{}]string),
|
||||
subscribed: make(map[chan any]string),
|
||||
}
|
||||
}
|
||||
|
||||
// Send sends message to all the writers subscribed to logger. Calling
|
||||
// Send does not block.
|
||||
func (logger *StreamLogger) Send(message interface{}) {
|
||||
func (logger *StreamLogger) Send(message any) {
|
||||
logger.mu.Lock()
|
||||
defer logger.mu.Unlock()
|
||||
|
||||
|
@ -108,17 +108,17 @@ func (logger *StreamLogger) Send(message interface{}) {
|
|||
|
||||
// Subscribe returns a channel which can be used to listen
|
||||
// for messages.
|
||||
func (logger *StreamLogger) Subscribe(name string) chan interface{} {
|
||||
func (logger *StreamLogger) Subscribe(name string) chan any {
|
||||
logger.mu.Lock()
|
||||
defer logger.mu.Unlock()
|
||||
|
||||
ch := make(chan interface{}, logger.size)
|
||||
ch := make(chan any, logger.size)
|
||||
logger.subscribed[ch] = name
|
||||
return ch
|
||||
}
|
||||
|
||||
// Unsubscribe removes the channel from the subscription.
|
||||
func (logger *StreamLogger) Unsubscribe(ch chan interface{}) {
|
||||
func (logger *StreamLogger) Unsubscribe(ch chan any) {
|
||||
logger.mu.Lock()
|
||||
defer logger.mu.Unlock()
|
||||
|
||||
|
@ -163,7 +163,7 @@ func (logger *StreamLogger) ServeLogs(url string, logf LogFormatter) {
|
|||
//
|
||||
// Returns the channel used for the subscription which can be used to close
|
||||
// it.
|
||||
func (logger *StreamLogger) LogToFile(path string, logf LogFormatter) (chan interface{}, error) {
|
||||
func (logger *StreamLogger) LogToFile(path string, logf LogFormatter) (chan any, error) {
|
||||
rotateChan := make(chan os.Signal, 1)
|
||||
signal.Notify(rotateChan, syscall.SIGUSR2)
|
||||
|
||||
|
@ -199,7 +199,7 @@ type Formatter interface {
|
|||
// GetFormatter returns a formatter function for objects conforming to the
|
||||
// Formatter interface
|
||||
func GetFormatter(logger *StreamLogger) LogFormatter {
|
||||
return func(w io.Writer, params url.Values, val interface{}) error {
|
||||
return func(w io.Writer, params url.Values, val any) error {
|
||||
fmter, ok := val.(Formatter)
|
||||
if !ok {
|
||||
_, err := fmt.Fprintf(w, "Error: unexpected value of type %T in %s!", val, logger.Name())
|
||||
|
|
|
@ -38,7 +38,7 @@ func (l *logMessage) Format(params url.Values) string {
|
|||
return l.val + "\n"
|
||||
}
|
||||
|
||||
func testLogf(w io.Writer, params url.Values, m interface{}) error {
|
||||
func testLogf(w io.Writer, params url.Values, m any) error {
|
||||
_, err := io.WriteString(w, m.(*logMessage).Format(params))
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ type Result struct {
|
|||
executing sync.RWMutex
|
||||
consolidator *Consolidator
|
||||
query string
|
||||
Result interface{}
|
||||
Result any
|
||||
Err error
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ type ConsolidatorCache struct {
|
|||
|
||||
// NewConsolidatorCache creates a new cache with the given capacity.
|
||||
func NewConsolidatorCache(capacity int64) *ConsolidatorCache {
|
||||
return &ConsolidatorCache{cache.NewLRUCache(capacity, func(_ interface{}) int64 {
|
||||
return &ConsolidatorCache{cache.NewLRUCache(capacity, func(_ any) int64 {
|
||||
return 1
|
||||
})}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ func (e stackError) StackTrace() string {
|
|||
return e.stackTrace
|
||||
}
|
||||
|
||||
func Errorf(msg string, args ...interface{}) error {
|
||||
func Errorf(msg string, args ...any) error {
|
||||
stack := ""
|
||||
// See if any arg is already embedding a stack - no need to
|
||||
// recompute something expensive and make the message unreadable.
|
||||
|
|
|
@ -312,7 +312,7 @@ func validateManifestFile(t *testing.T, backupLocation string) {
|
|||
// reading manifest
|
||||
data, err := os.ReadFile(backupLocation + "/MANIFEST")
|
||||
require.Nilf(t, err, "error while reading MANIFEST %v", err)
|
||||
manifest := make(map[string]interface{})
|
||||
manifest := make(map[string]any)
|
||||
|
||||
// parsing manifest
|
||||
err = json.Unmarshal(data, &manifest)
|
||||
|
@ -326,7 +326,7 @@ func validateManifestFile(t *testing.T, backupLocation string) {
|
|||
|
||||
// validate backup files
|
||||
fielEntries := manifest["FileEntries"]
|
||||
fileArr, ok := fielEntries.([]interface{})
|
||||
fileArr, ok := fielEntries.([]any)
|
||||
require.True(t, ok)
|
||||
for i := range fileArr {
|
||||
f, err := os.Open(fmt.Sprintf("%s/%d", backupLocation, i))
|
||||
|
|
|
@ -247,7 +247,7 @@ func (cluster *LocalProcessCluster) StartUnshardedKeyspace(keyspace Keyspace, re
|
|||
// rdonly: whether readonly tablets needed
|
||||
// customizers: functions like "func(*VttabletProcess)" that can modify settings of various objects
|
||||
// after they're created.
|
||||
func (cluster *LocalProcessCluster) StartKeyspace(keyspace Keyspace, shardNames []string, replicaCount int, rdonly bool, customizers ...interface{}) (err error) {
|
||||
func (cluster *LocalProcessCluster) StartKeyspace(keyspace Keyspace, shardNames []string, replicaCount int, rdonly bool, customizers ...any) (err error) {
|
||||
totalTabletsRequired := replicaCount + 1 // + 1 is for primary
|
||||
if rdonly {
|
||||
totalTabletsRequired = totalTabletsRequired + 1 // + 1 for rdonly
|
||||
|
@ -388,7 +388,7 @@ func (cluster *LocalProcessCluster) StartUnshardedKeyspaceLegacy(keyspace Keyspa
|
|||
// rdonly: whether readonly tablets needed
|
||||
// customizers: functions like "func(*VttabletProcess)" that can modify settings of various objects
|
||||
// after they're created.
|
||||
func (cluster *LocalProcessCluster) StartKeyspaceLegacy(keyspace Keyspace, shardNames []string, replicaCount int, rdonly bool, customizers ...interface{}) (err error) {
|
||||
func (cluster *LocalProcessCluster) StartKeyspaceLegacy(keyspace Keyspace, shardNames []string, replicaCount int, rdonly bool, customizers ...any) (err error) {
|
||||
totalTabletsRequired := replicaCount + 1 // + 1 is for primary
|
||||
if rdonly {
|
||||
totalTabletsRequired = totalTabletsRequired + 1 // + 1 for rdonly
|
||||
|
|
|
@ -157,7 +157,7 @@ func (vtgate *VtgateProcess) GetStatusForTabletOfShard(name string, endPointsCou
|
|||
return false
|
||||
}
|
||||
if resp.StatusCode == 200 {
|
||||
resultMap := make(map[string]interface{})
|
||||
resultMap := make(map[string]any)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
err := json.Unmarshal(respByte, &resultMap)
|
||||
if err != nil {
|
||||
|
@ -258,8 +258,8 @@ func VtgateProcessInstance(
|
|||
}
|
||||
|
||||
// GetVars returns map of vars
|
||||
func (vtgate *VtgateProcess) GetVars() (map[string]interface{}, error) {
|
||||
resultMap := make(map[string]interface{})
|
||||
func (vtgate *VtgateProcess) GetVars() (map[string]any, error) {
|
||||
resultMap := make(map[string]any)
|
||||
resp, err := http.Get(vtgate.VerifyURL)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error getting response from %s", vtgate.VerifyURL)
|
||||
|
|
|
@ -173,13 +173,13 @@ func (vttablet *VttabletProcess) GetStatus() string {
|
|||
}
|
||||
|
||||
// GetVars gets the debug vars as map
|
||||
func (vttablet *VttabletProcess) GetVars() map[string]interface{} {
|
||||
func (vttablet *VttabletProcess) GetVars() map[string]any {
|
||||
resp, err := http.Get(vttablet.VerifyURL)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
if resp.StatusCode == 200 {
|
||||
resultMap := make(map[string]interface{})
|
||||
resultMap := make(map[string]any)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
err := json.Unmarshal(respByte, &resultMap)
|
||||
if err != nil {
|
||||
|
|
|
@ -215,8 +215,8 @@ func VtworkerProcessInstance(httpPort int, grpcPort int, topoPort int, hostname
|
|||
}
|
||||
|
||||
// GetVars returns map of vars
|
||||
func (vtworker *VtworkerProcess) GetVars() (map[string]interface{}, error) {
|
||||
resultMap := make(map[string]interface{})
|
||||
func (vtworker *VtworkerProcess) GetVars() (map[string]any, error) {
|
||||
resultMap := make(map[string]any)
|
||||
resp, err := http.Get(vtworker.VerifyURL)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error getting response from %s", vtworker.VerifyURL)
|
||||
|
|
|
@ -65,7 +65,7 @@ func testTopoDataAPI(t *testing.T, url string) {
|
|||
require.Nil(t, err)
|
||||
assert.Equal(t, resp.StatusCode, 200)
|
||||
|
||||
resultMap := make(map[string]interface{})
|
||||
resultMap := make(map[string]any)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
err = json.Unmarshal(respByte, &resultMap)
|
||||
require.Nil(t, err)
|
||||
|
|
|
@ -54,7 +54,7 @@ func TestVtgateProcess(t *testing.T) {
|
|||
func verifyVtgateVariables(t *testing.T, url string) {
|
||||
resp, _ := http.Get(url)
|
||||
if resp != nil && resp.StatusCode == 200 {
|
||||
resultMap := make(map[string]interface{})
|
||||
resultMap := make(map[string]any)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
err := json.Unmarshal(respByte, &resultMap)
|
||||
require.Nil(t, err)
|
||||
|
@ -90,8 +90,8 @@ func verifyVtgateVariables(t *testing.T, url string) {
|
|||
}
|
||||
}
|
||||
|
||||
func getMapFromJSON(JSON map[string]interface{}, key string) map[string]interface{} {
|
||||
result := make(map[string]interface{})
|
||||
func getMapFromJSON(JSON map[string]any, key string) map[string]any {
|
||||
result := make(map[string]any)
|
||||
object := reflect.ValueOf(JSON[key])
|
||||
if object.Kind() == reflect.Map {
|
||||
for _, key := range object.MapKeys() {
|
||||
|
@ -102,7 +102,7 @@ func getMapFromJSON(JSON map[string]interface{}, key string) map[string]interfac
|
|||
return result
|
||||
}
|
||||
|
||||
func isPrimaryTabletPresent(tablets map[string]interface{}) bool {
|
||||
func isPrimaryTabletPresent(tablets map[string]any) bool {
|
||||
for key := range tablets {
|
||||
if strings.Contains(key, "primary") {
|
||||
return true
|
||||
|
|
|
@ -34,7 +34,7 @@ func TestVttabletProcess(t *testing.T) {
|
|||
firstTabletPort := clusterInstance.Keyspaces[0].Shards[0].Vttablets[0].HTTPPort
|
||||
testURL(t, fmt.Sprintf("http://localhost:%d/debug/vars/", firstTabletPort), "tablet debug var url")
|
||||
resp, _ := http.Get(fmt.Sprintf("http://localhost:%d/debug/vars", firstTabletPort))
|
||||
resultMap := make(map[string]interface{})
|
||||
resultMap := make(map[string]any)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
err := json.Unmarshal(respByte, &resultMap)
|
||||
if err != nil {
|
||||
|
|
|
@ -517,7 +517,7 @@ func getClientCount(vttablet *cluster.Vttablet) int {
|
|||
return 0
|
||||
}
|
||||
|
||||
v, ok := msg.(map[string]interface{})
|
||||
v, ok := msg.(map[string]any)
|
||||
if !ok {
|
||||
return 0
|
||||
}
|
||||
|
@ -536,13 +536,13 @@ func getClientCount(vttablet *cluster.Vttablet) int {
|
|||
}
|
||||
|
||||
// getVar read debug vars from the vttablet.
|
||||
func getVar(vttablet *cluster.Vttablet) (map[string]interface{}, error) {
|
||||
func getVar(vttablet *cluster.Vttablet) (map[string]any, error) {
|
||||
resp, err := http.Get(fmt.Sprintf("http://%s:%d/debug/vars", vttablet.VttabletProcess.TabletHostname, vttablet.HTTPPort))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if resp.StatusCode == 200 {
|
||||
resultMap := make(map[string]interface{})
|
||||
resultMap := make(map[string]any)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
err := json.Unmarshal(respByte, &resultMap)
|
||||
return resultMap, err
|
||||
|
|
|
@ -251,7 +251,7 @@ func startCluster(t *testing.T) string {
|
|||
return yamlFile
|
||||
}
|
||||
|
||||
func createKeyspace(t *testing.T, ks cluster.Keyspace, shards []string, customizers ...interface{}) {
|
||||
func createKeyspace(t *testing.T, ks cluster.Keyspace, shards []string, customizers ...any) {
|
||||
t.Helper()
|
||||
|
||||
err := clusterInstance.StartKeyspace(ks, shards, 1, false, customizers...)
|
||||
|
|
|
@ -261,7 +261,7 @@ func Connect(t *testing.T, params ...string) *sql.DB {
|
|||
}
|
||||
|
||||
// execWithError executes the prepared query, and validates the error_code.
|
||||
func execWithError(t *testing.T, dbo *sql.DB, errorCodes []uint16, stmt string, params ...interface{}) {
|
||||
func execWithError(t *testing.T, dbo *sql.DB, errorCodes []uint16, stmt string, params ...any) {
|
||||
_, err := dbo.Exec(stmt, params...)
|
||||
require.NotNilf(t, err, "error expected, got nil")
|
||||
mysqlErr, ok := err.(*mysql.MySQLError)
|
||||
|
@ -270,12 +270,12 @@ func execWithError(t *testing.T, dbo *sql.DB, errorCodes []uint16, stmt string,
|
|||
}
|
||||
|
||||
// exec executes the query using the params.
|
||||
func exec(t *testing.T, dbo *sql.DB, stmt string, params ...interface{}) {
|
||||
func exec(t *testing.T, dbo *sql.DB, stmt string, params ...any) {
|
||||
require.Nil(t, execErr(dbo, stmt, params...))
|
||||
}
|
||||
|
||||
// execErr executes the query and returns an error if one occurs.
|
||||
func execErr(dbo *sql.DB, stmt string, params ...interface{}) *mysql.MySQLError {
|
||||
func execErr(dbo *sql.DB, stmt string, params ...any) *mysql.MySQLError {
|
||||
if _, err := dbo.Exec(stmt, params...); err != nil {
|
||||
// TODO : need to handle
|
||||
mysqlErr, _ := err.(*mysql.MySQLError)
|
||||
|
@ -285,7 +285,7 @@ func execErr(dbo *sql.DB, stmt string, params ...interface{}) *mysql.MySQLError
|
|||
}
|
||||
|
||||
// selectWhere select the row corresponding to the where condition.
|
||||
func selectWhere(t *testing.T, dbo *sql.DB, where string, params ...interface{}) []tableData {
|
||||
func selectWhere(t *testing.T, dbo *sql.DB, where string, params ...any) []tableData {
|
||||
var out []tableData
|
||||
// prepare query
|
||||
qry := "SELECT msg, data, text_col, t_datetime, t_datetime_micros FROM " + tableName
|
||||
|
@ -307,7 +307,7 @@ func selectWhere(t *testing.T, dbo *sql.DB, where string, params ...interface{})
|
|||
}
|
||||
|
||||
// selectWhereWithTx select the row corresponding to the where condition.
|
||||
func selectWhereWithTx(t *testing.T, tx *sql.Tx, where string, params ...interface{}) []tableData {
|
||||
func selectWhereWithTx(t *testing.T, tx *sql.Tx, where string, params ...any) []tableData {
|
||||
var out []tableData
|
||||
// prepare query
|
||||
qry := "SELECT msg, data, text_col, t_datetime, t_datetime_micros FROM " + tableName
|
||||
|
|
|
@ -73,7 +73,7 @@ func TestInsertUpdateDelete(t *testing.T) {
|
|||
// inserting multiple rows into test table
|
||||
for i := 1; i <= 100; i++ {
|
||||
// preparing value for the insert testing
|
||||
insertValue := []interface{}{
|
||||
insertValue := []any{
|
||||
i, strconv.FormatInt(int64(i), 10) + "21", i * 100,
|
||||
127, 1, 32767, 8388607, 2147483647, 2.55, 64.9, 55.5,
|
||||
time.Date(2009, 5, 5, 0, 0, 0, 50000, time.UTC),
|
||||
|
@ -165,7 +165,7 @@ func TestAutoIncColumns(t *testing.T) {
|
|||
) VALUES (?, ?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);`
|
||||
insertValue := []interface{}{
|
||||
insertValue := []any{
|
||||
"21", 0,
|
||||
127, 1, 32767, 8388607, 2147483647, 2.55, 64.9, 55.5,
|
||||
time.Date(2009, 5, 5, 0, 0, 0, 50000, time.UTC),
|
||||
|
@ -235,7 +235,7 @@ func TestColumnParameter(t *testing.T) {
|
|||
parameter1 := "param1"
|
||||
message := "TestColumnParameter"
|
||||
insertStmt := "INSERT INTO " + tableName + " (id, msg, keyspace_id) VALUES (?, ?, ?);"
|
||||
values := []interface{}{
|
||||
values := []any{
|
||||
id,
|
||||
message,
|
||||
2000,
|
||||
|
|
|
@ -702,7 +702,7 @@ func positionAtLeast(t *testing.T, tablet *cluster.Vttablet, a string, b string)
|
|||
}
|
||||
|
||||
func assertNodeCount(t *testing.T, result string, want int) {
|
||||
resultMap := make(map[string]interface{})
|
||||
resultMap := make(map[string]any)
|
||||
err := json.Unmarshal([]byte(result), &resultMap)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
|
@ -229,7 +229,7 @@ func TestMergesharding(t *testing.T, useVarbinaryShardingKeyType bool) {
|
|||
// check for shards
|
||||
result, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("FindAllShardsInKeyspace", keyspaceName)
|
||||
require.NoError(t, err)
|
||||
resultMap := make(map[string]interface{})
|
||||
resultMap := make(map[string]any)
|
||||
err = json.Unmarshal([]byte(result), &resultMap)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 4, len(resultMap), "No of shards should be 4")
|
||||
|
|
|
@ -320,7 +320,7 @@ func TestResharding(t *testing.T, useVarbinaryShardingKeyType bool) {
|
|||
// check for shards
|
||||
result, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("FindAllShardsInKeyspace", keyspaceName)
|
||||
require.Nil(t, err)
|
||||
resultMap := make(map[string]interface{})
|
||||
resultMap := make(map[string]any)
|
||||
err = json.Unmarshal([]byte(result), &resultMap)
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, 4, len(resultMap), "No of shards should be 4")
|
||||
|
|
|
@ -469,21 +469,21 @@ func checkStats(t *testing.T) {
|
|||
resultMap, err := clusterInstance.VtgateProcess.GetVars()
|
||||
require.NoError(t, err)
|
||||
resultVtTabletCall := resultMap["VttabletCall"]
|
||||
resultVtTabletCallMap := resultVtTabletCall.(map[string]interface{})
|
||||
resultVtTabletCallMap := resultVtTabletCall.(map[string]any)
|
||||
resultHistograms := resultVtTabletCallMap["Histograms"]
|
||||
resultHistogramsMap := resultHistograms.(map[string]interface{})
|
||||
resultHistogramsMap := resultHistograms.(map[string]any)
|
||||
resultTablet := resultHistogramsMap["Execute.source_keyspace.0.replica"]
|
||||
resultTableMap := resultTablet.(map[string]interface{})
|
||||
resultTableMap := resultTablet.(map[string]any)
|
||||
resultCountStr := fmt.Sprintf("%v", reflect.ValueOf(resultTableMap["Count"]))
|
||||
assert.Equal(t, "2", resultCountStr, fmt.Sprintf("unexpected value for VttabletCall(Execute.source_keyspace.0.replica) inside %s", resultCountStr))
|
||||
|
||||
// Verify primary reads done by self._check_client_conn_redirection().
|
||||
resultVtgateAPI := resultMap["VtgateApi"]
|
||||
resultVtgateAPIMap := resultVtgateAPI.(map[string]interface{})
|
||||
resultVtgateAPIMap := resultVtgateAPI.(map[string]any)
|
||||
resultAPIHistograms := resultVtgateAPIMap["Histograms"]
|
||||
resultAPIHistogramsMap := resultAPIHistograms.(map[string]interface{})
|
||||
resultAPIHistogramsMap := resultAPIHistograms.(map[string]any)
|
||||
resultTabletDestination := resultAPIHistogramsMap["Execute.destination_keyspace.primary"]
|
||||
resultTabletDestinationMap := resultTabletDestination.(map[string]interface{})
|
||||
resultTabletDestinationMap := resultTabletDestination.(map[string]any)
|
||||
resultCountStrDestination := fmt.Sprintf("%v", reflect.ValueOf(resultTabletDestinationMap["Count"]))
|
||||
assert.Equal(t, "6", resultCountStrDestination, fmt.Sprintf("unexpected value for VtgateApi(Execute.destination_keyspace.primary) inside %s)", resultCountStrDestination))
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ func verifyVtgateVariables(t *testing.T, url string) {
|
|||
require.NoError(t, err)
|
||||
require.Equal(t, 200, resp.StatusCode, "Vtgate api url response not found")
|
||||
|
||||
resultMap := make(map[string]interface{})
|
||||
resultMap := make(map[string]any)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
err = json.Unmarshal(respByte, &resultMap)
|
||||
require.NoError(t, err)
|
||||
|
@ -216,8 +216,8 @@ func TestReplicaTransactions(t *testing.T) {
|
|||
assert.Equal(t, `[[INT64(1) VARCHAR("email1")] [INT64(2) VARCHAR("email2")]]`, fmt.Sprintf("%v", qr4.Rows), "we are not able to reconnect after restart")
|
||||
}
|
||||
|
||||
func getMapFromJSON(JSON map[string]interface{}, key string) map[string]interface{} {
|
||||
result := make(map[string]interface{})
|
||||
func getMapFromJSON(JSON map[string]any, key string) map[string]any {
|
||||
result := make(map[string]any)
|
||||
object := reflect.ValueOf(JSON[key])
|
||||
if object.Kind() == reflect.Map {
|
||||
for _, key := range object.MapKeys() {
|
||||
|
@ -228,7 +228,7 @@ func getMapFromJSON(JSON map[string]interface{}, key string) map[string]interfac
|
|||
return result
|
||||
}
|
||||
|
||||
func isPrimaryTabletPresent(tablets map[string]interface{}) bool {
|
||||
func isPrimaryTabletPresent(tablets map[string]any) bool {
|
||||
for key := range tablets {
|
||||
if strings.Contains(key, "primary") {
|
||||
return true
|
||||
|
|
|
@ -124,11 +124,11 @@ func TestTabletCommands(t *testing.T) {
|
|||
}
|
||||
|
||||
func assertExcludeFields(t *testing.T, qr string) {
|
||||
resultMap := make(map[string]interface{})
|
||||
resultMap := make(map[string]any)
|
||||
err := json.Unmarshal([]byte(qr), &resultMap)
|
||||
require.Nil(t, err)
|
||||
|
||||
rows := resultMap["rows"].([]interface{})
|
||||
rows := resultMap["rows"].([]any)
|
||||
assert.Equal(t, 2, len(rows))
|
||||
|
||||
fields := resultMap["fields"]
|
||||
|
@ -136,7 +136,7 @@ func assertExcludeFields(t *testing.T, qr string) {
|
|||
}
|
||||
|
||||
func assertExecuteFetch(t *testing.T, qr string) {
|
||||
resultMap := make(map[string]interface{})
|
||||
resultMap := make(map[string]any)
|
||||
err := json.Unmarshal([]byte(qr), &resultMap)
|
||||
require.Nil(t, err)
|
||||
|
||||
|
@ -196,7 +196,7 @@ func runHookAndAssert(t *testing.T, params []string, expectedStatus string, expe
|
|||
} else {
|
||||
require.Nil(t, err)
|
||||
|
||||
resultMap := make(map[string]interface{})
|
||||
resultMap := make(map[string]any)
|
||||
err = json.Unmarshal([]byte(hr), &resultMap)
|
||||
require.Nil(t, err)
|
||||
|
||||
|
@ -247,7 +247,7 @@ func TestGetSchema(t *testing.T) {
|
|||
}
|
||||
|
||||
func assertNodeCount(t *testing.T, result string, want int) {
|
||||
resultMap := make(map[string]interface{})
|
||||
resultMap := make(map[string]any)
|
||||
err := json.Unmarshal([]byte(result), &resultMap)
|
||||
require.Nil(t, err)
|
||||
|
||||
|
|
|
@ -81,11 +81,11 @@ func TestTopoCustomRule(t *testing.T) {
|
|||
// Verify that query is working
|
||||
result, err := vtctlExec("select id, value from t1", rTablet.Alias)
|
||||
require.NoError(t, err)
|
||||
resultMap := make(map[string]interface{})
|
||||
resultMap := make(map[string]any)
|
||||
err = json.Unmarshal([]byte(result), &resultMap)
|
||||
require.NoError(t, err)
|
||||
|
||||
rowsAffected := resultMap["rows"].([]interface{})
|
||||
rowsAffected := resultMap["rows"].([]any)
|
||||
assert.EqualValues(t, 2, len(rowsAffected))
|
||||
|
||||
// Now update the topocustomrule file.
|
||||
|
|
|
@ -112,7 +112,7 @@ func TestTopoRestart(t *testing.T) {
|
|||
|
||||
defer execute(t, conn, `delete from t1`)
|
||||
|
||||
ch := make(chan interface{})
|
||||
ch := make(chan any)
|
||||
|
||||
go func() {
|
||||
clusterInstance.TopoProcess.TearDown(clusterInstance.Cell, clusterInstance.OriginalVTDATAROOT, clusterInstance.CurrentVTDATAROOT, true, *clusterInstance.TopoFlavorString())
|
||||
|
|
|
@ -125,13 +125,13 @@ func TestStandalone(t *testing.T) {
|
|||
resp, err := http.Get(fmt.Sprintf("http://%s/debug/vars", vtctldAddr))
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, 200, resp.StatusCode)
|
||||
resultMap := make(map[string]interface{})
|
||||
resultMap := make(map[string]any)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
err = json.Unmarshal(respByte, &resultMap)
|
||||
require.Nil(t, err)
|
||||
cmd := resultMap["cmdline"]
|
||||
require.NotNil(t, cmd, "cmdline is not available in debug vars")
|
||||
tmp, _ := cmd.([]interface{})
|
||||
tmp, _ := cmd.([]any)
|
||||
require.Contains(t, tmp[0], "vtcombo")
|
||||
|
||||
ctx := context.Background()
|
||||
|
|
|
@ -298,7 +298,7 @@ func testBufferBase(t *testing.T, isExternalParent bool) {
|
|||
durationMs := 0
|
||||
bufferingStops := 0
|
||||
if resp.StatusCode == 200 {
|
||||
resultMap := make(map[string]interface{})
|
||||
resultMap := make(map[string]any)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
err := json.Unmarshal(respByte, &resultMap)
|
||||
if err != nil {
|
||||
|
@ -330,7 +330,7 @@ func testBufferBase(t *testing.T, isExternalParent bool) {
|
|||
clusterInstance.Teardown()
|
||||
}
|
||||
|
||||
func getVarFromVtgate(t *testing.T, label string, param string, resultMap map[string]interface{}) int {
|
||||
func getVarFromVtgate(t *testing.T, label string, param string, resultMap map[string]any) int {
|
||||
paramVal := 0
|
||||
var err error
|
||||
object := reflect.ValueOf(resultMap[param])
|
||||
|
|
|
@ -59,8 +59,8 @@ func TestNormalizeAllFields(t *testing.T) {
|
|||
assert.True(t, found, "correctly normalized record not found in planner cache")
|
||||
}
|
||||
|
||||
func getPlanCache(vtgateHostPort string) ([]map[string]interface{}, error) {
|
||||
var results []map[string]interface{}
|
||||
func getPlanCache(vtgateHostPort string) ([]map[string]any, error) {
|
||||
var results []map[string]any
|
||||
client := http.Client{
|
||||
Timeout: 10 * time.Second,
|
||||
}
|
||||
|
|
|
@ -266,7 +266,7 @@ func testCopySchemaShardWithDifferentDB(t *testing.T, shard int) {
|
|||
schema, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("GetSchema", tabletAlias)
|
||||
require.Nil(t, err)
|
||||
|
||||
resultMap := make(map[string]interface{})
|
||||
resultMap := make(map[string]any)
|
||||
err = json.Unmarshal([]byte(schema), &resultMap)
|
||||
require.Nil(t, err)
|
||||
dbSchema := reflect.ValueOf(resultMap["database_schema"])
|
||||
|
|
|
@ -135,7 +135,7 @@ func TestVSchemaTrackerKeyspaceReInit(t *testing.T) {
|
|||
primaryTablet := clusterInstance.Keyspaces[0].Shards[0].PrimaryTablet()
|
||||
|
||||
// get the vschema prior to the restarts
|
||||
var originalResults interface{}
|
||||
var originalResults any
|
||||
readVSchema(t, &clusterInstance.VtgateProcess, &originalResults)
|
||||
assert.NotNil(t, originalResults)
|
||||
|
||||
|
@ -148,14 +148,14 @@ func TestVSchemaTrackerKeyspaceReInit(t *testing.T) {
|
|||
err = clusterInstance.WaitForTabletsToHealthyInVtgate()
|
||||
require.NoError(t, err)
|
||||
time.Sleep(time.Duration(signalInterval*2) * time.Second)
|
||||
var newResults interface{}
|
||||
var newResults any
|
||||
readVSchema(t, &clusterInstance.VtgateProcess, &newResults)
|
||||
assert.Equal(t, originalResults, newResults)
|
||||
newResults = nil
|
||||
}
|
||||
}
|
||||
|
||||
func readVSchema(t *testing.T, vtgate *cluster.VtgateProcess, results *interface{}) {
|
||||
func readVSchema(t *testing.T, vtgate *cluster.VtgateProcess, results *any) {
|
||||
httpClient := &http.Client{Timeout: 5 * time.Second}
|
||||
resp, err := httpClient.Get(vtgate.VSchemaURL)
|
||||
require.Nil(t, err)
|
||||
|
|
|
@ -373,7 +373,7 @@ func runSplitDiff(t *testing.T, keyspaceShard string) {
|
|||
|
||||
func pollForVars(t *testing.T, mssg string) {
|
||||
startTime := time.Now()
|
||||
var resultMap map[string]interface{}
|
||||
var resultMap map[string]any
|
||||
var err error
|
||||
var workerState string
|
||||
for {
|
||||
|
@ -390,7 +390,7 @@ func pollForVars(t *testing.T, mssg string) {
|
|||
|
||||
func pollForVarsWorkerRetryCount(t *testing.T, count int) {
|
||||
startTime := time.Now()
|
||||
var resultMap map[string]interface{}
|
||||
var resultMap map[string]any
|
||||
var err error
|
||||
var workerRetryCountInt int
|
||||
for {
|
||||
|
|
|
@ -73,7 +73,7 @@ func (r result) assert() bool {
|
|||
}
|
||||
|
||||
// print renders the results held by result.
|
||||
func (r result) print(log func(format string, args ...interface{}), seconds float64) {
|
||||
func (r result) print(log func(format string, args ...any), seconds float64) {
|
||||
allQCs := sumQueryCounts(r.selects, r.inserts, r.deletes)
|
||||
log(`QPS:
|
||||
select: %d | failed: %d (including %d meaningful failures) | sum: %d
|
||||
|
|
|
@ -48,7 +48,7 @@ import (
|
|||
// In Test*() function:
|
||||
//
|
||||
// mustMatch(t, want, got, "something doesn't match")
|
||||
func MustMatchFn(ignoredFields ...string) func(t *testing.T, want, got interface{}, errMsg ...string) {
|
||||
func MustMatchFn(ignoredFields ...string) func(t *testing.T, want, got any, errMsg ...string) {
|
||||
diffOpts := []cmp.Option{
|
||||
cmp.Comparer(func(a, b proto.Message) bool {
|
||||
return proto.Equal(a, b)
|
||||
|
@ -59,7 +59,7 @@ func MustMatchFn(ignoredFields ...string) func(t *testing.T, want, got interface
|
|||
cmpIgnoreFields(ignoredFields...),
|
||||
}
|
||||
// Diffs want/got and fails with errMsg on any failure.
|
||||
return func(t *testing.T, want, got interface{}, errMsg ...string) {
|
||||
return func(t *testing.T, want, got any, errMsg ...string) {
|
||||
t.Helper()
|
||||
diff := cmp.Diff(want, got, diffOpts...)
|
||||
if diff != "" {
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
|
||||
// ExecuteTemplate executes the given text template with the given data, and
|
||||
// returns the resulting string.
|
||||
func ExecuteTemplate(tmpl *template.Template, data interface{}) (string, error) {
|
||||
func ExecuteTemplate(tmpl *template.Template, data any) (string, error) {
|
||||
buf := &strings.Builder{}
|
||||
if err := tmpl.Execute(buf, data); err != nil {
|
||||
return "", err
|
||||
|
|
|
@ -157,7 +157,7 @@ func (r *SubImpl) String() string {
|
|||
func (r *SubImpl) iface() {}
|
||||
|
||||
type InterfaceContainer struct {
|
||||
v interface{}
|
||||
v any
|
||||
}
|
||||
|
||||
func (r InterfaceContainer) String() string {
|
||||
|
|
|
@ -41,8 +41,8 @@ func (noopTracingServer) AddGrpcClientOptions(addInterceptors func(s grpc.Stream
|
|||
// NoopSpan implements Span with no-op methods.
|
||||
type NoopSpan struct{}
|
||||
|
||||
func (NoopSpan) Finish() {}
|
||||
func (NoopSpan) Annotate(string, interface{}) {}
|
||||
func (NoopSpan) Finish() {}
|
||||
func (NoopSpan) Annotate(string, any) {}
|
||||
|
||||
func init() {
|
||||
tracingBackendFactories["noop"] = func(_ string) (tracingService, io.Closer, error) {
|
||||
|
|
|
@ -29,4 +29,4 @@ func (*traceLogger) Log(msg string) { log.Errorf(msg) }
|
|||
func (*traceLogger) Error(msg string) { log.Errorf(msg) }
|
||||
|
||||
// Infof is part of the jaeger.Logger interface.
|
||||
func (*traceLogger) Infof(msg string, args ...interface{}) { log.Infof(msg, args...) }
|
||||
func (*traceLogger) Infof(msg string, args ...any) { log.Infof(msg, args...) }
|
||||
|
|
|
@ -41,7 +41,7 @@ func (js openTracingSpan) Finish() {
|
|||
}
|
||||
|
||||
// Annotate will add information to an existing span
|
||||
func (js openTracingSpan) Annotate(key string, value interface{}) {
|
||||
func (js openTracingSpan) Annotate(key string, value any) {
|
||||
js.otSpan.SetTag(key, value)
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ type Span interface {
|
|||
Finish()
|
||||
// Annotate records a key/value pair associated with a Span. It should be
|
||||
// called between Start and Finish.
|
||||
Annotate(key string, value interface{})
|
||||
Annotate(key string, value any)
|
||||
}
|
||||
|
||||
// NewSpan creates a new Span with the currently installed tracing plugin.
|
||||
|
|
|
@ -115,6 +115,6 @@ func (m *mockSpan) Finish() {
|
|||
m.tracer.log = append(m.tracer.log, "span finished")
|
||||
}
|
||||
|
||||
func (m *mockSpan) Annotate(key string, value interface{}) {
|
||||
func (m *mockSpan) Annotate(key string, value any) {
|
||||
m.tracer.log = append(m.tracer.log, fmt.Sprintf("key: %v values:%v", key, value))
|
||||
}
|
||||
|
|
|
@ -775,6 +775,6 @@ type StatsHistoryRecord struct {
|
|||
}
|
||||
|
||||
// IsDuplicate implements history.Deduplicable
|
||||
func (r *StatsHistoryRecord) IsDuplicate(other interface{}) bool {
|
||||
func (r *StatsHistoryRecord) IsDuplicate(other any) bool {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ type StatusUpdater struct {
|
|||
|
||||
// Update sets a new status and initializes the EventID if necessary.
|
||||
// This implements event.Updater.Update().
|
||||
func (su *StatusUpdater) Update(status interface{}) {
|
||||
func (su *StatusUpdater) Update(status any) {
|
||||
su.Status = status.(string)
|
||||
|
||||
// initialize event ID
|
||||
|
|
|
@ -34,48 +34,48 @@ func init() {
|
|||
|
||||
type glogger struct{}
|
||||
|
||||
func (g *glogger) Info(args ...interface{}) {
|
||||
func (g *glogger) Info(args ...any) {
|
||||
}
|
||||
|
||||
func (g *glogger) Infoln(args ...interface{}) {
|
||||
func (g *glogger) Infoln(args ...any) {
|
||||
}
|
||||
|
||||
func (g *glogger) Infof(format string, args ...interface{}) {
|
||||
func (g *glogger) Infof(format string, args ...any) {
|
||||
}
|
||||
|
||||
func (g *glogger) Warning(args ...interface{}) {
|
||||
func (g *glogger) Warning(args ...any) {
|
||||
log.WarningDepth(2, args...)
|
||||
}
|
||||
|
||||
func (g *glogger) Warningln(args ...interface{}) {
|
||||
func (g *glogger) Warningln(args ...any) {
|
||||
log.WarningDepth(2, fmt.Sprintln(args...))
|
||||
}
|
||||
|
||||
func (g *glogger) Warningf(format string, args ...interface{}) {
|
||||
func (g *glogger) Warningf(format string, args ...any) {
|
||||
log.WarningDepth(2, fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
func (g *glogger) Error(args ...interface{}) {
|
||||
func (g *glogger) Error(args ...any) {
|
||||
log.ErrorDepth(2, args...)
|
||||
}
|
||||
|
||||
func (g *glogger) Errorln(args ...interface{}) {
|
||||
func (g *glogger) Errorln(args ...any) {
|
||||
log.ErrorDepth(2, fmt.Sprintln(args...))
|
||||
}
|
||||
|
||||
func (g *glogger) Errorf(format string, args ...interface{}) {
|
||||
func (g *glogger) Errorf(format string, args ...any) {
|
||||
log.ErrorDepth(2, fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
func (g *glogger) Fatal(args ...interface{}) {
|
||||
func (g *glogger) Fatal(args ...any) {
|
||||
log.FatalDepth(2, args...)
|
||||
}
|
||||
|
||||
func (g *glogger) Fatalln(args ...interface{}) {
|
||||
func (g *glogger) Fatalln(args ...any) {
|
||||
log.FatalDepth(2, fmt.Sprintln(args...))
|
||||
}
|
||||
|
||||
func (g *glogger) Fatalf(format string, args ...interface{}) {
|
||||
func (g *glogger) Fatalf(format string, args ...any) {
|
||||
log.FatalDepth(2, fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
|
|
|
@ -36,22 +36,22 @@ func NewConsoleLogger() *ConsoleLogger {
|
|||
}
|
||||
|
||||
// Infof is part of the Logger interface
|
||||
func (cl *ConsoleLogger) Infof(format string, v ...interface{}) {
|
||||
func (cl *ConsoleLogger) Infof(format string, v ...any) {
|
||||
cl.InfoDepth(1, fmt.Sprintf(format, v...))
|
||||
}
|
||||
|
||||
// Warningf is part of the Logger interface
|
||||
func (cl *ConsoleLogger) Warningf(format string, v ...interface{}) {
|
||||
func (cl *ConsoleLogger) Warningf(format string, v ...any) {
|
||||
cl.WarningDepth(1, fmt.Sprintf(format, v...))
|
||||
}
|
||||
|
||||
// Errorf is part of the Logger interface
|
||||
func (cl *ConsoleLogger) Errorf(format string, v ...interface{}) {
|
||||
func (cl *ConsoleLogger) Errorf(format string, v ...any) {
|
||||
cl.ErrorDepth(1, fmt.Sprintf(format, v...))
|
||||
}
|
||||
|
||||
// Errorf2 is part of the Logger interface
|
||||
func (cl *ConsoleLogger) Errorf2(err error, format string, v ...interface{}) {
|
||||
func (cl *ConsoleLogger) Errorf2(err error, format string, v ...any) {
|
||||
cl.ErrorDepth(1, fmt.Sprintf(format+": %+v", append(v, err)))
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ func (cl *ConsoleLogger) Error(err error) {
|
|||
}
|
||||
|
||||
// Printf is part of the Logger interface
|
||||
func (cl *ConsoleLogger) Printf(format string, v ...interface{}) {
|
||||
func (cl *ConsoleLogger) Printf(format string, v ...any) {
|
||||
fmt.Printf(format, v...)
|
||||
}
|
||||
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче