elephantine

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: MIT Imports: 20 Imported by: 11

README

Elephantine

Shared functionality for Elephant systems. It's most likely not something anyone outside of Elephant would be interested in.

Documentation

Index

Constants

View Source
const (
	LogKeyLogLevel     = "log_level"
	LogKeyError        = "err"
	LogKeyCountMetric  = "count_metric"
	LogKeyDocumentUUID = "document_uuid"
	LogKeyTransaction  = "transaction"
	LogKeyOCSource     = "oc_source"
	LogKeyOCVersion    = "oc_version"
	LogKeyOCEvent      = "oc_event"
	LogKeyChannel      = "channel"
	LogKeyMessage      = "message"
	LogKeyDelay        = "delay"
	LogKeyBucket       = "bucket"
	LogKeyObjectKey    = "object_key"
	LogKeyComponent    = "component"
	LogKeyCount        = "count"
	LogKeyEventID      = "event_id"
	LogKeyEventType    = "event_type"
	LogKeyJobLock      = "job_lock"
	LogKeyJobLockID    = "job_lock_id"
	LogKeyState        = "state"
	LogKeyIndex        = "index"
	LogKeyRoute        = "route"
	LogKeyService      = "service"
	LogKeyMethod       = "method"
)

Log attribute keys used throughout the application.

Variables

This section is empty.

Functions

func IsHTTPErrorWithStatus

func IsHTTPErrorWithStatus(err error, status int) bool

func ListenAndServeContext

func ListenAndServeContext(ctx context.Context, server *http.Server) error

func ResolveParameter

func ResolveParameter(
	c *cli.Context, src ParameterSource, name string,
) (string, error)

func SetUpLogger

func SetUpLogger(logLevel string, w io.Writer) *slog.Logger

SetUpLogger creates a default JSON logger and sets it as the global logger.

func UnmarshalFile

func UnmarshalFile(path string, o interface{}) error

func UnmarshalHTTPResource

func UnmarshalHTTPResource(resURL string, o interface{}) error

Types

type HTTPError

type HTTPError struct {
	Status     string
	StatusCode int
	Header     http.Header
	Body       io.Reader
}

func HTTPErrorFromResponse

func HTTPErrorFromResponse(res *http.Response) *HTTPError

func HTTPErrorf

func HTTPErrorf(statusCode int, format string, a ...any) *HTTPError

func NewHTTPError

func NewHTTPError(statusCode int, message string) *HTTPError

func (*HTTPError) Error

func (e *HTTPError) Error() string

type HealthServer

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

HealthServer exposes health endpoints, metrics, and PPROF endpoints.

func NewHealthServer

func NewHealthServer(addr string) *HealthServer

func (*HealthServer) AddReadyFunction

func (s *HealthServer) AddReadyFunction(name string, fn ReadyFunc)

func (*HealthServer) Close

func (s *HealthServer) Close() error

func (*HealthServer) ListenAndServe

func (s *HealthServer) ListenAndServe(ctx context.Context) error

type LazySSM

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

func NewLazySSM

func NewLazySSM() *LazySSM

func (*LazySSM) GetParameterValue

func (l *LazySSM) GetParameterValue(ctx context.Context, name string) (string, error)

type ParameterSource

type ParameterSource interface {
	GetParameterValue(ctx context.Context, name string) (string, error)
}

func GetParameterSource

func GetParameterSource(name string) (ParameterSource, error)

type ReadyFunc

type ReadyFunc func(ctx context.Context) error

type ReadyResult

type ReadyResult struct {
	Ok    bool   `json:"ok"`
	Error string `json:"error,omitempty"`
}

Directories

Path Synopsis
pg

Jump to

Keyboard shortcuts

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