http

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

View Source
const Kind = service.HTTP

Variables

This section is empty.

Functions

func WriteJSONBody

func WriteJSONBody(b *bytes.Buffer, body any, status int, altError string, w http.ResponseWriter)

Types

type Container

type Container struct {
	service.HTTPConn
	Svc  *Service
	Name string
}

func (*Container) Addr

func (c *Container) Addr() string

func (*Container) AddrOrPanic

func (c *Container) AddrOrPanic() string

func (*Container) NewHealthCheckClient

func (c *Container) NewHealthCheckClient() (service.HealthChecker, error)

type HealthCheckClient

type HealthCheckClient struct {
	ServerAddr string
	Builder    service.HTTPClientBuilder
}

func (*HealthCheckClient) CheckOk

func (c *HealthCheckClient) CheckOk(_ context.Context) error

func (*HealthCheckClient) Close

func (c *HealthCheckClient) Close() error

type HealthCheckFn

type HealthCheckFn = func(context.Context) (map[string]string, error)

type Option

type Option[T httpOptions] interface {
	Apply(T)
}

func WithAddr

func WithAddr(a string) Option[*ServiceOptions]

func WithContext

func WithContext(ctx context.Context) Option[*ServiceOptions]

func WithDisableOtel

func WithDisableOtel(otel bool) Option[*SidecarOptions]

func WithHealthCheckFn

func WithHealthCheckFn[T *SidecarOptions | *ServiceOptions](healthChkFn HealthCheckFn) Option[T]

func WithInitRoutesFn

func WithInitRoutesFn[T *SidecarOptions | *ServiceOptions](i initRoutesFn) Option[T]

Setters

func WithListener

func WithListener[T *SidecarOptions | *ServiceOptions](listener service.HTTPListener) Option[T]

func WithName

func WithName(n string) Option[*ServiceOptions]

func WithPProfAddr added in v0.6.3

func WithPProfAddr(addr *string) Option[*ServiceOptions]

func WithPrimaryService

func WithPrimaryService(svc *service.Base) Option[*SidecarOptions]

func WithProfilingEnabled

func WithProfilingEnabled(p bool) Option[*ServiceOptions]

func WithServiceStatusFn added in v0.6.0

func WithServiceStatusFn(f ServiceStatus) Option[*SidecarOptions]

func WithStackLevelOnError

func WithStackLevelOnError[T *SidecarOptions | *ServiceOptions](lvl StackLevel) Option[T]

type RecoveryFunc

type RecoveryFunc struct {
	StackLevel StackLevel
}

func (*RecoveryFunc) TryToRecover

func (s *RecoveryFunc) TryToRecover() mux.MiddlewareFunc

type Service

type Service struct {
	Listener service.HTTPListener
	// contains filtered or unexported fields
}

func New

func New(opts ...Option[*ServiceOptions]) (*Service, error)

func NewSidecar

func NewSidecar(opts ...Option[*SidecarOptions]) (*Service, error)

func (*Service) DoServe

func (s *Service) DoServe(listener net.Listener) error

func (*Service) HelthCheckClient

func (s *Service) HelthCheckClient(c service.HTTPClientBuilder) *HealthCheckClient

func (*Service) RunHealthCheck added in v0.6.0

func (s *Service) RunHealthCheck(ctx context.Context) (map[string]string, error)

func (*Service) Serve

func (s *Service) Serve() error

type ServiceOptions

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

type ServiceStatus added in v0.6.0

type ServiceStatus = func() (string, time.Time)

type SidecarOptions

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

type StackLevel

type StackLevel int
const (
	StackLevelSimple StackLevel = iota + 1
	StackLevelFullStack
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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