Documentation
¶
Index ¶
Constants ¶
const (
// NITRIC_ENVIRONMENT is the environment variable key used to determine the current Nitric lifecycle
NITRIC_ENVIRONMENT = "NITRIC_ENVIRONMENT"
)
Variables ¶
This section is empty.
Functions ¶
func IsCollecting ¶
func IsCollecting() bool
IsCollecting checks if the current lifecycle is collecting application requirements (Build)
func IsInLifecycle ¶
func IsInLifecycle(stages ...LifecycleStage) bool
IsInLifecycle checks if the current environment is one of the provided stages
func IsRunning ¶
func IsRunning() bool
IsRunning checks if the current lifecycle is running the app (LocalRun or Cloud)
func WhenCollecting ¶
func WhenCollecting[T any](callback func() T) T
WhenCollecting executes the provided callback if the current environment is collecting requirements (Build)
func WhenInLifecycles ¶
func WhenInLifecycles[T any](stages []LifecycleStage, callback func() T) T
WhenInLifecycles executes the provided callback if the current environment is one of the provided stages
func WhenRunning ¶
func WhenRunning[T any](callback func() T) T
WhenRunning executes the provided callback if the current environment is running (LocalRun or Cloud)
Types ¶
type LifecycleStage ¶
type LifecycleStage string
LifecycleStage represents the different stages of Nitric execution
const ( // LocalRun represents local development run (using nitric run/start) LocalRun LifecycleStage = "run" // Build represents local development requirements building/collection (using nitric up) Build LifecycleStage = "build" // Cloud represents when the code is running in a deployed environment Cloud LifecycleStage = "cloud" )
func GetCurrentLifecycle ¶
func GetCurrentLifecycle() (LifecycleStage, error)
GetCurrentLifecycle returns the current lifecycle stage