server

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: Apache-2.0 Imports: 78 Imported by: 0

Documentation

Overview

Code generated by github.com/ecordell/optgen. DO NOT EDIT.

Code generated by github.com/ecordell/optgen. DO NOT EDIT.

Code generated by github.com/ecordell/optgen. DO NOT EDIT.

Index

Constants

View Source
const (
	DefaultMiddlewareRequestID     = "requestid"
	DefaultMiddlewareLog           = "log"
	DefaultMiddlewareGRPCLog       = "grpclog"
	DefaultMiddlewareOTelGRPC      = "otelgrpc"
	DefaultMiddlewareGRPCAuth      = "grpcauth"
	DefaultMiddlewareGRPCProm      = "grpcprom"
	DefaultMiddlewareServerVersion = "serverversion"

	DefaultInternalMiddlewareDispatch       = "dispatch"
	DefaultInternalMiddlewareDatastore      = "datastore"
	DefaultInternalMiddlewareConsistency    = "consistency"
	DefaultInternalMiddlewareServerSpecific = "servicespecific"
)

Variables

View Source
var ConsistentHashringBuilder = consistent.NewBuilder(xxhash.Sum64)

ConsistentHashringBuilder is a balancer Builder that uses xxhash as the underlying hash for the ConsistentHashringBalancers it creates.

View Source
var DisableTelemetryHandler *prometheus.Registry

Functions

func CompleteCache added in v0.0.3

func CompleteCache[K cache.KeyString, V any](cc *CacheConfig) (cache.Cache[K, V], error)

CompleteCache translates the CLI cache config into a cache config.

func DefaultDispatchMiddleware

func DefaultDispatchMiddleware(logger zerolog.Logger, authFunc grpcauth.AuthFunc, ds datastore.Datastore,
	disableGRPCLatencyHistogram bool,
) ([]grpc.UnaryServerInterceptor, []grpc.StreamServerInterceptor)

DefaultDispatchMiddleware generates the default middleware chain used for the internal dispatch SpiceDB gRPC API

func DefaultPreRunE

func DefaultPreRunE(programName string) cobrautil.CobraRunFunc

DefaultPreRunE sets up viper, zerolog, and OpenTelemetry flag handling for a command.

func GRPCMetrics

func GRPCMetrics(disableLatencyHistogram bool) (grpc.UnaryServerInterceptor, grpc.StreamServerInterceptor)

GRPCMetrics returns the interceptors used for the default gRPC metrics from grpc-ecosystem/go-grpc-middleware

func InterceptorLogger

func InterceptorLogger(l zerolog.Logger) grpclog.Logger

func MetricsHandler

func MetricsHandler(telemetryRegistry *prometheus.Registry, c *Config) http.Handler

MetricsHandler sets up an HTTP server that handles serving Prometheus metrics and pprof endpoints.

func MustRegisterCacheFlags added in v0.0.3

func MustRegisterCacheFlags(flags *pflag.FlagSet, flagPrefix string, config, defaults *CacheConfig)

MustRegisterCacheFlags registers flags used to configure SpiceDB's various caches.

func ServeExample

func ServeExample(programName string) string

ServeExample creates an example usage string with the provided program name.

Types

type CacheConfig

type CacheConfig struct {
	Name        string `debugmap:"visible"`
	MaxCost     string `debugmap:"visible"`
	NumCounters int64  `debugmap:"visible"`
	Metrics     bool   `debugmap:"visible"`
	Enabled     bool   `debugmap:"visible"`

	CacheKindForTesting string `debugmap:"visible"`
	// contains filtered or unexported fields
}

CacheConfig defines the configuration various SpiceDB caches.

func CacheConfigWithOptions

func CacheConfigWithOptions(c *CacheConfig, opts ...CacheConfigOption) *CacheConfig

CacheConfigWithOptions configures an existing CacheConfig with the passed in options set

func NewCacheConfigWithOptions

func NewCacheConfigWithOptions(opts ...CacheConfigOption) *CacheConfig

NewCacheConfigWithOptions creates a new CacheConfig with the passed in options set

func NewCacheConfigWithOptionsAndDefaults

func NewCacheConfigWithOptionsAndDefaults(opts ...CacheConfigOption) *CacheConfig

NewCacheConfigWithOptionsAndDefaults creates a new CacheConfig with the passed in options set starting from the defaults

func (CacheConfig) DebugMap

func (c CacheConfig) DebugMap() map[string]any

DebugMap returns a map form of CacheConfig for debugging

func (*CacheConfig) ToOption

func (c *CacheConfig) ToOption() CacheConfigOption

ToOption returns a new CacheConfigOption that sets the values from the passed in CacheConfig

func (*CacheConfig) WithOptions

func (c *CacheConfig) WithOptions(opts ...CacheConfigOption) *CacheConfig

WithOptions configures the receiver CacheConfig with the passed in options set

func (*CacheConfig) WithRevisionParameters

func (cc *CacheConfig) WithRevisionParameters(
	quantizationInterval time.Duration,
	followerReadDelay time.Duration,
	maxStalenessPercent float64,
) *CacheConfig

WithRevisionParameters configures a cache such that all entries are given a TTL that will expire safely outside of the quantization window.

type CacheConfigOption

type CacheConfigOption func(c *CacheConfig)

func WithCacheKindForTesting added in v0.0.3

func WithCacheKindForTesting(cacheKindForTesting string) CacheConfigOption

WithCacheKindForTesting returns an option that can set CacheKindForTesting on a CacheConfig

func WithEnabled

func WithEnabled(enabled bool) CacheConfigOption

WithEnabled returns an option that can set Enabled on a CacheConfig

func WithMaxCost

func WithMaxCost(maxCost string) CacheConfigOption

WithMaxCost returns an option that can set MaxCost on a CacheConfig

func WithMetrics

func WithMetrics(metrics bool) CacheConfigOption

WithMetrics returns an option that can set Metrics on a CacheConfig

func WithName

func WithName(name string) CacheConfigOption

WithName returns an option that can set Name on a CacheConfig

func WithNumCounters

func WithNumCounters(numCounters int64) CacheConfigOption

WithNumCounters returns an option that can set NumCounters on a CacheConfig

type Config

type Config struct {
	// API config
	GRPCServer             util.GRPCServerConfig `debugmap:"visible"`
	GRPCAuthFunc           grpc_auth.AuthFunc    `debugmap:"visible"`
	PresharedSecureKey     []string              `debugmap:"sensitive"`
	ShutdownGracePeriod    time.Duration         `debugmap:"visible"`
	DisableVersionResponse bool                  `debugmap:"visible"`

	// GRPC Gateway config
	HTTPGateway                    util.HTTPServerConfig `debugmap:"visible"`
	HTTPGatewayUpstreamAddr        string                `debugmap:"visible"`
	HTTPGatewayUpstreamTLSCertPath string                `debugmap:"visible"`
	HTTPGatewayCorsEnabled         bool                  `debugmap:"visible"`
	HTTPGatewayCorsAllowedOrigins  []string              `debugmap:"visible-format"`

	// Datastore
	DatastoreConfig datastorecfg.Config `debugmap:"visible"`
	Datastore       datastore.Datastore `debugmap:"visible"`

	// Datastore usage
	MaxCaveatContextSize       int `debugmap:"visible" default:"4096"`
	MaxRelationshipContextSize int `debugmap:"visible" default:"25_000"`

	// Namespace cache
	EnableExperimentalWatchableSchemaCache bool          `debugmap:"visible"`
	SchemaWatchHeartbeat                   time.Duration `debugmap:"visible"`
	NamespaceCacheConfig                   CacheConfig   `debugmap:"visible"`

	// Schema options
	SchemaPrefixesRequired bool `debugmap:"visible"`

	// Dispatch options
	DispatchServer                    util.GRPCServerConfig   `debugmap:"visible"`
	DispatchMaxDepth                  uint32                  `debugmap:"visible"`
	GlobalDispatchConcurrencyLimit    uint16                  `debugmap:"visible"`
	DispatchConcurrencyLimits         graph.ConcurrencyLimits `debugmap:"visible"`
	DispatchUpstreamAddr              string                  `debugmap:"visible"`
	DispatchUpstreamCAPath            string                  `debugmap:"visible"`
	DispatchUpstreamTimeout           time.Duration           `debugmap:"visible"`
	DispatchClientMetricsEnabled      bool                    `debugmap:"visible"`
	DispatchClientMetricsPrefix       string                  `debugmap:"visible"`
	DispatchClusterMetricsEnabled     bool                    `debugmap:"visible"`
	DispatchClusterMetricsPrefix      string                  `debugmap:"visible"`
	Dispatcher                        dispatch.Dispatcher     `debugmap:"visible"`
	DispatchHashringReplicationFactor uint16                  `debugmap:"visible"`
	DispatchHashringSpread            uint8                   `debugmap:"visible"`
	DispatchChunkSize                 uint16                  `debugmap:"visible" default:"100"`

	DispatchSecondaryUpstreamAddrs map[string]string `debugmap:"visible"`
	DispatchSecondaryUpstreamExprs map[string]string `debugmap:"visible"`

	DispatchCacheConfig        CacheConfig `debugmap:"visible"`
	ClusterDispatchCacheConfig CacheConfig `debugmap:"visible"`

	// API Behavior
	DisableV1SchemaAPI                bool          `debugmap:"visible"`
	V1SchemaAdditiveOnly              bool          `debugmap:"visible"`
	MaximumUpdatesPerWrite            uint16        `debugmap:"visible"`
	MaximumPreconditionCount          uint16        `debugmap:"visible"`
	MaxDatastoreReadPageSize          uint64        `debugmap:"visible"`
	StreamingAPITimeout               time.Duration `debugmap:"visible"`
	WatchHeartbeat                    time.Duration `debugmap:"visible"`
	MaxReadRelationshipsLimit         uint32        `debugmap:"visible"`
	MaxDeleteRelationshipsLimit       uint32        `debugmap:"visible"`
	MaxLookupResourcesLimit           uint32        `debugmap:"visible"`
	MaxBulkExportRelationshipsLimit   uint32        `debugmap:"visible"`
	EnableExperimentalLookupResources bool          `debugmap:"visible"`

	// Additional Services
	MetricsAPI util.HTTPServerConfig `debugmap:"visible"`

	// Middleware for grpc API
	UnaryMiddlewareModification     []MiddlewareModification[grpc.UnaryServerInterceptor]  `debugmap:"hidden"`
	StreamingMiddlewareModification []MiddlewareModification[grpc.StreamServerInterceptor] `debugmap:"hidden"`

	// Middleware for internal dispatch API
	DispatchUnaryMiddleware     []grpc.UnaryServerInterceptor  `debugmap:"hidden"`
	DispatchStreamingMiddleware []grpc.StreamServerInterceptor `debugmap:"hidden"`

	// Telemetry
	SilentlyDisableTelemetry bool          `debugmap:"visible"`
	TelemetryCAOverridePath  string        `debugmap:"visible"`
	TelemetryEndpoint        string        `debugmap:"visible"`
	TelemetryInterval        time.Duration `debugmap:"visible"`

	// Logs
	EnableRequestLogs  bool `debugmap:"visible"`
	EnableResponseLogs bool `debugmap:"visible"`

	// Metrics
	DisableGRPCLatencyHistogram bool `debugmap:"visible"`
}

func ConfigWithOptions

func ConfigWithOptions(c *Config, opts ...ConfigOption) *Config

ConfigWithOptions configures an existing Config with the passed in options set

func NewConfigWithOptions

func NewConfigWithOptions(opts ...ConfigOption) *Config

NewConfigWithOptions creates a new Config with the passed in options set

func NewConfigWithOptionsAndDefaults

func NewConfigWithOptionsAndDefaults(opts ...ConfigOption) *Config

NewConfigWithOptionsAndDefaults creates a new Config with the passed in options set starting from the defaults

func (*Config) Complete

func (c *Config) Complete(ctx context.Context) (RunnableServer, error)

Complete validates the config and fills out defaults. if there is no error, a completedServerConfig (with limited options for mutation) is returned.

func (Config) DebugMap

func (c Config) DebugMap() map[string]any

DebugMap returns a map form of Config for debugging

func (*Config) ToOption

func (c *Config) ToOption() ConfigOption

ToOption returns a new ConfigOption that sets the values from the passed in Config

func (*Config) WithOptions

func (c *Config) WithOptions(opts ...ConfigOption) *Config

WithOptions configures the receiver Config with the passed in options set

type ConfigOption

type ConfigOption func(c *Config)

func SetDispatchSecondaryUpstreamAddrs

func SetDispatchSecondaryUpstreamAddrs(dispatchSecondaryUpstreamAddrs map[string]string) ConfigOption

SetDispatchSecondaryUpstreamAddrs returns an option that can set DispatchSecondaryUpstreamAddrs on a Config

func SetDispatchSecondaryUpstreamExprs

func SetDispatchSecondaryUpstreamExprs(dispatchSecondaryUpstreamExprs map[string]string) ConfigOption

SetDispatchSecondaryUpstreamExprs returns an option that can set DispatchSecondaryUpstreamExprs on a Config

func SetDispatchStreamingMiddleware

func SetDispatchStreamingMiddleware(dispatchStreamingMiddleware []grpc.StreamServerInterceptor) ConfigOption

SetDispatchStreamingMiddleware returns an option that can set DispatchStreamingMiddleware on a Config

func SetDispatchUnaryMiddleware

func SetDispatchUnaryMiddleware(dispatchUnaryMiddleware []grpc.UnaryServerInterceptor) ConfigOption

SetDispatchUnaryMiddleware returns an option that can set DispatchUnaryMiddleware on a Config

func SetHTTPGatewayCorsAllowedOrigins

func SetHTTPGatewayCorsAllowedOrigins(hTTPGatewayCorsAllowedOrigins []string) ConfigOption

SetHTTPGatewayCorsAllowedOrigins returns an option that can set HTTPGatewayCorsAllowedOrigins on a Config

func SetPresharedSecureKey

func SetPresharedSecureKey(presharedSecureKey []string) ConfigOption

SetPresharedSecureKey returns an option that can set PresharedSecureKey on a Config

func SetStreamingMiddlewareModification

func SetStreamingMiddlewareModification(streamingMiddlewareModification []MiddlewareModification[grpc.StreamServerInterceptor]) ConfigOption

SetStreamingMiddlewareModification returns an option that can set StreamingMiddlewareModification on a Config

func SetUnaryMiddlewareModification

func SetUnaryMiddlewareModification(unaryMiddlewareModification []MiddlewareModification[grpc.UnaryServerInterceptor]) ConfigOption

SetUnaryMiddlewareModification returns an option that can set UnaryMiddlewareModification on a Config

func WithClusterDispatchCacheConfig

func WithClusterDispatchCacheConfig(clusterDispatchCacheConfig CacheConfig) ConfigOption

WithClusterDispatchCacheConfig returns an option that can set ClusterDispatchCacheConfig on a Config

func WithDatastore

func WithDatastore(datastore datastore1.Datastore) ConfigOption

WithDatastore returns an option that can set Datastore on a Config

func WithDatastoreConfig

func WithDatastoreConfig(datastoreConfig datastore.Config) ConfigOption

WithDatastoreConfig returns an option that can set DatastoreConfig on a Config

func WithDisableGRPCLatencyHistogram

func WithDisableGRPCLatencyHistogram(disableGRPCLatencyHistogram bool) ConfigOption

WithDisableGRPCLatencyHistogram returns an option that can set DisableGRPCLatencyHistogram on a Config

func WithDisableV1SchemaAPI

func WithDisableV1SchemaAPI(disableV1SchemaAPI bool) ConfigOption

WithDisableV1SchemaAPI returns an option that can set DisableV1SchemaAPI on a Config

func WithDisableVersionResponse

func WithDisableVersionResponse(disableVersionResponse bool) ConfigOption

WithDisableVersionResponse returns an option that can set DisableVersionResponse on a Config

func WithDispatchCacheConfig

func WithDispatchCacheConfig(dispatchCacheConfig CacheConfig) ConfigOption

WithDispatchCacheConfig returns an option that can set DispatchCacheConfig on a Config

func WithDispatchChunkSize added in v0.0.3

func WithDispatchChunkSize(dispatchChunkSize uint16) ConfigOption

WithDispatchChunkSize returns an option that can set DispatchChunkSize on a Config

func WithDispatchClientMetricsEnabled

func WithDispatchClientMetricsEnabled(dispatchClientMetricsEnabled bool) ConfigOption

WithDispatchClientMetricsEnabled returns an option that can set DispatchClientMetricsEnabled on a Config

func WithDispatchClientMetricsPrefix

func WithDispatchClientMetricsPrefix(dispatchClientMetricsPrefix string) ConfigOption

WithDispatchClientMetricsPrefix returns an option that can set DispatchClientMetricsPrefix on a Config

func WithDispatchClusterMetricsEnabled

func WithDispatchClusterMetricsEnabled(dispatchClusterMetricsEnabled bool) ConfigOption

WithDispatchClusterMetricsEnabled returns an option that can set DispatchClusterMetricsEnabled on a Config

func WithDispatchClusterMetricsPrefix

func WithDispatchClusterMetricsPrefix(dispatchClusterMetricsPrefix string) ConfigOption

WithDispatchClusterMetricsPrefix returns an option that can set DispatchClusterMetricsPrefix on a Config

func WithDispatchConcurrencyLimits

func WithDispatchConcurrencyLimits(dispatchConcurrencyLimits graph.ConcurrencyLimits) ConfigOption

WithDispatchConcurrencyLimits returns an option that can set DispatchConcurrencyLimits on a Config

func WithDispatchHashringReplicationFactor

func WithDispatchHashringReplicationFactor(dispatchHashringReplicationFactor uint16) ConfigOption

WithDispatchHashringReplicationFactor returns an option that can set DispatchHashringReplicationFactor on a Config

func WithDispatchHashringSpread

func WithDispatchHashringSpread(dispatchHashringSpread uint8) ConfigOption

WithDispatchHashringSpread returns an option that can set DispatchHashringSpread on a Config

func WithDispatchMaxDepth

func WithDispatchMaxDepth(dispatchMaxDepth uint32) ConfigOption

WithDispatchMaxDepth returns an option that can set DispatchMaxDepth on a Config

func WithDispatchSecondaryUpstreamAddrs

func WithDispatchSecondaryUpstreamAddrs(key string, value string) ConfigOption

WithDispatchSecondaryUpstreamAddrs returns an option that can append DispatchSecondaryUpstreamAddrss to Config.DispatchSecondaryUpstreamAddrs

func WithDispatchSecondaryUpstreamExprs

func WithDispatchSecondaryUpstreamExprs(key string, value string) ConfigOption

WithDispatchSecondaryUpstreamExprs returns an option that can append DispatchSecondaryUpstreamExprss to Config.DispatchSecondaryUpstreamExprs

func WithDispatchServer

func WithDispatchServer(dispatchServer util.GRPCServerConfig) ConfigOption

WithDispatchServer returns an option that can set DispatchServer on a Config

func WithDispatchStreamingMiddleware

func WithDispatchStreamingMiddleware(dispatchStreamingMiddleware grpc.StreamServerInterceptor) ConfigOption

WithDispatchStreamingMiddleware returns an option that can append DispatchStreamingMiddlewares to Config.DispatchStreamingMiddleware

func WithDispatchUnaryMiddleware

func WithDispatchUnaryMiddleware(dispatchUnaryMiddleware grpc.UnaryServerInterceptor) ConfigOption

WithDispatchUnaryMiddleware returns an option that can append DispatchUnaryMiddlewares to Config.DispatchUnaryMiddleware

func WithDispatchUpstreamAddr

func WithDispatchUpstreamAddr(dispatchUpstreamAddr string) ConfigOption

WithDispatchUpstreamAddr returns an option that can set DispatchUpstreamAddr on a Config

func WithDispatchUpstreamCAPath

func WithDispatchUpstreamCAPath(dispatchUpstreamCAPath string) ConfigOption

WithDispatchUpstreamCAPath returns an option that can set DispatchUpstreamCAPath on a Config

func WithDispatchUpstreamTimeout

func WithDispatchUpstreamTimeout(dispatchUpstreamTimeout time.Duration) ConfigOption

WithDispatchUpstreamTimeout returns an option that can set DispatchUpstreamTimeout on a Config

func WithDispatcher

func WithDispatcher(dispatcher dispatch.Dispatcher) ConfigOption

WithDispatcher returns an option that can set Dispatcher on a Config

func WithEnableExperimentalLookupResources added in v0.0.3

func WithEnableExperimentalLookupResources(enableExperimentalLookupResources bool) ConfigOption

WithEnableExperimentalLookupResources returns an option that can set EnableExperimentalLookupResources on a Config

func WithEnableExperimentalWatchableSchemaCache

func WithEnableExperimentalWatchableSchemaCache(enableExperimentalWatchableSchemaCache bool) ConfigOption

WithEnableExperimentalWatchableSchemaCache returns an option that can set EnableExperimentalWatchableSchemaCache on a Config

func WithEnableRequestLogs

func WithEnableRequestLogs(enableRequestLogs bool) ConfigOption

WithEnableRequestLogs returns an option that can set EnableRequestLogs on a Config

func WithEnableResponseLogs

func WithEnableResponseLogs(enableResponseLogs bool) ConfigOption

WithEnableResponseLogs returns an option that can set EnableResponseLogs on a Config

func WithGRPCAuthFunc

func WithGRPCAuthFunc(gRPCAuthFunc auth.AuthFunc) ConfigOption

WithGRPCAuthFunc returns an option that can set GRPCAuthFunc on a Config

func WithGRPCServer

func WithGRPCServer(gRPCServer util.GRPCServerConfig) ConfigOption

WithGRPCServer returns an option that can set GRPCServer on a Config

func WithGlobalDispatchConcurrencyLimit

func WithGlobalDispatchConcurrencyLimit(globalDispatchConcurrencyLimit uint16) ConfigOption

WithGlobalDispatchConcurrencyLimit returns an option that can set GlobalDispatchConcurrencyLimit on a Config

func WithHTTPGateway

func WithHTTPGateway(hTTPGateway util.HTTPServerConfig) ConfigOption

WithHTTPGateway returns an option that can set HTTPGateway on a Config

func WithHTTPGatewayCorsAllowedOrigins

func WithHTTPGatewayCorsAllowedOrigins(hTTPGatewayCorsAllowedOrigins string) ConfigOption

WithHTTPGatewayCorsAllowedOrigins returns an option that can append HTTPGatewayCorsAllowedOriginss to Config.HTTPGatewayCorsAllowedOrigins

func WithHTTPGatewayCorsEnabled

func WithHTTPGatewayCorsEnabled(hTTPGatewayCorsEnabled bool) ConfigOption

WithHTTPGatewayCorsEnabled returns an option that can set HTTPGatewayCorsEnabled on a Config

func WithHTTPGatewayUpstreamAddr

func WithHTTPGatewayUpstreamAddr(hTTPGatewayUpstreamAddr string) ConfigOption

WithHTTPGatewayUpstreamAddr returns an option that can set HTTPGatewayUpstreamAddr on a Config

func WithHTTPGatewayUpstreamTLSCertPath

func WithHTTPGatewayUpstreamTLSCertPath(hTTPGatewayUpstreamTLSCertPath string) ConfigOption

WithHTTPGatewayUpstreamTLSCertPath returns an option that can set HTTPGatewayUpstreamTLSCertPath on a Config

func WithMaxBulkExportRelationshipsLimit

func WithMaxBulkExportRelationshipsLimit(maxBulkExportRelationshipsLimit uint32) ConfigOption

WithMaxBulkExportRelationshipsLimit returns an option that can set MaxBulkExportRelationshipsLimit on a Config

func WithMaxCaveatContextSize

func WithMaxCaveatContextSize(maxCaveatContextSize int) ConfigOption

WithMaxCaveatContextSize returns an option that can set MaxCaveatContextSize on a Config

func WithMaxDatastoreReadPageSize

func WithMaxDatastoreReadPageSize(maxDatastoreReadPageSize uint64) ConfigOption

WithMaxDatastoreReadPageSize returns an option that can set MaxDatastoreReadPageSize on a Config

func WithMaxDeleteRelationshipsLimit

func WithMaxDeleteRelationshipsLimit(maxDeleteRelationshipsLimit uint32) ConfigOption

WithMaxDeleteRelationshipsLimit returns an option that can set MaxDeleteRelationshipsLimit on a Config

func WithMaxLookupResourcesLimit

func WithMaxLookupResourcesLimit(maxLookupResourcesLimit uint32) ConfigOption

WithMaxLookupResourcesLimit returns an option that can set MaxLookupResourcesLimit on a Config

func WithMaxReadRelationshipsLimit

func WithMaxReadRelationshipsLimit(maxReadRelationshipsLimit uint32) ConfigOption

WithMaxReadRelationshipsLimit returns an option that can set MaxReadRelationshipsLimit on a Config

func WithMaxRelationshipContextSize

func WithMaxRelationshipContextSize(maxRelationshipContextSize int) ConfigOption

WithMaxRelationshipContextSize returns an option that can set MaxRelationshipContextSize on a Config

func WithMaximumPreconditionCount

func WithMaximumPreconditionCount(maximumPreconditionCount uint16) ConfigOption

WithMaximumPreconditionCount returns an option that can set MaximumPreconditionCount on a Config

func WithMaximumUpdatesPerWrite

func WithMaximumUpdatesPerWrite(maximumUpdatesPerWrite uint16) ConfigOption

WithMaximumUpdatesPerWrite returns an option that can set MaximumUpdatesPerWrite on a Config

func WithMetricsAPI

func WithMetricsAPI(metricsAPI util.HTTPServerConfig) ConfigOption

WithMetricsAPI returns an option that can set MetricsAPI on a Config

func WithNamespaceCacheConfig

func WithNamespaceCacheConfig(namespaceCacheConfig CacheConfig) ConfigOption

WithNamespaceCacheConfig returns an option that can set NamespaceCacheConfig on a Config

func WithPresharedSecureKey

func WithPresharedSecureKey(presharedSecureKey string) ConfigOption

WithPresharedSecureKey returns an option that can append PresharedSecureKeys to Config.PresharedSecureKey

func WithSchemaPrefixesRequired

func WithSchemaPrefixesRequired(schemaPrefixesRequired bool) ConfigOption

WithSchemaPrefixesRequired returns an option that can set SchemaPrefixesRequired on a Config

func WithSchemaWatchHeartbeat

func WithSchemaWatchHeartbeat(schemaWatchHeartbeat time.Duration) ConfigOption

WithSchemaWatchHeartbeat returns an option that can set SchemaWatchHeartbeat on a Config

func WithShutdownGracePeriod

func WithShutdownGracePeriod(shutdownGracePeriod time.Duration) ConfigOption

WithShutdownGracePeriod returns an option that can set ShutdownGracePeriod on a Config

func WithSilentlyDisableTelemetry

func WithSilentlyDisableTelemetry(silentlyDisableTelemetry bool) ConfigOption

WithSilentlyDisableTelemetry returns an option that can set SilentlyDisableTelemetry on a Config

func WithStreamingAPITimeout

func WithStreamingAPITimeout(streamingAPITimeout time.Duration) ConfigOption

WithStreamingAPITimeout returns an option that can set StreamingAPITimeout on a Config

func WithStreamingMiddlewareModification

func WithStreamingMiddlewareModification(streamingMiddlewareModification MiddlewareModification[grpc.StreamServerInterceptor]) ConfigOption

WithStreamingMiddlewareModification returns an option that can append StreamingMiddlewareModifications to Config.StreamingMiddlewareModification

func WithTelemetryCAOverridePath

func WithTelemetryCAOverridePath(telemetryCAOverridePath string) ConfigOption

WithTelemetryCAOverridePath returns an option that can set TelemetryCAOverridePath on a Config

func WithTelemetryEndpoint

func WithTelemetryEndpoint(telemetryEndpoint string) ConfigOption

WithTelemetryEndpoint returns an option that can set TelemetryEndpoint on a Config

func WithTelemetryInterval

func WithTelemetryInterval(telemetryInterval time.Duration) ConfigOption

WithTelemetryInterval returns an option that can set TelemetryInterval on a Config

func WithUnaryMiddlewareModification

func WithUnaryMiddlewareModification(unaryMiddlewareModification MiddlewareModification[grpc.UnaryServerInterceptor]) ConfigOption

WithUnaryMiddlewareModification returns an option that can append UnaryMiddlewareModifications to Config.UnaryMiddlewareModification

func WithV1SchemaAdditiveOnly

func WithV1SchemaAdditiveOnly(v1SchemaAdditiveOnly bool) ConfigOption

WithV1SchemaAdditiveOnly returns an option that can set V1SchemaAdditiveOnly on a Config

func WithWatchHeartbeat

func WithWatchHeartbeat(watchHeartbeat time.Duration) ConfigOption

WithWatchHeartbeat returns an option that can set WatchHeartbeat on a Config

type Middleware added in v0.0.3

type Middleware interface {
	UnaryServerInterceptor() grpc.UnaryServerInterceptor
	StreamServerInterceptor() grpc.StreamServerInterceptor
}

type MiddlewareChain

type MiddlewareChain[T middlewareTypes] struct {
	// contains filtered or unexported fields
}

MiddlewareChain describes an ordered sequence of middlewares that can be modified with one or more MiddlewareModification. This struct is used to facilitate the creation and modification of gRPC middleware chains

func DefaultStreamingMiddleware

func DefaultStreamingMiddleware(opts MiddlewareOption) (*MiddlewareChain[grpc.StreamServerInterceptor], error)

DefaultStreamingMiddleware generates the default middleware chain used for the public SpiceDB Streaming gRPC methods

func DefaultUnaryMiddleware

func DefaultUnaryMiddleware(opts MiddlewareOption) (*MiddlewareChain[grpc.UnaryServerInterceptor], error)

DefaultUnaryMiddleware generates the default middleware chain used for the public SpiceDB Unary gRPC methods

func NewMiddlewareChain

func NewMiddlewareChain[T middlewareTypes](mw ...ReferenceableMiddleware[T]) (MiddlewareChain[T], error)

NewMiddlewareChain creates a new middleware chain given zero or more named middlewares. An error will be returned in case validation of the NamedMiddlewares fail.

func (*MiddlewareChain[T]) Names

func (mc *MiddlewareChain[T]) Names() *mapz.Set[string]

Names returns the names of the middlewares in a chain

func (*MiddlewareChain[T]) ToGRPCInterceptors

func (mc *MiddlewareChain[T]) ToGRPCInterceptors() []T

ToGRPCInterceptors generates slices of gRPC interceptors ready to be installed in a server

type MiddlewareModification

type MiddlewareModification[T middlewareTypes] struct {
	// DependencyMiddlewareName is used to define with respect to which middleware an operation is performed.
	// Dependency is not required for ReplaceAll operation
	DependencyMiddlewareName string

	// Operation describes the type of operation to be performed
	Operation MiddlewareOperation

	// Middlewares are the named middlewares that will be part of this modification
	Middlewares []ReferenceableMiddleware[T]
}

MiddlewareModification describes an operation to modify a MiddlewareChain

type MiddlewareOperation

type MiddlewareOperation int

MiddlewareOperation describes the type of operation that will be performed in a MiddlewareModification

const (
	// OperationPrepend adds the middlewares right before the referenced dependency
	OperationPrepend MiddlewareOperation = iota

	// OperationReplace substitutes the referenced dependency with the middlewares of a modification.
	// If replaced with an empty modification, this acts like a deletion
	OperationReplace

	// OperationAppend adds the middlewares right after the referenced dependency
	OperationAppend

	// OperationReplaceAllUnsafe replaces all middlewares in a chain with those in the modification
	// this operation is only meant to be used in tests.
	OperationReplaceAllUnsafe
)

type MiddlewareOption

type MiddlewareOption struct {
	Logger                  zerolog.Logger      `debugmap:"hidden"`
	AuthFunc                grpcauth.AuthFunc   `debugmap:"hidden"`
	EnableVersionResponse   bool                `debugmap:"visible"`
	DispatcherForMiddleware dispatch.Dispatcher `debugmap:"hidden"`
	EnableRequestLog        bool                `debugmap:"visible"`
	EnableResponseLog       bool                `debugmap:"visible"`
	DisableGRPCHistogram    bool                `debugmap:"visible"`
	// contains filtered or unexported fields
}

func MiddlewareOptionWithOptions added in v0.0.3

func MiddlewareOptionWithOptions(m *MiddlewareOption, opts ...MiddlewareOptionOption) *MiddlewareOption

MiddlewareOptionWithOptions configures an existing MiddlewareOption with the passed in options set

func NewMiddlewareOptionWithOptions added in v0.0.3

func NewMiddlewareOptionWithOptions(opts ...MiddlewareOptionOption) *MiddlewareOption

NewMiddlewareOptionWithOptions creates a new MiddlewareOption with the passed in options set

func NewMiddlewareOptionWithOptionsAndDefaults added in v0.0.3

func NewMiddlewareOptionWithOptionsAndDefaults(opts ...MiddlewareOptionOption) *MiddlewareOption

NewMiddlewareOptionWithOptionsAndDefaults creates a new MiddlewareOption with the passed in options set starting from the defaults

func (MiddlewareOption) DebugMap added in v0.0.3

func (m MiddlewareOption) DebugMap() map[string]any

DebugMap returns a map form of MiddlewareOption for debugging

func (*MiddlewareOption) ToOption added in v0.0.3

ToOption returns a new MiddlewareOptionOption that sets the values from the passed in MiddlewareOption

func (MiddlewareOption) WithDatastore added in v0.0.3

func (MiddlewareOption) WithDatastoreMiddleware added in v0.0.3

func (m MiddlewareOption) WithDatastoreMiddleware(middleware Middleware) MiddlewareOption

func (*MiddlewareOption) WithOptions added in v0.0.3

func (m *MiddlewareOption) WithOptions(opts ...MiddlewareOptionOption) *MiddlewareOption

WithOptions configures the receiver MiddlewareOption with the passed in options set

type MiddlewareOptionOption added in v0.0.3

type MiddlewareOptionOption func(m *MiddlewareOption)

func WithAuthFunc added in v0.0.3

func WithAuthFunc(authFunc auth.AuthFunc) MiddlewareOptionOption

WithAuthFunc returns an option that can set AuthFunc on a MiddlewareOption

func WithDisableGRPCHistogram added in v0.0.3

func WithDisableGRPCHistogram(disableGRPCHistogram bool) MiddlewareOptionOption

WithDisableGRPCHistogram returns an option that can set DisableGRPCHistogram on a MiddlewareOption

func WithDispatcherForMiddleware added in v0.0.3

func WithDispatcherForMiddleware(dispatcherForMiddleware dispatch.Dispatcher) MiddlewareOptionOption

WithDispatcherForMiddleware returns an option that can set DispatcherForMiddleware on a MiddlewareOption

func WithEnableRequestLog added in v0.0.3

func WithEnableRequestLog(enableRequestLog bool) MiddlewareOptionOption

WithEnableRequestLog returns an option that can set EnableRequestLog on a MiddlewareOption

func WithEnableResponseLog added in v0.0.3

func WithEnableResponseLog(enableResponseLog bool) MiddlewareOptionOption

WithEnableResponseLog returns an option that can set EnableResponseLog on a MiddlewareOption

func WithEnableVersionResponse added in v0.0.3

func WithEnableVersionResponse(enableVersionResponse bool) MiddlewareOptionOption

WithEnableVersionResponse returns an option that can set EnableVersionResponse on a MiddlewareOption

func WithLogger added in v0.0.3

func WithLogger(logger zerolog.Logger) MiddlewareOptionOption

WithLogger returns an option that can set Logger on a MiddlewareOption

type ReferenceableMiddleware

type ReferenceableMiddleware[T middlewareTypes] struct {
	Name       string
	Internal   bool
	Middleware T
}

ReferenceableMiddleware represents a middleware in a MiddlewareChain. Middlewares can be referenced by name in MiddlewareModification, for example "append after middleware abc". Internal middlewares can also be referenced for operations like append or prepend, but cannot be referenced for replace operations. Middlewares must always be named.

type RunnableServer

type RunnableServer interface {
	Run(ctx context.Context) error
	GRPCDialContext(ctx context.Context, opts ...grpc.DialOption) (*grpc.ClientConn, error)
	DispatchNetDialContext(ctx context.Context, s string) (net.Conn, error)
}

RunnableServer is a spicedb service set ready to run

type StreamOrderEnforcerBuilder

type StreamOrderEnforcerBuilder struct {
	// contains filtered or unexported fields
}

func NewStreamMiddleware

func NewStreamMiddleware() *StreamOrderEnforcerBuilder

func (*StreamOrderEnforcerBuilder) Done

func (*StreamOrderEnforcerBuilder) EnsureInterceptorAlreadyExecuted

func (soeb *StreamOrderEnforcerBuilder) EnsureInterceptorAlreadyExecuted(name string) *StreamOrderEnforcerBuilder

func (*StreamOrderEnforcerBuilder) EnsureInterceptorNotExecuted

func (soeb *StreamOrderEnforcerBuilder) EnsureInterceptorNotExecuted(name string) *StreamOrderEnforcerBuilder

func (*StreamOrderEnforcerBuilder) EnsureWrapperAlreadyExecuted

func (soeb *StreamOrderEnforcerBuilder) EnsureWrapperAlreadyExecuted(name string) *StreamOrderEnforcerBuilder

func (*StreamOrderEnforcerBuilder) EnsureWrapperNotExecuted

func (soeb *StreamOrderEnforcerBuilder) EnsureWrapperNotExecuted(name string) *StreamOrderEnforcerBuilder

func (*StreamOrderEnforcerBuilder) WithInterceptor

func (*StreamOrderEnforcerBuilder) WithInternal

func (soeb *StreamOrderEnforcerBuilder) WithInternal(internal bool) *StreamOrderEnforcerBuilder

func (*StreamOrderEnforcerBuilder) WithName

type UnaryOrderEnforcerBuilder

type UnaryOrderEnforcerBuilder struct {
	// contains filtered or unexported fields
}

func NewUnaryMiddleware

func NewUnaryMiddleware() *UnaryOrderEnforcerBuilder

func (*UnaryOrderEnforcerBuilder) Done

func (*UnaryOrderEnforcerBuilder) EnsureAlreadyExecuted

func (soeb *UnaryOrderEnforcerBuilder) EnsureAlreadyExecuted(name string) *UnaryOrderEnforcerBuilder

func (*UnaryOrderEnforcerBuilder) EnsureNotExecuted

func (soeb *UnaryOrderEnforcerBuilder) EnsureNotExecuted(name string) *UnaryOrderEnforcerBuilder

func (*UnaryOrderEnforcerBuilder) WithInterceptor

func (*UnaryOrderEnforcerBuilder) WithInternal

func (soeb *UnaryOrderEnforcerBuilder) WithInternal(internal bool) *UnaryOrderEnforcerBuilder

func (*UnaryOrderEnforcerBuilder) WithName

Jump to

Keyboard shortcuts

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