Documentation
¶
Index ¶
- Constants
- Variables
- func GetLocation(req *location.GetLocationRequest) (*location.Location, error)
- func ListLocations(req *location.ListLocationsRequest) ([]*location.Location, string, error)
- type ConfigProvider
- type Handler
- func (h *Handler) API() redispb.CloudRedisServer
- func (h *Handler) Addr() string
- 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(ctx context.Context)
- func (h *Handler) Snapshot(ctx context.Context) []byte
- func (h *Handler) StartWorker(ctx context.Context) error
- type InMemoryBackend
- func (b *InMemoryBackend) Close()
- func (b *InMemoryBackend) CreateInstance(in *redispb.CreateInstanceRequest) (*longrunningpb.Operation, error)
- func (b *InMemoryBackend) DeleteInstance(name string) (*longrunningpb.Operation, error)
- func (b *InMemoryBackend) ExportInstance(in *redispb.ExportInstanceRequest) (*longrunningpb.Operation, error)
- func (b *InMemoryBackend) FailoverInstance(in *redispb.FailoverInstanceRequest) (*longrunningpb.Operation, error)
- func (b *InMemoryBackend) GetInstance(name string) (*redispb.Instance, error)
- func (b *InMemoryBackend) GetInstanceAuthString(name string) (*redispb.InstanceAuthString, error)
- func (b *InMemoryBackend) ImportInstance(in *redispb.ImportInstanceRequest) (*longrunningpb.Operation, error)
- func (b *InMemoryBackend) ListInstances(in *redispb.ListInstancesRequest) ([]*redispb.Instance, string, error)
- func (b *InMemoryBackend) RescheduleMaintenance(in *redispb.RescheduleMaintenanceRequest) (*longrunningpb.Operation, error)
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) SetObjectStore(o ObjectStore)
- func (b *InMemoryBackend) SetPortPool(alloc *portalloc.Allocator)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) UpdateInstance(in *redispb.UpdateInstanceRequest) (*longrunningpb.Operation, error)
- func (b *InMemoryBackend) UpgradeInstance(in *redispb.UpgradeInstanceRequest) (*longrunningpb.Operation, error)
- type ObjectStore
- type Provider
- type Settings
Constants ¶
const DefaultPort = 8133
DefaultPort is the dedicated gRPC listener's default TCP port.
Variables ¶
var ErrNilAppContext = errors.New("gcpredis: nil app context")
ErrNilAppContext is returned when Init is called with a nil AppContext.
Functions ¶
func GetLocation ¶
func GetLocation(req *location.GetLocationRequest) (*location.Location, error)
GetLocation returns one supported location.
func ListLocations ¶
ListLocations lists the supported locations of a project.
Types ¶
type ConfigProvider ¶
type ConfigProvider interface {
GetGCPRedisSettings() Settings
}
ConfigProvider extracts Memorystore for Redis configuration from the AppContext Config.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
Port int
// contains filtered or unexported fields
}
Handler serves the Memorystore for Redis API (v1) on a dedicated gRPC listener.
func NewHandler ¶
func NewHandler(backend *InMemoryBackend) *Handler
NewHandler creates a Handler; callers override Port from Settings.
func (*Handler) API ¶
func (h *Handler) API() redispb.CloudRedisServer
API exposes the CloudRedis server for in-process callers (dashboard proxy).
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 supported gRPC methods.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns a 404 handler; the real API is gRPC on the dedicated port.
func (*Handler) MatchPriority ¶
MatchPriority is irrelevant because RouteMatcher never matches.
func (*Handler) RouteMatcher ¶
RouteMatcher never matches: Memorystore for Redis runs on its own gRPC listener.
func (*Handler) Shutdown ¶
Shutdown stops the gRPC server and every instance's Redis server, forcing a close after a short grace period.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend holds all Memorystore for Redis state under one lock.
func NewInMemoryBackend ¶
func NewInMemoryBackend() *InMemoryBackend
NewInMemoryBackend creates an empty backend that serves instances on ephemeral loopback ports.
func (*InMemoryBackend) Close ¶
func (b *InMemoryBackend) Close()
Close stops every instance's Redis server and waits for background work.
func (*InMemoryBackend) CreateInstance ¶
func (b *InMemoryBackend) CreateInstance(in *redispb.CreateInstanceRequest) (*longrunningpb.Operation, error)
CreateInstance starts creating an instance; the returned operation completes once its Redis server is up.
func (*InMemoryBackend) DeleteInstance ¶
func (b *InMemoryBackend) DeleteInstance(name string) (*longrunningpb.Operation, error)
DeleteInstance deletes an instance and stops its Redis server.
func (*InMemoryBackend) ExportInstance ¶
func (b *InMemoryBackend) ExportInstance(in *redispb.ExportInstanceRequest) (*longrunningpb.Operation, error)
ExportInstance writes an instance's data to Cloud Storage as an RDB file.
func (*InMemoryBackend) FailoverInstance ¶
func (b *InMemoryBackend) FailoverInstance(in *redispb.FailoverInstanceRequest) (*longrunningpb.Operation, error)
FailoverInstance swaps the primary and replica zones of a STANDARD_HA instance.
func (*InMemoryBackend) GetInstance ¶
func (b *InMemoryBackend) GetInstance(name string) (*redispb.Instance, error)
GetInstance returns an instance.
func (*InMemoryBackend) GetInstanceAuthString ¶
func (b *InMemoryBackend) GetInstanceAuthString(name string) (*redispb.InstanceAuthString, error)
GetInstanceAuthString returns the AUTH string of an instance with AUTH enabled.
func (*InMemoryBackend) ImportInstance ¶
func (b *InMemoryBackend) ImportInstance(in *redispb.ImportInstanceRequest) (*longrunningpb.Operation, error)
ImportInstance replaces an instance's data with an RDB file read from Cloud Storage.
func (*InMemoryBackend) ListInstances ¶
func (b *InMemoryBackend) ListInstances(in *redispb.ListInstancesRequest) ([]*redispb.Instance, string, error)
ListInstances lists instances under a location, or every location with "-".
func (*InMemoryBackend) RescheduleMaintenance ¶
func (b *InMemoryBackend) RescheduleMaintenance( in *redispb.RescheduleMaintenanceRequest, ) (*longrunningpb.Operation, error)
RescheduleMaintenance sets when the next maintenance runs.
func (*InMemoryBackend) Reset ¶
func (b *InMemoryBackend) Reset()
Reset stops every instance and clears all state.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads a snapshot. Instances caught mid-creation or mid-deletion are dropped, other transient states settle to READY, and every Redis server starts again on a fresh port.
func (*InMemoryBackend) SetObjectStore ¶
func (b *InMemoryBackend) SetObjectStore(o ObjectStore)
SetObjectStore connects ImportInstance and ExportInstance to an object store.
func (*InMemoryBackend) SetPortPool ¶
func (b *InMemoryBackend) SetPortPool(alloc *portalloc.Allocator)
SetPortPool makes instances take their Redis ports from alloc.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serialises every instance with its keyspace; Redis servers and TLS CAs are rebuilt on restore.
func (*InMemoryBackend) UpdateInstance ¶
func (b *InMemoryBackend) UpdateInstance(in *redispb.UpdateInstanceRequest) (*longrunningpb.Operation, error)
UpdateInstance applies the masked fields of the request's instance.
func (*InMemoryBackend) UpgradeInstance ¶
func (b *InMemoryBackend) UpgradeInstance(in *redispb.UpgradeInstanceRequest) (*longrunningpb.Operation, error)
UpgradeInstance moves an instance to a newer Redis version.
type ObjectStore ¶
type ObjectStore interface {
ReadObject(bucket, object string) ([]byte, error)
WriteObject(bucket, object string, data []byte) error
}
ObjectStore reads and writes objects in the GCS emulator, for ImportInstance and ExportInstance.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for Google Memorystore for Redis. It serves gRPC on its own listener (see Handler.StartWorker) and never matches on the shared AWS router.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init creates the backend and handler; the port is bound in StartWorker.
type Settings ¶
type Settings struct {
Port int `` //nolint:lll // config struct tags are intentionally verbose
/* 179-byte string literal not displayed */
}
Settings holds service-level configuration, embedded in the root CLI command as CLI.GCPRedis.
func DefaultSettings ¶
func DefaultSettings() Settings
DefaultSettings returns the settings used when no ConfigProvider is available.