builder

package
v0.32.41 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultGatewayAllowedHeaders = []string{
	headers.Authorization,
	headers.ContentType,
	headers.IfMatch,
	headers.IfNoneMatch,
	"Depth",
}
View Source
var DefaultGatewayAllowedMethods = []string{
	http.MethodGet,
	http.MethodPost,
	http.MethodHead,
	http.MethodDelete,
	http.MethodPut,
	http.MethodPatch,
	"PROPFIND",
	"MKCOL",
	"COPY",
	"MOVE",
}
View Source
var DefaultGatewayAllowedOrigins = []string{
	"http://localhost",
	"http://localhost:*",
	"https://localhost",
	"https://localhost:*",
	"http://127.0.0.1",
	"http://127.0.0.1:*",
	"https://127.0.0.1",
	"https://127.0.0.1:*",
}

Functions

This section is empty.

Types

type API

type API struct {
	Needs []string `json:"needs"`
	GRPC  struct {
		FQDN          string `json:"fqdn"`
		ListenAddress string `json:"listen_address"`
		// Default connection timeout is 120 seconds
		// https://godoc.org/google.golang.org/grpc#ConnectionTimeout
		ConnectionTimeoutSeconds uint32           `json:"connection_timeout_seconds"`
		Certs                    aserto.TLSConfig `json:"certs"`
	} `json:"grpc"`
	Gateway struct {
		FQDN              string           `json:"fqdn"`
		ListenAddress     string           `json:"listen_address"`
		AllowedOrigins    []string         `json:"allowed_origins"`
		AllowedHeaders    []string         `json:"allowed_headers"`
		AllowedMethods    []string         `json:"allowed_methods"`
		Certs             aserto.TLSConfig `json:"certs"`
		HTTP              bool             `json:"http"`
		ReadTimeout       time.Duration    `json:"read_timeout"`
		ReadHeaderTimeout time.Duration    `json:"read_header_timeout"`
		WriteTimeout      time.Duration    `json:"write_timeout"`
		IdleTimeout       time.Duration    `json:"idle_timeout"`
	} `json:"gateway"`
}

type GRPCOptions

type GRPCOptions struct {
	ServerOptions []grpc.ServerOption
	Registrations GRPCRegistrations
}

type GRPCRegistrations

type GRPCRegistrations func(server *grpc.Server)

type Gateway

type Gateway struct {
	Server *http.Server
	Mux    *http.ServeMux
	Certs  *aserto.TLSConfig
}

func (*Gateway) AddHandler

func (g *Gateway) AddHandler(pattern string, handler http.HandlerFunc)

type GatewayOptions

type GatewayOptions struct {
	HandlerRegistrations HandlerRegistrations
	ErrorHandler         runtime.ErrorHandlerFunc
}

type HandlerRegistrations

type HandlerRegistrations func(ctx context.Context, mux *runtime.ServeMux, grpcEndpoint string, opts []grpc.DialOption) error

type Health

type Health struct {
	Server     *health.Server
	GRPCServer *grpc.Server
	Address    string
}

func (*Health) SetServiceStatus

func (h *Health) SetServiceStatus(service string, status healthpb.HealthCheckResponse_ServingStatus)

type Service

type Service struct {
	Config   *API
	Server   *grpc.Server
	Listener net.Listener
	Gateway  *Gateway
	Started  chan bool
	Cleanup  []func()
}

type ServiceFactory

type ServiceFactory struct{}

func NewServiceFactory

func NewServiceFactory() *ServiceFactory

func (*ServiceFactory) CreateService

func (f *ServiceFactory) CreateService(
	config *API,
	grpcOpts *GRPCOptions,
	gatewayOpts *GatewayOptions,
	cleanup ...func(),
) (*Service, error)

type ServiceInterface

type ServiceInterface interface {
	Start(context.Context) error
	Stop(context.Context) error
}

type ServiceManager

type ServiceManager struct {
	Context context.Context

	Servers       map[string]*Service
	DependencyMap map[string][]string
	HealthServer  *Health
	MetricServer  *http.Server
	// contains filtered or unexported fields
}

func NewServiceManager

func NewServiceManager(logger *zerolog.Logger) *ServiceManager

func (*ServiceManager) AddGRPCServer

func (s *ServiceManager) AddGRPCServer(server *Service) error

func (*ServiceManager) SetupHealthServer

func (s *ServiceManager) SetupHealthServer(address string, certCfg *aserto.TLSConfig) error

func (*ServiceManager) SetupMetricsServer

func (s *ServiceManager) SetupMetricsServer(address string, certCfg *aserto.TLSConfig, enableZpages bool) ([]grpc.ServerOption,
	error,
)

func (*ServiceManager) StartServers

func (s *ServiceManager) StartServers(ctx context.Context) error

func (*ServiceManager) StopServers

func (s *ServiceManager) StopServers(ctx context.Context)

func (*ServiceManager) WithShutdownTimeout

func (s *ServiceManager) WithShutdownTimeout(seconds int) *ServiceManager

Jump to

Keyboard shortcuts

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