Documentation
¶
Index ¶
- func NewCheckingReplicatedDatastore(primary datastore.Datastore, replicas ...datastore.ReadOnlyDatastore) (datastore.Datastore, error)
- func NewHedgingProxy(delegate datastore.Datastore, initialSlowRequestThreshold time.Duration, ...) (datastore.Datastore, error)
- func NewObservableDatastoreProxy(d datastore.Datastore) datastore.Datastore
- func NewReadonlyDatastore(delegate datastore.Datastore) datastore.Datastore
- func NewRelationshipIntegrityProxy(ds datastore.Datastore, currentKey KeyConfig, expiredKeys []KeyConfig) (datastore.Datastore, error)
- func NewSingleflightDatastoreProxy(d datastore.Datastore) datastore.Datastore
- func NewStrictReplicatedDatastore(primary datastore.Datastore, replicas ...datastore.StrictReadDatastore) (datastore.Datastore, error)
- type KeyConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCheckingReplicatedDatastore ¶ added in v1.35.0
func NewCheckingReplicatedDatastore(primary datastore.Datastore, replicas ...datastore.ReadOnlyDatastore) (datastore.Datastore, error)
NewCheckingReplicatedDatastore creates a new datastore that writes to the provided primary and reads from the provided replicas. The replicas are chosen in a round-robin fashion. If a replica does not have the requested revision, the primary is used instead.
NOTE: Be *very* careful when using this function. It is not safe to use this function without knowledge of the layout of the underlying datastore and its replicas.
Replicas will be checked for the requested revision before reading from them, which means that the read pool for the replicas *must* point to a *stable* instance of the datastore (not a load balancer). That means that *each* replica node in the database must be configured as its own replica to SpiceDB, with each URI given distinctly.
func NewHedgingProxy ¶ added in v1.1.0
func NewHedgingProxy( delegate datastore.Datastore, initialSlowRequestThreshold time.Duration, maxSampleCount uint64, hedgingQuantile float64, ) (datastore.Datastore, error)
NewHedgingProxy creates a proxy which performs request hedging on read operations according to the specified config.
func NewObservableDatastoreProxy ¶ added in v1.14.0
NewObservableDatastoreProxy creates a new datastore proxy which adds tracing and metrics to the datastore.
func NewReadonlyDatastore ¶
NewReadonlyDatastore creates a proxy which disables write operations to a downstream delegate datastore.
func NewRelationshipIntegrityProxy ¶ added in v1.36.0
func NewRelationshipIntegrityProxy(ds datastore.Datastore, currentKey KeyConfig, expiredKeys []KeyConfig) (datastore.Datastore, error)
NewRelationshipIntegrityProxy creates a new datastore proxy that ensures the integrity of relationships by using HMACs to sign the data. The current key is used to sign new data, and the expired keys are used to verify old data, if any.
func NewSingleflightDatastoreProxy ¶ added in v1.27.0
NewSingleflightDatastoreProxy creates a new Datastore proxy which deduplicates calls to Datastore methods that can share results.
func NewStrictReplicatedDatastore ¶ added in v1.35.0
func NewStrictReplicatedDatastore(primary datastore.Datastore, replicas ...datastore.StrictReadDatastore) (datastore.Datastore, error)
NewStrictReplicatedDatastore creates a new datastore that writes to the provided primary and reads from the provided replicas. The replicas are chosen in a round-robin fashion. If a replica does not have the requested revision, the primary is used instead.
Unlike NewCheckingReplicatedDatastore, this function does not check the replicas for the requested revision before reading from them; instead, a revision check is inserted into the SQL for each read. This is useful when the read pool points to a load balancer that can transparently handle the request. In this case, the primary will be used as a fallback if the replica does not have the requested revision. The replica(s) supplied to this proxy *must*, therefore, have strict read mode enabled, to ensure the query will fail with a RevisionUnavailableError if the revision is not available.
Types ¶
type KeyConfig ¶ added in v1.36.0
type KeyConfig struct { // ID is the unique identifier for the key. ID string // ExpiredAt is the time at which the key is no longer valid, if any. ExpiredAt *time.Time // Bytes is the raw key material. Bytes []byte }
KeyConfig is a configuration for a key used to sign relationships.