server

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: Apache-2.0 Imports: 48 Imported by: 1

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
var DisableTelemetryHandler *prometheus.Registry

Functions

func DefaultPreRunE

func DefaultPreRunE(programName string) cobrautil.CobraRunFunc

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

func MetricsHandler

func MetricsHandler(telemetryRegistry *prometheus.Registry) http.Handler

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

func RegisterCacheConfigFlags

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

RegisterCacheConfigFlags registers flags for a ristretto-based cache.

func ServeExample

func ServeExample(programName string) string

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

Types

type CacheConfig

type CacheConfig struct {
	MaxCost     string
	NumCounters int64
	Metrics     bool
}

CacheConfig defines configuration for a ristretto cache. See: https://github.com/dgraph-io/ristretto#Config

func (*CacheConfig) Complete

func (cc *CacheConfig) Complete() (*ristretto.Config, error)

Complete converts the cache config into a ristretto cache config.

type Config

type Config struct {
	// API config
	GRPCServer          util.GRPCServerConfig
	GRPCAuthFunc        grpc_auth.AuthFunc
	PresharedKey        []string
	ShutdownGracePeriod time.Duration

	// GRPC Gateway config
	HTTPGateway                    util.HTTPServerConfig
	HTTPGatewayUpstreamAddr        string
	HTTPGatewayUpstreamTLSCertPath string
	HTTPGatewayCorsEnabled         bool
	HTTPGatewayCorsAllowedOrigins  []string

	// Datastore
	DatastoreConfig datastorecfg.Config
	Datastore       datastore.Datastore

	// Namespace cache
	NamespaceManager     namespace.Manager
	NamespaceCacheConfig CacheConfig

	// Schema options
	SchemaPrefixesRequired bool

	// Dispatch options
	DispatchServer               util.GRPCServerConfig
	DispatchMaxDepth             uint32
	DispatchUpstreamAddr         string
	DispatchUpstreamCAPath       string
	DispatchClientMetricsPrefix  string
	DispatchClusterMetricsPrefix string
	Dispatcher                   dispatch.Dispatcher

	DispatchCacheConfig        CacheConfig
	ClusterDispatchCacheConfig CacheConfig

	// API Behavior
	DisableV1SchemaAPI bool

	// Additional Services
	DashboardAPI util.HTTPServerConfig
	MetricsAPI   util.HTTPServerConfig

	// Middleware for grpc
	UnaryMiddleware     []grpc.UnaryServerInterceptor
	StreamingMiddleware []grpc.StreamServerInterceptor

	// Middleware for dispatch
	DispatchUnaryMiddleware     []grpc.UnaryServerInterceptor
	DispatchStreamingMiddleware []grpc.StreamServerInterceptor

	// Telemetry
	SilentlyDisableTelemetry bool
	TelemetryCAOverridePath  string
	TelemetryEndpoint        string
	TelemetryInterval        time.Duration
}

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 (*Config) Complete

func (c *Config) Complete() (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) ToOption

func (c *Config) ToOption() ConfigOption

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

type ConfigOption

type ConfigOption func(c *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 SetPresharedKey added in v1.7.0

func SetPresharedKey(presharedKey []string) ConfigOption

SetPresharedKey returns an option that can set PresharedKey on a Config

func SetStreamingMiddleware

func SetStreamingMiddleware(streamingMiddleware []grpc.StreamServerInterceptor) ConfigOption

SetStreamingMiddleware returns an option that can set StreamingMiddleware on a Config

func SetUnaryMiddleware

func SetUnaryMiddleware(unaryMiddleware []grpc.UnaryServerInterceptor) ConfigOption

SetUnaryMiddleware returns an option that can set UnaryMiddleware on a Config

func WithClusterDispatchCacheConfig

func WithClusterDispatchCacheConfig(clusterDispatchCacheConfig CacheConfig) ConfigOption

WithClusterDispatchCacheConfig returns an option that can set ClusterDispatchCacheConfig on a Config

func WithDashboardAPI

func WithDashboardAPI(dashboardAPI util.HTTPServerConfig) ConfigOption

WithDashboardAPI returns an option that can set DashboardAPI 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 WithDisableV1SchemaAPI

func WithDisableV1SchemaAPI(disableV1SchemaAPI bool) ConfigOption

WithDisableV1SchemaAPI returns an option that can set DisableV1SchemaAPI on a Config

func WithDispatchCacheConfig

func WithDispatchCacheConfig(dispatchCacheConfig CacheConfig) ConfigOption

WithDispatchCacheConfig returns an option that can set DispatchCacheConfig on a Config

func WithDispatchClientMetricsPrefix

func WithDispatchClientMetricsPrefix(dispatchClientMetricsPrefix string) ConfigOption

WithDispatchClientMetricsPrefix returns an option that can set DispatchClientMetricsPrefix 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 WithDispatchMaxDepth

func WithDispatchMaxDepth(dispatchMaxDepth uint32) ConfigOption

WithDispatchMaxDepth returns an option that can set DispatchMaxDepth on a Config

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 WithDispatcher

func WithDispatcher(dispatcher dispatch.Dispatcher) ConfigOption

WithDispatcher returns an option that can set Dispatcher 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 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 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 WithNamespaceManager added in v1.6.0

func WithNamespaceManager(namespaceManager namespace.Manager) ConfigOption

WithNamespaceManager returns an option that can set NamespaceManager on a Config

func WithPresharedKey

func WithPresharedKey(presharedKey string) ConfigOption

WithPresharedKey returns an option that can append PresharedKeys to Config.PresharedKey

func WithSchemaPrefixesRequired

func WithSchemaPrefixesRequired(schemaPrefixesRequired bool) ConfigOption

WithSchemaPrefixesRequired returns an option that can set SchemaPrefixesRequired 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 WithStreamingMiddleware

func WithStreamingMiddleware(streamingMiddleware grpc.StreamServerInterceptor) ConfigOption

WithStreamingMiddleware returns an option that can append StreamingMiddlewares to Config.StreamingMiddleware

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 WithUnaryMiddleware

func WithUnaryMiddleware(unaryMiddleware grpc.UnaryServerInterceptor) ConfigOption

WithUnaryMiddleware returns an option that can append UnaryMiddlewares to Config.UnaryMiddleware

type RunnableServer

type RunnableServer interface {
	Run(ctx context.Context) error
	Middleware() ([]grpc.UnaryServerInterceptor, []grpc.StreamServerInterceptor)
	SetMiddleware(unaryInterceptors []grpc.UnaryServerInterceptor, streamingInterceptors []grpc.StreamServerInterceptor) RunnableServer
	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

Jump to

Keyboard shortcuts

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