readonly

package
v0.0.0-...-a70aae3 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0, Apache-2.0 Imports: 3 Imported by: 1

Documentation

Overview

Package readonly implements a filter that enforces read-only accesses to services.

This can be useful in hybrid environments where one cluster wants to read from a cache-backed datastore, but cannot modify the cache, so reads are safe and direct, but writes would create a state where the cached values are invalid.

This happens when mixing AppEngine datastore/memcache with Cloud Datastore readers.

Package readonly implements a filter that enforces read-only accesses to datastore.

This is useful in hybrid environments where one cluster wants to read from a cache-backed datastore, but cannot modify the cache, so reads are safe and direct, but writes would create a state where the cached values are invalid. This happens when mixing AppEngine datastore/memcache with Cloud Datastore readers.

Index

Constants

This section is empty.

Variables

View Source
var ErrReadOnly = errors.New("readonly: datastore is read-only")

ErrReadOnly is an error returned in response to mutating datastore operations.

Functions

func FilterRDS

func FilterRDS(c context.Context, p Predicate) context.Context

FilterRDS installs a read-only datastore filter in the context.

This enforces that mutating datastore operations that touch keys for which the predicate returns 'true' fail with ErrReadOnly.

If the predicate is nil, all mutating operations are denied.

Types

type Predicate

type Predicate func(*ds.Key) (isReadOnly bool)

Predicate is a user-supplied function that examines a key and returns true if it should be treated as read-only.

Jump to

Keyboard shortcuts

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