app

package
v0.0.0-...-8c16a7d Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EnvProd represents Prod env
	EnvProd = Environment("production")
	// EnvStaging represents Staging environment
	EnvStaging = Environment("staging")
	// EnvDev represents Development environment
	EnvDev = Environment("development")
)

Variables

This section is empty.

Functions

func CloneNewContext

func CloneNewContext(ctx context.Context) context.Context

CloneNewContext returns a new context void of the signals of the given context but inclusive of Config, trace.Span, Zap and Attrs

func ContextWithAttributes

func ContextWithAttributes(ctx context.Context, attrs ...attribute.KeyValue) context.Context

ContextWithAttributes adds the given attributes to the context and the span in the context (if any)

func Init

func Init() (ctx context.Context, shutdown func(), err error)

Init initializes the app and returns

func RecordDebugEvent

func RecordDebugEvent(ctx context.Context, msg string, attrs ...attribute.KeyValue)

RecordDebugEvent records a debug event in both the logs and OTEL span

func RecordError

func RecordError(ctx context.Context, err error, attrs ...attribute.KeyValue)

RecordError records an error in both the logs and OTEL span

func RecordInfoEvent

func RecordInfoEvent(ctx context.Context, msg string, attrs ...attribute.KeyValue)

RecordInfoEvent records an info event in both the logs and OTEL span

func RecordWarnEvent

func RecordWarnEvent(ctx context.Context, msg string, attrs ...attribute.KeyValue)

RecordWarnEvent records a warning event in both the logs and OTEL span

func Run

func Run(ctx context.Context, services ...service)

Run runs the various services and listens to exit signals to terminate all the services.

func StartSpan

func StartSpan(
	ctx context.Context,
	name string,
	async bool,
	attrs ...attribute.KeyValue,
) (newCtx context.Context, end func(error))

StartSpan starts a new span and returns the context with the span and the end func If a span already exists inside the given ctx, the new span is created as a child of the parent span. If async is set to true, then the newCtx is separated from the old ctx's signals. Intentionally didn't use an options pattern for async to force devs to pay attention to when to use sync/async.

Types

type Config

type Config struct {
	// Env is the environment in which the application is running
	Env Environment
	// contains filtered or unexported fields
}

Config holds the application config

func ConfigFromContext

func ConfigFromContext(ctx context.Context) Config

ConfigFromContext retrieves the Config from context if exists else return a new Config

type Environment

type Environment string

Environment denotes the environment where the app is running.

func (Environment) IsValid

func (e Environment) IsValid() error

IsValid checks if the environment is valid or not

func (Environment) String

func (e Environment) String() string

String returns the string representation of the environment

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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