server

package
v1.15.5 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PluginsRoot = root + ".plugins"
)

Variables

This section is empty.

Functions

func ConfigAdd

func ConfigAdd(path string)

func Error

func Error(err error) error

Error converts errors to grpc errors

func ToStruct

func ToStruct(v map[string]interface{}) *st.Struct

ToStruct converts a map[string]interface{} to a ptypes.Struct

func ToValue

func ToValue(v interface{}) *st.Value

ToValue converts an interface{} to a ptypes.Value

Types

type Options

type Options struct {
	Port                  int
	MaxConcurrentStreams  int64
	InitialWindowSize     int32
	InitialConnWindowSize int32
	TLS                   TLSOptions `config:"tls"`
}

Options grpc server options.

func NewOptions

func NewOptions() (*Options, error)

NewOptions returns options from config file or environment vars.

func NewOptionsWithPath

func NewOptionsWithPath(path string) (opts *Options, err error)

NewOptionsWithPath unmarshals a given key path into options and returns it.

type Plugin

type Plugin func(ctx context.Context) []grpc.ServerOption

Plugin defines a grpc server Plugin function to execute.

type Server

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

Server represents a grpc server.

func NewServer

func NewServer(ctx context.Context, plugins ...Plugin) *Server

NewServer returns a new grpc server with default options.

func NewServerWithConfigPath

func NewServerWithConfigPath(ctx context.Context, path string) (*Server, error)

NewServerWithConfigPath returns a new grpc server with options from config path.

func NewServerWithOptions

func NewServerWithOptions(ctx context.Context, opt *Options, plugins ...Plugin) *Server

NewServerWithOptions returns a new grpc server with options.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context)

Serve starts grpc server.

func (*Server) Server

func (s *Server) Server() *grpc.Server

Server returns the wrapped grpc server instance.

func (*Server) ServiceRegistrar

func (s *Server) ServiceRegistrar() grpc.ServiceRegistrar

ServiceRegistrar returns grpc service register.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context)

Shutdown stops grpc server gracefully.

type TLSAutoOptions

type TLSAutoOptions struct {
	Host string
}

type TLSFileOptions

type TLSFileOptions struct {
	Cert string
	Key  string
	CA   string `config:"ca"`
}

type TLSOptions

type TLSOptions struct {
	Enabled bool
	Type    string
	Auto    TLSAutoOptions
	File    TLSFileOptions
}

Jump to

Keyboard shortcuts

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