nilgo

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MIT Imports: 11 Imported by: 2

README ΒΆ

πŸƒ An opinionated minimalist Go application framework

Go Version Go Reference Build Coverage

Nilgo provides an out-of-the-box, cloud-native, production-ready, minimalist Go application framework with opinionated configuration, log, and telemetry for major Cloud providers.

Nilgo is Nilgai in brezhoneg. The nilgai (literally meaning "blue cow") is the largest Asian antelope and is ubiquitous across the northern Indian subcontinent.

Documentation ΒΆ

Overview ΒΆ

Package nilgo provides a simple way to bootstrap an production-ready application.

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

This section is empty.

Functions ΒΆ

This section is empty.

Types ΒΆ

type Option ΒΆ added in v0.2.0

type Option func(*options)

Option configures the Runner with specific options.

func WithLogger ΒΆ added in v0.2.0

func WithLogger(logger *slog.Logger) Option

WithLogger provides a slog.Logger to handle logs.

func WithMeterProvider ΒΆ added in v0.2.0

func WithMeterProvider(provider metric.MeterProvider) Option

WithMeterProvider provides OpenTelemetry metric provider.

func WithPostRun ΒΆ added in v0.2.0

func WithPostRun(runs ...func(context.Context) error) Option

WithPostRun provides runs to execute after the main runs provided in Runner.Run.

func WithPreRun ΒΆ added in v0.2.0

func WithPreRun(runs ...func(context.Context) error) Option

WithPreRun provides runs to execute before the main runs provided in Runner.Run.

It's guaranteed that all goroutines for pre-runs start before the main runs start, and end after the main runs end if it's blocking with context.Context.Done.

func WithStartGate ΒΆ added in v0.2.0

func WithStartGate(gates ...func(context.Context) error) Option

WithStartGate provides gates to block the start of main runs provided in Runner.Run, until all start gates returns without error.

All start gates must return in limited time to avoid blocking the main runs.

func WithStopGate ΒΆ added in v0.2.0

func WithStopGate(gates ...func(context.Context) error) Option

WithStopGate provides gates to block the stop of main runs provided in Runner.Run, until all stop gates returns.

All stop gates must return in limited time to avoid blocking the main runs.

func WithTraceProvider ΒΆ added in v0.2.0

func WithTraceProvider(provider trace.TracerProvider) Option

WithTraceProvider provides OpenTelemetry trace provider.

type Runner ΒΆ added in v0.2.0

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

Runner is a pre-configured runtime for executing runs in parallel.

To create an Runner, use New.

func New ΒΆ added in v0.2.0

func New(opts ...Option) Runner

New creates a new Runner with the given Option(s).

func (Runner) Run ΒΆ added in v0.2.0

func (r Runner) Run(ctx context.Context, runs ...func(context.Context) error) error

Run executes the given run in parallel with well-configured runtime, which includes logging, configuration, and telemetry.

The run running in parallel without any explicit order, which means it should not have temporal dependencies between each other.

The execution can be interrupted if any run returns non-nil error, or it receives an OS signal syscall.SIGINT or syscall.SIGTERM. It waits all run return unless it's forcefully terminated by OS.

The execution flow is as follows: 1. Starts all pre runs and start gates in parallel. 2. Waits for all pre runs start and start gates complete. 3. Starts all main runs. 4. Waits for OS interrupt or terminal signals or all main runs complete. 5. Waits for all stop gates complete. 6. Stop all main runs. 7. Waits for all post runs complete.

Directories ΒΆ

Path Synopsis
Package dev provides function useful for local development.
Package dev provides function useful for local development.
examples
grpc Module
http Module
gcp module
grpc module
http module
internal
otlp module

Jump to

Keyboard shortcuts

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