Documentation
¶
Index ¶
- Constants
- Variables
- type AccessAssignment
- type BlobStore
- type CacheInfo
- type ConfigProvider
- type Endpoint
- type Handler
- func (h *Handler) ExtractOperation(*echo.Context) string
- func (h *Handler) ExtractResource(*echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Shutdown(context.Context)
- func (h *Handler) Snapshot(ctx context.Context) []byte
- type IPRange
- type InMemoryBackend
- func (b *InMemoryBackend) Caches() []CacheInfo
- func (b *InMemoryBackend) Close()
- func (b *InMemoryBackend) Delete(key string) error
- func (b *InMemoryBackend) Endpoint(key string) (Endpoint, bool)
- func (b *InMemoryBackend) Ensure(key string, spec Spec) (Endpoint, error)
- func (b *InMemoryBackend) Export(key, format, prefix, containerURL string) error
- func (b *InMemoryBackend) Import(key, format string, files []string) error
- func (b *InMemoryBackend) Keys(key string) (Keys, error)
- func (b *InMemoryBackend) Reboot(key, rebootType string) error
- func (b *InMemoryBackend) RegenerateKey(key, keyType string) (Keys, error)
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) Scan(key string, db int, pattern, after string, limit int) ([]KeyEntry, string, error)
- func (b *InMemoryBackend) SetBlobStore(s BlobStore)
- func (b *InMemoryBackend) SetClock(now func() time.Time)
- func (b *InMemoryBackend) SetPortPool(alloc *portalloc.Allocator)
- func (b *InMemoryBackend) SetTokenValidator(v TokenValidator)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) Value(key string, db int, name string) (KeyValue, error)
- type KeyEntry
- type KeyValue
- type Keys
- type Provider
- type Settings
- type Spec
- type TokenValidator
Constants ¶
const ( MaxDatabases = 16 MaxScan = 500 MaxElements = 100 MaxValueLen = 4096 )
Inspection limits.
const ( RebootPrimary = "PrimaryNode" RebootSecondary = "SecondaryNode" RebootAll = "AllNodes" )
Reboot types accepted by Reboot.
const ( KeyPrimary = "Primary" KeySecondary = "Secondary" )
Access key names accepted by RegenerateKey.
const ( SKUBasic = "Basic" SKUStandard = "Standard" SKUPremium = "Premium" )
SKU names.
Variables ¶
var ( // ErrNotFound is returned for an unknown cache. ErrNotFound = errors.New("azureredis: cache not found") // ErrInvalid is returned for a malformed request. ErrInvalid = errors.New("azureredis: invalid request") // ErrNoBlobStore is returned when import or export has no Blob Storage to talk to. ErrNoBlobStore = errors.New("azureredis: blob storage is not available") // ErrNilAppContext is returned when Init is called with a nil AppContext. ErrNilAppContext = errors.New("azureredis: nil app context") )
Functions ¶
This section is empty.
Types ¶
type AccessAssignment ¶
type AccessAssignment struct {
ObjectID string `json:"objectId"`
Alias string `json:"alias"`
Permissions string `json:"permissions"`
}
AccessAssignment grants a principal the permissions of a data access policy; Alias is also the user name accepted for token authentication.
type BlobStore ¶
type BlobStore interface {
ReadBlob(container, blob string) ([]byte, error)
WriteBlob(container, blob string, data []byte) error
}
BlobStore reads and writes blobs in the Blob Storage emulator, for ImportData and ExportData.
type ConfigProvider ¶
type ConfigProvider interface {
GetAzureRedisSettings() Settings
}
ConfigProvider extracts the Azure Cache for Redis settings from the AppContext config.
type Endpoint ¶
Endpoint is where a cache's servers listen. Port is 0 while the non-TLS port is disabled.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
}
Handler owns the cache servers. Azure Cache for Redis has no HTTP data plane: ARM manages caches and clients speak Redis to each cache's own ports, so the handler never matches a request.
func (*Handler) ExtractOperation ¶
ExtractOperation is unused: requests never reach the shared router.
func (*Handler) ExtractResource ¶
ExtractResource is unused: requests never reach the shared router.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations lists the operations ARM's Microsoft.Cache provider drives.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns a 404 handler.
func (*Handler) MatchPriority ¶
MatchPriority is irrelevant because RouteMatcher never matches.
func (*Handler) RouteMatcher ¶
RouteMatcher never matches.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend runs one embedded Redis server per cache, with a TLS port always on and a plaintext port only while the cache enables it.
func NewInMemoryBackend ¶
func NewInMemoryBackend(cfg Settings) *InMemoryBackend
NewInMemoryBackend creates an empty backend on ephemeral loopback ports.
func (*InMemoryBackend) Caches ¶
func (b *InMemoryBackend) Caches() []CacheInfo
Caches lists the running caches by ID.
func (*InMemoryBackend) Delete ¶
func (b *InMemoryBackend) Delete(key string) error
Delete stops the cache's servers and discards its data.
func (*InMemoryBackend) Endpoint ¶
func (b *InMemoryBackend) Endpoint(key string) (Endpoint, bool)
Endpoint reports where the cache listens.
func (*InMemoryBackend) Ensure ¶
func (b *InMemoryBackend) Ensure(key string, spec Spec) (Endpoint, error)
Ensure creates the cache, or applies spec to an existing one, and returns where it listens.
func (*InMemoryBackend) Export ¶
func (b *InMemoryBackend) Export(key, format, prefix, containerURL string) error
Export writes the cache's data to <prefix>.rdb in the container named by containerURL.
func (*InMemoryBackend) Import ¶
func (b *InMemoryBackend) Import(key, format string, files []string) error
Import replaces the cache's data with the RDB file at the blob URL.
func (*InMemoryBackend) Keys ¶
func (b *InMemoryBackend) Keys(key string) (Keys, error)
Keys returns the cache's access keys.
func (*InMemoryBackend) Reboot ¶
func (b *InMemoryBackend) Reboot(key, rebootType string) error
Reboot restarts the selected nodes. Data is flushed when no surviving node holds it; client connections drop unless only a replica reboots.
func (*InMemoryBackend) RegenerateKey ¶
func (b *InMemoryBackend) RegenerateKey(key, keyType string) (Keys, error)
RegenerateKey replaces one access key; the old value stops authenticating.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads a snapshot, starting every cache again on fresh ports.
func (*InMemoryBackend) Scan ¶
func (b *InMemoryBackend) Scan(key string, db int, pattern, after string, limit int) ([]KeyEntry, string, error)
Scan lists up to limit keys of database db that match the glob pattern (* and ? only), in key order, starting after the cursor key. The returned next is empty once the scan is complete.
func (*InMemoryBackend) SetBlobStore ¶
func (b *InMemoryBackend) SetBlobStore(s BlobStore)
SetBlobStore connects ImportData and ExportData to Blob Storage.
func (*InMemoryBackend) SetClock ¶
func (b *InMemoryBackend) SetClock(now func() time.Time)
SetClock replaces the clock that decides when a Microsoft Entra token has expired.
func (*InMemoryBackend) SetPortPool ¶
func (b *InMemoryBackend) SetPortPool(alloc *portalloc.Allocator)
SetPortPool makes caches take their Redis ports from alloc.
func (*InMemoryBackend) SetTokenValidator ¶
func (b *InMemoryBackend) SetTokenValidator(v TokenValidator)
SetTokenValidator lets caches with Entra authentication enabled accept Microsoft Entra tokens.
type KeyValue ¶
type KeyValue struct {
Key string
Type string
Text string
Elements []string
Total int
TTL time.Duration
Truncated bool
}
KeyValue is a capped view of one key's value.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for Azure Cache for Redis.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init builds the backend and handler.
type Settings ¶
type Settings struct {
TLSCertFile string `` //nolint:lll // config struct tags are intentionally verbose
/* 215-byte string literal not displayed */
TLSKeyFile string `json:"tlsKeyFile" env:"AZURE_REDIS_TLS_KEY" name:"tls-key" help:"Path to the PEM key matching --azure-redis-tls-cert."` //nolint:lll // config struct tags are intentionally verbose
}
Settings is the Kong-embedded configuration of the Azure Cache for Redis emulator.
func DefaultSettings ¶
func DefaultSettings() Settings
DefaultSettings returns the settings used when no ConfigProvider exists.
type Spec ¶
type Spec struct {
SKU string `json:"sku"`
MinTLS string `json:"minTls"`
Firewall []IPRange `json:"firewall,omitempty"`
Assignments []AccessAssignment `json:"accessAssignments,omitempty"`
EnableNonSSLPort bool `json:"enableNonSslPort"`
Persistence bool `json:"persistence"`
AuthNotRequired bool `json:"authNotRequired,omitempty"`
DisableAccessKeys bool `json:"disableAccessKeys,omitempty"`
EntraEnabled bool `json:"entraEnabled,omitempty"`
}
Spec is the part of a cache's ARM configuration the Redis servers act on.
type TokenValidator ¶
TokenValidator checks a Microsoft Entra access token for the Redis audience and returns its principal's object ID.