server

package
v1.31.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 74 Imported by: 1

Documentation

Overview

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 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 added in v1.30.0

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 added in v1.23.0

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 RegisterCacheFlags added in v1.13.0

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

RegisterCacheFlags 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"`
	// contains filtered or unexported fields
}

CacheConfig defines the configuration various SpiceDB caches.

func CacheConfigWithOptions added in v1.22.0

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

CacheConfigWithOptions configures an existing CacheConfig with the passed in options set

func NewCacheConfigWithOptions added in v1.22.0

func NewCacheConfigWithOptions(opts ...CacheConfigOption) *CacheConfig

NewCacheConfigWithOptions creates a new CacheConfig with the passed in options set

func NewCacheConfigWithOptionsAndDefaults added in v1.22.0

func NewCacheConfigWithOptionsAndDefaults(opts ...CacheConfigOption) *CacheConfig

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

func (*CacheConfig) Complete

func (cc *CacheConfig) Complete() (cache.Cache, error)

Complete translates the CLI cache config into a cache config.

func (CacheConfig) DebugMap added in v1.22.0

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

DebugMap returns a map form of CacheConfig for debugging

func (*CacheConfig) ToOption added in v1.22.0

func (c *CacheConfig) ToOption() CacheConfigOption

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

func (*CacheConfig) WithOptions added in v1.22.0

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

WithOptions configures the receiver CacheConfig with the passed in options set

func (*CacheConfig) WithRevisionParameters added in v1.21.0

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 added in v1.22.0

type CacheConfigOption func(c *CacheConfig)

func WithEnabled added in v1.22.0

func WithEnabled(enabled bool) CacheConfigOption

WithEnabled returns an option that can set Enabled on a CacheConfig

func WithMaxCost added in v1.22.0

func WithMaxCost(maxCost string) CacheConfigOption

WithMaxCost returns an option that can set MaxCost on a CacheConfig

func WithMetrics added in v1.22.0

func WithMetrics(metrics bool) CacheConfigOption

WithMetrics returns an option that can set Metrics on a CacheConfig

func WithName added in v1.22.0

func WithName(name string) CacheConfigOption

WithName returns an option that can set Name on a CacheConfig

func WithNumCounters added in v1.22.0

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"`

	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"`

	// 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 added in v1.22.0

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 added in v1.22.0

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 added in v1.22.0

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 added in v1.27.0

func SetDispatchSecondaryUpstreamAddrs(dispatchSecondaryUpstreamAddrs map[string]string) ConfigOption

SetDispatchSecondaryUpstreamAddrs returns an option that can set DispatchSecondaryUpstreamAddrs on a Config

func SetDispatchSecondaryUpstreamExprs added in v1.27.0

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 added in v1.22.0

func SetPresharedSecureKey(presharedSecureKey []string) ConfigOption

SetPresharedSecureKey returns an option that can set PresharedSecureKey on a Config

func SetStreamingMiddlewareModification added in v1.22.2

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

SetStreamingMiddlewareModification returns an option that can set StreamingMiddlewareModification on a Config

func SetUnaryMiddlewareModification added in v1.22.2

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 added in v1.30.0

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 added in v1.8.0

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 WithDispatchClientMetricsEnabled added in v1.17.0

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 added in v1.17.0

func WithDispatchClusterMetricsEnabled(dispatchClusterMetricsEnabled bool) ConfigOption

WithDispatchClusterMetricsEnabled returns an option that can set DispatchClusterMetricsEnabled on a Config

func WithDispatchClusterMetricsPrefix added in v1.6.0

func WithDispatchClusterMetricsPrefix(dispatchClusterMetricsPrefix string) ConfigOption

WithDispatchClusterMetricsPrefix returns an option that can set DispatchClusterMetricsPrefix on a Config

func WithDispatchConcurrencyLimits added in v1.16.0

func WithDispatchConcurrencyLimits(dispatchConcurrencyLimits graph.ConcurrencyLimits) ConfigOption

WithDispatchConcurrencyLimits returns an option that can set DispatchConcurrencyLimits on a Config

func WithDispatchHashringReplicationFactor added in v1.18.1

func WithDispatchHashringReplicationFactor(dispatchHashringReplicationFactor uint16) ConfigOption

WithDispatchHashringReplicationFactor returns an option that can set DispatchHashringReplicationFactor on a Config

func WithDispatchHashringSpread added in v1.20.0

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 added in v1.27.0

func WithDispatchSecondaryUpstreamAddrs(key string, value string) ConfigOption

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

func WithDispatchSecondaryUpstreamExprs added in v1.27.0

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 added in v1.16.2

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 WithEnableExperimentalWatchableSchemaCache added in v1.25.0

func WithEnableExperimentalWatchableSchemaCache(enableExperimentalWatchableSchemaCache bool) ConfigOption

WithEnableExperimentalWatchableSchemaCache returns an option that can set EnableExperimentalWatchableSchemaCache on a Config

func WithEnableRequestLogs added in v1.27.0

func WithEnableRequestLogs(enableRequestLogs bool) ConfigOption

WithEnableRequestLogs returns an option that can set EnableRequestLogs on a Config

func WithEnableResponseLogs added in v1.27.0

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 added in v1.16.0

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 WithMaxCaveatContextSize added in v1.18.0

func WithMaxCaveatContextSize(maxCaveatContextSize int) ConfigOption

WithMaxCaveatContextSize returns an option that can set MaxCaveatContextSize on a Config

func WithMaxDatastoreReadPageSize added in v1.21.0

func WithMaxDatastoreReadPageSize(maxDatastoreReadPageSize uint64) ConfigOption

WithMaxDatastoreReadPageSize returns an option that can set MaxDatastoreReadPageSize on a Config

func WithMaxRelationshipContextSize added in v1.22.0

func WithMaxRelationshipContextSize(maxRelationshipContextSize int) ConfigOption

WithMaxRelationshipContextSize returns an option that can set MaxRelationshipContextSize on a Config

func WithMaximumPreconditionCount added in v1.12.0

func WithMaximumPreconditionCount(maximumPreconditionCount uint16) ConfigOption

WithMaximumPreconditionCount returns an option that can set MaximumPreconditionCount on a Config

func WithMaximumUpdatesPerWrite added in v1.12.0

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 added in v1.22.0

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 added in v1.29.0

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 added in v1.7.0

func WithSilentlyDisableTelemetry(silentlyDisableTelemetry bool) ConfigOption

WithSilentlyDisableTelemetry returns an option that can set SilentlyDisableTelemetry on a Config

func WithStreamingAPITimeout added in v1.21.0

func WithStreamingAPITimeout(streamingAPITimeout time.Duration) ConfigOption

WithStreamingAPITimeout returns an option that can set StreamingAPITimeout on a Config

func WithStreamingMiddlewareModification added in v1.22.2

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

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

func WithTelemetryCAOverridePath added in v1.7.0

func WithTelemetryCAOverridePath(telemetryCAOverridePath string) ConfigOption

WithTelemetryCAOverridePath returns an option that can set TelemetryCAOverridePath on a Config

func WithTelemetryEndpoint added in v1.7.0

func WithTelemetryEndpoint(telemetryEndpoint string) ConfigOption

WithTelemetryEndpoint returns an option that can set TelemetryEndpoint on a Config

func WithTelemetryInterval added in v1.7.0

func WithTelemetryInterval(telemetryInterval time.Duration) ConfigOption

WithTelemetryInterval returns an option that can set TelemetryInterval on a Config

func WithUnaryMiddlewareModification added in v1.22.2

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

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

func WithV1SchemaAdditiveOnly added in v1.15.0

func WithV1SchemaAdditiveOnly(v1SchemaAdditiveOnly bool) ConfigOption

WithV1SchemaAdditiveOnly returns an option that can set V1SchemaAdditiveOnly on a Config

func WithWatchHeartbeat added in v1.29.0

func WithWatchHeartbeat(watchHeartbeat time.Duration) ConfigOption

WithWatchHeartbeat returns an option that can set WatchHeartbeat on a Config

type MiddlewareChain added in v1.16.0

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 added in v1.22.2

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

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

func DefaultUnaryMiddleware added in v1.22.2

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

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

func NewMiddlewareChain added in v1.16.0

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 added in v1.16.0

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

Names returns the names of the middlewares in a chain

func (*MiddlewareChain[T]) ToGRPCInterceptors added in v1.16.0

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

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

type MiddlewareModification added in v1.16.0

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 added in v1.16.0

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 added in v1.27.0

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

type ReferenceableMiddleware added in v1.16.0

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 added in v1.22.2

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

func NewStreamMiddleware added in v1.22.2

func NewStreamMiddleware() *StreamOrderEnforcerBuilder

func (*StreamOrderEnforcerBuilder) Done added in v1.22.2

func (*StreamOrderEnforcerBuilder) EnsureInterceptorAlreadyExecuted added in v1.22.2

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

func (*StreamOrderEnforcerBuilder) EnsureInterceptorNotExecuted added in v1.22.2

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

func (*StreamOrderEnforcerBuilder) EnsureWrapperAlreadyExecuted added in v1.22.2

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

func (*StreamOrderEnforcerBuilder) EnsureWrapperNotExecuted added in v1.22.2

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

func (*StreamOrderEnforcerBuilder) WithInterceptor added in v1.22.2

func (*StreamOrderEnforcerBuilder) WithInternal added in v1.22.2

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

func (*StreamOrderEnforcerBuilder) WithName added in v1.22.2

type UnaryOrderEnforcerBuilder added in v1.22.2

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

func NewUnaryMiddleware added in v1.22.2

func NewUnaryMiddleware() *UnaryOrderEnforcerBuilder

func (*UnaryOrderEnforcerBuilder) Done added in v1.22.2

func (*UnaryOrderEnforcerBuilder) EnsureAlreadyExecuted added in v1.22.2

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

func (*UnaryOrderEnforcerBuilder) EnsureNotExecuted added in v1.22.2

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

func (*UnaryOrderEnforcerBuilder) WithInterceptor added in v1.22.2

func (*UnaryOrderEnforcerBuilder) WithInternal added in v1.22.2

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

func (*UnaryOrderEnforcerBuilder) WithName added in v1.22.2

Jump to

Keyboard shortcuts

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