infrabin

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2021 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName                    = "go-infrabin"
	DefaultHost                = "0.0.0.0"
	DefaultGRPCPort       uint = 50051
	DefaultHTTPServerPort uint = 8888
	DefaultAdminPort      uint = 8889
	DefaultPrometheusPort uint = 8887
	EnableProxyEndpoint        = false
	AWSMetadataEndpoint        = "http://169.254.169.254/latest/meta-data/"
	DrainTimeout               = 15 * time.Second
	MaxDelay                   = 120 * time.Second
	HttpWriteTimeout           = MaxDelay + time.Second
	HttpReadTimeout            = 60 * time.Second
	HttpIdleTimeout            = 15 * time.Second
	HttpReadHeaderTimeout      = 15 * time.Second
	DefaultConfigName          = "config"
	DefaultConfigType          = "yaml"
)

Variables

View Source
var (
	DefaultConfigPaths = [...]string{".", "./config", "./cmd/go-infrabin"}
)

Functions

func ReadConfiguration added in v1.3.0

func ReadConfiguration()

ReadConfiguration : Sets up a default configuration then overwrites any configured details from a config.yaml file in the local directory or under ./config

Types

type GRPCServer

type GRPCServer struct {
	Name            string
	Server          *grpc.Server
	InfrabinService InfrabinServer
	HealthService   *health.Server
}

Server wraps the gRPC server and implements infrabin.Infrabin

func NewGRPCServer

func NewGRPCServer() *GRPCServer

New creates a new rpc server.

func (*GRPCServer) ListenAndServe

func (s *GRPCServer) ListenAndServe(lis net.Listener)

ListenAndServe binds the server to the indicated interface:port. Pass lis as nil to be bound to the config port. lis can be passed for testing

func (*GRPCServer) Shutdown

func (s *GRPCServer) Shutdown()

type HTTPServer

type HTTPServer struct {
	Name   string
	Server *http.Server
}

func NewHTTPServer

func NewHTTPServer(name string, opts ...HTTPServerOption) *HTTPServer

func (*HTTPServer) ListenAndServe

func (s *HTTPServer) ListenAndServe()

func (*HTTPServer) Shutdown

func (s *HTTPServer) Shutdown()

type HTTPServerOption added in v1.3.0

type HTTPServerOption func(ctx context.Context, s *HTTPServer)

func RegisterHandler added in v1.3.0

func RegisterHandler(pattern string, handler http.Handler) HTTPServerOption

func RegisterHealth added in v1.3.0

func RegisterHealth(pattern string, healthService *health.Server) HTTPServerOption

func RegisterInfrabin added in v1.3.0

func RegisterInfrabin(pattern string, infrabinService InfrabinServer) HTTPServerOption

type InfrabinService

type InfrabinService struct {
	UnimplementedInfrabinServer
}

Must embed UnimplementedInfrabinServer for `protogen-gen-go-grpc`

func (*InfrabinService) AWS added in v1.1.0

func (s *InfrabinService) AWS(ctx context.Context, request *AWSRequest) (*structpb.Struct, error)

func (*InfrabinService) Delay

func (s *InfrabinService) Delay(ctx context.Context, request *DelayRequest) (*Response, error)

func (*InfrabinService) Env

func (s *InfrabinService) Env(ctx context.Context, request *EnvRequest) (*Response, error)

func (*InfrabinService) Headers

func (s *InfrabinService) Headers(ctx context.Context, request *HeadersRequest) (*Response, error)

func (*InfrabinService) Proxy added in v1.1.0

func (s *InfrabinService) Proxy(ctx context.Context, request *ProxyRequest) (*structpb.Struct, error)

func (*InfrabinService) Root

func (s *InfrabinService) Root(ctx context.Context, _ *Empty) (*Response, error)

Jump to

Keyboard shortcuts

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