Documentation ¶
Overview ¶
Package copper encapsulates everything you need to build apps quickly
Index ¶
Constants ¶
This section is empty.
Variables ¶
WireModule can be used as part of google/wire setup to include the app's lifecycle, config, and logger.
Functions ¶
This section is empty.
Types ¶
type App ¶
App defines a Copper app container that can run provided code in its managed lifecycle. It provides functionality to read config in multiple environments as defined by command-line flags.
func NewApp ¶
NewApp creates a new Copper app and returns it along with the app's lifecycle manager, config, and the logger.
func (*App) Run ¶
Run runs the provided funcs. Once all of the functions complete their run, the lifecycle's stop funcs are also called. If any of the fns return an error, the app exits with an exit code 1. Run should be used when none of the fn are blocking. For blocking funcs like a long running server, use Start.
func (*App) Start ¶
Start runs the provided fns where the last provided fn be blocking like a long running server. The app listens on the OS's INT and TERM signals from the user to exit. Once the signal is received, the lifecycle's stop funcs are called. If any of the fns fail to run and returns an error, the app exits with exit code 1. If none of the fns are blocking, use Run instead.
type Flags ¶
Flags holds flag values passed in via command line. These can be used to configure the app environment and override the config directory.
type Lifecycle ¶
type Lifecycle struct {
// contains filtered or unexported fields
}
Lifecycle represents the lifecycle of an app. Most importantly, it allows various parts of the app to register stop funcs that are run before the app exits. Packages such as chttp use Lifecycle to gracefully stop the HTTP server before the app exits.
func NewLifecycle ¶
NewLifecycle instantiates and returns a new Lifecycle that can be used with New to create a Copper app.
Directories ¶
Path | Synopsis |
---|---|
Package copper provides the primitives to create a new app using github.com/uber-go/fx.
|
Package copper provides the primitives to create a new app using github.com/uber-go/fx. |
cerror
Package cerror provides a custom error type that can hold more context than the stdlib error package.
|
Package cerror provides a custom error type that can hold more context than the stdlib error package. |
chttp
Package chttp provides a fx module that can be used to create a http copper application.
|
Package chttp provides a fx module that can be used to create a http copper application. |
clogger
Package clogger provides an interface to log messages.
|
Package clogger provides an interface to log messages. |
crandom
Package crandom provides utility random functions to generate random numbers and strings.
|
Package crandom provides utility random functions to generate random numbers and strings. |
Package cauth provides the primitives and the service layer for authentication.
|
Package cauth provides the primitives and the service layer for authentication. |
cauthtest
Package cauthtest provides utilities to test cauth
|
Package cauthtest provides utilities to test cauth |
Package cconfig helps read app config easily with support for different environments
|
Package cconfig helps read app config easily with support for different environments |
cconfigtest
Package cconfigtest provides helper methods to test the cconfig package
|
Package cconfigtest provides helper methods to test the cconfig package |
Package cerrors provides a custom error type that can hold more context than the stdlib error package.
|
Package cerrors provides a custom error type that can hold more context than the stdlib error package. |
Package chttp helps setup a http server with routing, middlewares, and more.
|
Package chttp helps setup a http server with routing, middlewares, and more. |
chttptest
Package chttptest provides utility functions that are useful when testing chttp
|
Package chttptest provides utility functions that are useful when testing chttp |
Package clogger provides a Logger interface that can be used to log messages and errors
|
Package clogger provides a Logger interface that can be used to log messages and errors |
Package cmailer provides methods to easily send emails
|
Package cmailer provides methods to easily send emails |
Package crandom provides methods to generate random numbers and strings
|
Package crandom provides methods to generate random numbers and strings |
Package csql helps create and manage database connections
|
Package csql helps create and manage database connections |