Documentation
¶
Index ¶
- Constants
- func GetDestructorManager() *callstack.CallStack
- func RegisterDestructor(fn callstack.CallableFn)
- func SetShutdownTimeout(d time.Duration)
- func Shutdown(arg error)
- func ShutdownContext() context.Context
- type Container
- func (c *Container) AbortFatal(err error)
- func (c *Container) Exists(name string) bool
- func (c *Container) Get(name string) (interface{}, bool)
- func (c *Container) GetContext() context.Context
- func (c *Container) Register(name string, service interface{})
- func (c *Container) Run(mainFn ...RuntimeFn)
- func (c *Container) Terminate(err error)
- type RuntimeFn
Constants ¶
const DefaultShutdownTimeout = 5 * time.Second
DefaultShutdownTimeout is the default deadline of ShutdownContext, counted from the start of Shutdown
Variables ¶
This section is empty.
Functions ¶
func GetDestructorManager ¶
GetDestructorManager Retrieve callback manager; returns nil after Shutdown
func RegisterDestructor ¶
func RegisterDestructor(fn callstack.CallableFn)
RegisterDestructor Register a function to perform shutdown procedures Calling RegisterDestructor after (or during) Shutdown is a no-op
func SetShutdownTimeout ¶ added in v0.16.0
SetShutdownTimeout sets the deadline of ShutdownContext, counted from the start of Shutdown; a d of zero or less gives destructors an already expired context. Keep it below the grace period of whatever stops the process (docker stop: 10s), or later destructors are killed before they run. Shutdown does not enforce it: a destructor that does not use ShutdownContext is not interrupted
func Shutdown ¶
func Shutdown(arg error)
Shutdown Shuts down the whole application Only the first call runs the destructors; a call made while they are running returns immediately (or, with a non-nil arg, logs the fatal error and exits without waiting for them)
func ShutdownContext ¶ added in v0.16.0
ShutdownContext returns the context destructors pass to Shutdown/Stop calls, e.g. server.Shutdown(blueprint.ShutdownContext()); the application context cannot be used for this, as on a signal it is already cancelled when destructors run. Call it from a destructor: elsewhere it may be called before Shutdown has started. During Shutdown it has one deadline, the shutdown timeout counted from the start of Shutdown, shared by all destructors. Before Shutdown it returns context.Background(); after Shutdown, a cancelled context
Types ¶
type Container ¶
type Container struct {
Config config.ConfigProvider
Context context.Context
CancelCtx context.CancelFunc
// contains filtered or unexported fields
}
func NewContainer ¶
func NewContainer(config config.ConfigProvider) *Container
NewContainer create new container runtime with the specified config provider and a new application context
func (*Container) AbortFatal ¶
AbortFatal aborts execution in case of fatal error
func (*Container) GetContext ¶
GetContext helper function to retrieve context
func (*Container) Run ¶
Run runs application container mainFn is a collection of non-blocking functions; they will be executed in order. each one will receive the Container object as the parameter: Example:
container.Run(func(a interface{}) error {
app := a.(*Container)
app.AbortFatal(nil) // won't abort because arg is nil
return nil
})
the main loop will wait for an os signal on the 'monitor' channel or for the application context to be canceled; on signal, the application context is canceled first and the registered destructors are then executed via Shutdown(); in both cases the application is terminated by invoking Terminate()
Directories
¶
| Path | Synopsis |
|---|---|
|
crypt
|
|
|
Package dbx provides typed generic repositories on top of gohan, with a database/sql adapter and transaction helper.
|
Package dbx provides typed generic repositories on top of gohan, with a database/sql adapter and transaction helper. |
|
provider
|
|
|
clickhouse
module
|
|
|
etcd
module
|
|
|
franz
module
|
|
|
hmacprovider
module
|
|
|
htpasswd
module
|
|
|
httpserver
module
|
|
|
jwtprovider
module
|
|
|
kafka
module
|
|
|
metrics
module
|
|
|
mqtt
module
|
|
|
nats
module
|
|
|
pgsql
module
|
|
|
prometheus
module
|
|
|
redis
module
|
|
|
s3
module
|
|
|
smtp
module
|
|
|
sqlite
module
|
|
|
samples
|
|
|
application
command
|
|
|
ch-migrations
command
|
|
|
clickhouse
command
|
|
|
console
command
|
|
|
dbgrid
command
|
|
|
dbx-sqlite
command
Command dbx-sqlite is a runnable sample for the dbx package: it opens a SQLite database (no external service required), creates a users table, inserts two users through a dbx.Repository, counts them, fetches one by name with GetBy, and runs a Contains search.
|
Command dbx-sqlite is a runnable sample for the dbx package: it opens a SQLite database (no external service required), creates a users table, inserts two users through a dbx.Repository, counts them, fetches one by name with GetBy, and runs a Contains search. |
|
etcd
command
|
|
|
filelogging
command
|
|
|
franz
command
|
|
|
hmac-python-client/server
command
|
|
|
htpasswd
command
|
|
|
http-csrf
command
|
|
|
httpserver
command
|
|
|
httpserver-authtoken
command
|
|
|
httpserver-hmacprovider
command
|
|
|
httpserver-hmacprovider/server
command
|
|
|
httpserver-mtls/client
command
|
|
|
httpserver-mtls/server
command
|
|
|
httpserver-session
command
|
|
|
jwtprovider-example
command
|
|
|
jwtprovider-user-tracking
command
|
|
|
kafka
command
|
|
|
metrics
command
|
|
|
mqtt
command
|
|
|
nats
command
|
|
|
nextjs-api-demo
command
|
|
|
pgsql
command
|
|
|
pgsql_migrations
command
|
|
|
prometheus
command
|
|
|
s3-client
command
|
|
|
s3-objectlock
command
Command s3-objectlock demonstrates the S3 provider's Object Lock (WORM) features: bucket-level default retention, per-object retention (Governance/Compliance), governance bypass, and legal holds.
|
Command s3-objectlock demonstrates the S3 provider's Object Lock (WORM) features: bucket-level default retention, per-object retention (Governance/Compliance), governance bypass, and legal holds. |
|
session-example
command
|
|
|
sqlite
command
|
|
|
types
|
|
|
duration
Package duration provides a JSON-friendly duration type for configuration.
|
Package duration provides a JSON-friendly duration type for configuration. |
|
jsoncol
Package jsoncol provides JSON[T], a generic database column type that stores T as JSON text: PostgreSQL json/jsonb, or SQLite TEXT.
|
Package jsoncol provides JSON[T], a generic database column type that stores T as JSON text: PostgreSQL json/jsonb, or SQLite TEXT. |
|
optional
Package optional provides Optional[T], a tri-state value for PATCH-style request bodies, where "field absent", "field explicitly null" and "field set to a value" mean different things:
|
Package optional provides Optional[T], a tri-state value for PATCH-style request bodies, where "field absent", "field explicitly null" and "field set to a value" mean different things: |
|
threadsafe
* imported from https://github.com/hayageek/threadsafe * (c) Copyright (c) 2024 Ravishanker Kusuma - MIT License * See LICENSE for more details
|
* imported from https://github.com/hayageek/threadsafe * (c) Copyright (c) 2024 Ravishanker Kusuma - MIT License * See LICENSE for more details |