Documentation
¶
Overview ¶
Package nilgo runs application on Cloud with pre-configured logger, config, telemetry, graceful shutdown, etc.
It's usually used in main() function to bootstrap the application like following code:
func main() { nilgo.Run( options_and_runners..., ) }
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
func Run(opts ...interface{})
Run runs app synchronously with provided options.
The runners passed in are running parallel without explicit order, which means it should not have temporal dependency between runners.
The running can be interrupted if any runner returns non-nil error, or it receives an os.Signal specified via WithSignals. It waits all runners return unless it's forcefully killed by os.
It panics on first non-nil error (if any) received. It does not recover panic, which causes running crashes if any panic happens without recovery in runner.
For now, it only can be one of the following types for opts:
- nilgo.Option
- log.Option
- config.Option
- otel.Option
- func(context.Context) error
Example ¶
package main import ( "context" "testing/fstest" "go.uber.org/zap" "github.com/ktong/nilgo" "github.com/ktong/nilgo/config" "github.com/ktong/nilgo/log" ) func main() { cfg := fstest.MapFS{ "config.yaml": { Data: []byte("app:\n user: cfg"), }, } nilgo.Run( config.WithFile("config.yaml"), config.WithFS(cfg), log.WithZapLogger(zap.NewExample()), func(ctx context.Context) error { var user string if err := config.Unmarshal("app.user", &user); err != nil { return err } log.FromContext(ctx).Info("example log", "user", user) return nil }, ) }
Output: {"level":"info","msg":"example log","user":"cfg"}
Types ¶
This section is empty.
Directories
¶
Path | Synopsis |
---|---|
Package config provides an application configuration system.
|
Package config provides an application configuration system. |
Package gcp provides customization for the application runtime environment on Google Cloud Platform.
|
Package gcp provides customization for the application runtime environment on Google Cloud Platform. |
Package grpc provides opinionated production-ready configured gRPC server.
|
Package grpc provides opinionated production-ready configured gRPC server. |
Package http provides opinionated production-ready configured HTTP server.
|
Package http provides opinionated production-ready configured HTTP server. |
Package log provides a minimalist logging API.
|
Package log provides a minimalist logging API. |
Package otel provides customization for OpenTelemetry.
|
Package otel provides customization for OpenTelemetry. |
Package run runs a group of functions finitely or infinitely.
|
Package run runs a group of functions finitely or infinitely. |
Package testing provides support for end-to-end functional tests.
|
Package testing provides support for end-to-end functional tests. |