Skip to content

Commit

Permalink
Merge pull request authzed#120 from ecordell/overlap
Browse files Browse the repository at this point in the history
add overlap key constant and helpers
  • Loading branch information
ecordell committed Jun 1, 2023
2 parents fd444ef + 07f50e5 commit f358673
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/requestmeta/requestmeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
// RequestMetadataHeaderKey defines a key in the request metadata header.
type RequestMetadataHeaderKey string

// BoolRequestMetadataHeaderKey defines a key for a boolean vlaue in the request metadata header.
// BoolRequestMetadataHeaderKey defines a key for a boolean value in the request metadata header.
type BoolRequestMetadataHeaderKey RequestMetadataHeaderKey

const (
Expand All @@ -22,6 +22,12 @@ const (
// for the API call (if applicable and supported).
// Value: `1`
RequestDebugInformation BoolRequestMetadataHeaderKey = "io.spicedb.requestdebuginfo"

// RequestOverlapKey, if specified in a request header, indicates to SpiceDB
// that all requests with the same overlap value should be protected from
// the New Enemy Problem. This is only used with the CockroachDB datastore,
// and only if user-provided request overlap is enabled.
RequestOverlapKey RequestMetadataHeaderKey = "io.spicedb.requestoverlapkey"
)

// AddRequestHeaders returns a new context with the given values as request headers.
Expand All @@ -42,3 +48,8 @@ func SetRequestHeaders(ctx context.Context, values map[RequestMetadataHeaderKey]
}
return metadata.AppendToOutgoingContext(ctx, pairs...)
}

// WithOverlapKey returns a new context with the overlap key set.
func WithOverlapKey(ctx context.Context, key string) context.Context {
return metadata.AppendToOutgoingContext(ctx, string(RequestOverlapKey), key)
}

0 comments on commit f358673

Please sign in to comment.