config

package
v0.0.0-...-14d8bfa Latest Latest
Warning

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

Go to latest
Published: May 3, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

README

config

-- import "github.com/autom8ter/engine/config"

Usage

type Config
type Config struct {
	Network            string `json:"network" validate:"required"`
	Address            string `json:"address" validate:"required"`
	Plugins            []driver.Plugin
	UnaryInterceptors  []grpc.UnaryServerInterceptor
	StreamInterceptors []grpc.StreamServerInterceptor
	Option             []grpc.ServerOption
}

Config contains configurations of gRPC and Gateway server. A new instance of Config is created from your config.yaml|config.json file in your current working directory Network, Address, and Paths can be set in your config file to set the Config instance. Otherwise, defaults are set.

func New
func New(network, addr string, debug bool) *Config

New creates a config from your config file. If no config file is present, the resulting Config will have the following defaults: netowork: "tcp" address: ":3000" use the With method to continue to modify the resulting Config object

func (*Config) CreateListener
func (c *Config) CreateListener() (*lis.Listener, error)

CreateListener creates a network listener from the network and address config

func (*Config) Debug
func (c *Config) Debug() string
func (*Config) ServerOptions
func (c *Config) ServerOptions() []grpc.ServerOption
func (*Config) With
func (c *Config) With(opts ...Option) *Config

With is used to configure/initialize a Config with custom options

type Option
type Option func(*Config)

Option configures a gRPC and a gateway server.

func WithAuthUnaryMiddleware
func WithAuthUnaryMiddleware(fn func(ctx context.Context) (context.Context, error)) Option
func WithChannelz
func WithChannelz() Option

WithChannelz adds grpc server channelz to the list of plugins ref: https://godoc.org/google.golang.org/grpc/channelz/grpc_channelz_v1

func WithConnTimeout
func WithConnTimeout(t time.Duration) Option

WithStatsHandler ConnectionTimeout returns a ServerOption that sets the timeout for connection establishment (up to and including HTTP/2 handshaking) for all new connections. If this is not set, the default is 120 seconds.

func WithCreds
func WithCreds(creds credentials.TransportCredentials) Option

WithCreds returns a ServerOption that sets credentials for server connections.

func WithDefaultMiddlewares
func WithDefaultMiddlewares() Option
func WithDefaultPlugins
func WithDefaultPlugins() Option
func WithHealthz
func WithHealthz() Option

WithHealthz exposes server's health and it must be imported to enable support for client-side health checks and adds it to plugins. ref: https://godoc.org/google.golang.org/grpc/health

func WithMaxConcurrentStreams
func WithMaxConcurrentStreams(num uint32) Option

WithMaxConcurrentStreams returns a ServerOption that will apply a limit on the number of concurrent streams to each ServerTransport.

func WithPlugins
func WithPlugins(svrs ...driver.Plugin) Option

WithGoPlugins returns an Option that adds hard-coded Plugins(golang) to the engine runtime as opposed to go/plugins. See driver.Plugin for the interface definition.

func WithReflection
func WithReflection() Option

WithReflection adds grpc server reflection to the list of plugins ref: https://godoc.org/google.golang.org/grpc/reflection

func WithStatsHandler
func WithStatsHandler(h stats.Handler) Option

WithStatsHandler returns a ServerOption that sets the stats handler for the server.

func WithStreamInterceptors
func WithStreamInterceptors(interceptors ...grpc.StreamServerInterceptor) Option

WithGrpcServerStreamInterceptors returns an Option that sets stream interceptor(s) for a gRPC server.

func WithStreamLoggingMiddleware
func WithStreamLoggingMiddleware() Option
func WithStreamRateLimitMiddleware
func WithStreamRateLimitMiddleware(waitDur time.Duration) Option
func WithStreamRecoveryMiddleware
func WithStreamRecoveryMiddleware() Option
func WithStreamTraceMiddleware
func WithStreamTraceMiddleware() Option
func WithUnaryInterceptors
func WithUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor) Option

WithUnaryInterceptors returns an Option that sets unary interceptor(s) for a gRPC server.

func WithUnaryLoggingMiddleware
func WithUnaryLoggingMiddleware() Option
func WithUnaryRateLimitMiddleware
func WithUnaryRateLimitMiddleware(waitDur time.Duration) Option
func WithUnaryRecoveryMiddleware
func WithUnaryRecoveryMiddleware() Option
func WithUnaryTraceMiddleware
func WithUnaryTraceMiddleware() Option
func WithUnaryUUIDMiddleware
func WithUnaryUUIDMiddleware() Option

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Network            string `json:"network" validate:"required"`
	Address            string `json:"address" validate:"required"`
	Plugins            []driver.Plugin
	UnaryInterceptors  []grpc.UnaryServerInterceptor
	StreamInterceptors []grpc.StreamServerInterceptor
	Option             []grpc.ServerOption
}

Config contains configurations of gRPC and Gateway server. A new instance of Config is created from your config.yaml|config.json file in your current working directory Network, Address, and Paths can be set in your config file to set the Config instance. Otherwise, defaults are set.

func New

func New(network, addr string, debug bool) *Config

New creates a config from your config file. If no config file is present, the resulting Config will have the following defaults: netowork: "tcp" address: ":3000" use the With method to continue to modify the resulting Config object

func (*Config) CreateListener

func (c *Config) CreateListener() (*lis.Listener, error)

CreateListener creates a network listener from the network and address config

func (*Config) Debug

func (c *Config) Debug() string

func (*Config) ServerOptions

func (c *Config) ServerOptions() []grpc.ServerOption

func (*Config) With

func (c *Config) With(opts ...Option) *Config

With is used to configure/initialize a Config with custom options

type Option

type Option func(*Config)

Option configures a gRPC and a gateway server.

func WithAuthUnaryMiddleware

func WithAuthUnaryMiddleware(fn func(ctx context.Context) (context.Context, error)) Option

func WithChannelz

func WithChannelz() Option

WithChannelz adds grpc server channelz to the list of plugins ref: https://godoc.org/google.golang.org/grpc/channelz/grpc_channelz_v1

func WithConnTimeout

func WithConnTimeout(t time.Duration) Option

WithStatsHandler ConnectionTimeout returns a ServerOption that sets the timeout for connection establishment (up to and including HTTP/2 handshaking) for all new connections. If this is not set, the default is 120 seconds.

func WithCreds

func WithCreds(creds credentials.TransportCredentials) Option

WithCreds returns a ServerOption that sets credentials for server connections.

func WithDefaultMiddlewares

func WithDefaultMiddlewares() Option

func WithDefaultPlugins

func WithDefaultPlugins() Option

func WithHealthz

func WithHealthz() Option

WithHealthz exposes server's health and it must be imported to enable support for client-side health checks and adds it to plugins. ref: https://godoc.org/google.golang.org/grpc/health

func WithMaxConcurrentStreams

func WithMaxConcurrentStreams(num uint32) Option

WithMaxConcurrentStreams returns a ServerOption that will apply a limit on the number of concurrent streams to each ServerTransport.

func WithPlugins

func WithPlugins(svrs ...driver.Plugin) Option

WithGoPlugins returns an Option that adds hard-coded Plugins(golang) to the engine runtime as opposed to go/plugins. See driver.Plugin for the interface definition.

func WithReflection

func WithReflection() Option

WithReflection adds grpc server reflection to the list of plugins ref: https://godoc.org/google.golang.org/grpc/reflection

func WithStatsHandler

func WithStatsHandler(h stats.Handler) Option

WithStatsHandler returns a ServerOption that sets the stats handler for the server.

func WithStreamInterceptors

func WithStreamInterceptors(interceptors ...grpc.StreamServerInterceptor) Option

WithGrpcServerStreamInterceptors returns an Option that sets stream interceptor(s) for a gRPC server.

func WithStreamLoggingMiddleware

func WithStreamLoggingMiddleware() Option

func WithStreamRateLimitMiddleware

func WithStreamRateLimitMiddleware(waitDur time.Duration) Option

func WithStreamRecoveryMiddleware

func WithStreamRecoveryMiddleware() Option

func WithStreamTraceMiddleware

func WithStreamTraceMiddleware() Option

func WithUnaryInterceptors

func WithUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor) Option

WithUnaryInterceptors returns an Option that sets unary interceptor(s) for a gRPC server.

func WithUnaryLoggingMiddleware

func WithUnaryLoggingMiddleware() Option

func WithUnaryRateLimitMiddleware

func WithUnaryRateLimitMiddleware(waitDur time.Duration) Option

func WithUnaryRecoveryMiddleware

func WithUnaryRecoveryMiddleware() Option

func WithUnaryTraceMiddleware

func WithUnaryTraceMiddleware() Option

func WithUnaryUUIDMiddleware

func WithUnaryUUIDMiddleware() Option

Jump to

Keyboard shortcuts

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