Documentation
¶
Index ¶
- Constants
- Variables
- type BlobStore
- 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 InMemoryBackend
- 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) SetBlobStore(s BlobStore)
- func (b *InMemoryBackend) SetPortPool(alloc *portalloc.Allocator)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- type Keys
- type Provider
- type Settings
- type Spec
Constants ¶
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 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) 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 or persisted copy holds it.
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) SetBlobStore ¶
func (b *InMemoryBackend) SetBlobStore(s BlobStore)
SetBlobStore connects ImportData and ExportData to Blob Storage.
func (*InMemoryBackend) SetPortPool ¶
func (b *InMemoryBackend) SetPortPool(alloc *portalloc.Allocator)
SetPortPool makes caches take their Redis ports from alloc.
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 is Basic, Standard or Premium.
SKU string `json:"sku"`
// MinTLS is "1.0", "1.1" or "1.2".
MinTLS string `json:"minTls"`
// EnableNonSSLPort serves plaintext Redis on a second port.
EnableNonSSLPort bool `json:"enableNonSslPort"`
// Persistence is true when RDB or AOF backup is enabled, so a full reboot keeps the data.
Persistence bool `json:"persistence"`
// AuthNotRequired (redisConfiguration authnotrequired) lets clients connect without a key.
AuthNotRequired bool `json:"authNotRequired,omitempty"`
}
Spec is the part of a cache's ARM configuration the Redis servers act on.