schemacache

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package schemacache provides wrapper functions for interacting with instances of the generic (vtadmin/cache).Cache that store schemas.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddOrBackfill

func AddOrBackfill(c *schemaCache, schemas []*vtadminpb.Schema, key Key, d time.Duration, opts LoadOptions)

AddOrBackfill takes a (schemas, key, duration) triple (see cache.Add) and a LoadOptions and either adds the schemas to the cache directly for the key, or enqueues a backfill for the key. Which of these occurs depends on the given LoadOptions. If the options, when passed to Load(All|One) would result in a full payload of the cached data, then the schemas are added to the cache directly. Otherwise, data would be missing for future Load(All|One) calls, so we enqueue a backfill to fetch the full payload and add that to the cache.

Callers are expected to call this function in the background, so it returns nothing and only logs warnings on failures.

func LoadAll

func LoadAll(c *schemaCache, key Key, opts LoadOptions) (schemas []*vtadminpb.Schema, ok bool, err error)

LoadAll returns the slice of all schemas cached for the given key, filtering down based on LoadOptions.

The boolean return value will be false if there is nothing in the cache for key.

func LoadOne

func LoadOne(c *schemaCache, key Key, opts LoadOptions) (schema *vtadminpb.Schema, found bool, err error)

LoadOne loads a single schema for the given key, filtering down based on the LoadOptions. If there is not exactly one schema for the key, an error is returned.

The boolean return value will be false if there is nothing in the cache for key.

Types

type Key

type Key struct {
	ClusterID               string
	Keyspace                string
	IncludeNonServingShards bool
}

Key is the cache key for vtadmin's schema caches.

func (Key) Key

func (k Key) Key() string

Key implements cache.Keyer for Key.

type LoadOptions

type LoadOptions struct {
	BaseRequest    *vtctldatapb.GetSchemaRequest
	AggregateSizes bool
	// contains filtered or unexported fields
}

LoadOptions is the set of options used by Load(All|One) to filter down fully- cached schema payloads.

Jump to

Keyboard shortcuts

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