Back to godoc.org

Package readonly

v0.0.0-...-8b7da69
Latest Go to latest

The latest major version is .

Published: Jul 27, 2020 | License: Apache-2.0 | Module: go.chromium.org/gae

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

Variables

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

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

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.

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.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier