Documentation
¶
Index ¶
- Variables
- func API[API api.Provider](sess *Context, api *API) error
- func APIBySlug[API api.Provider](sess *Context, apiSlug string) (api API, err error)
- func AttachServiceInfo(c *Context, svcinfo *service.Info) error
- func ReadyEvent() events.Event
- type Config
- type Context
- func (c *Context) AttachAPI(slug string, api api.Provider) error
- func (c *Context) CanRecover(err error) bool
- func (c *Context) Deadline() (deadline time.Time, ok bool)
- func (c *Context) Describe(key string) string
- func (c *Context) Destroy(err error)
- func (c *Context) Dispatch(ev events.Event)
- func (c *Context) Done() <-chan struct{}
- func (c *Context) Err() error
- func (c *Context) Get(key string) vars.Variable
- func (c *Context) Has(key string) bool
- func (c *Context) Log() logging.Logger
- func (c *Context) Opts() *options.Options
- func (c *Context) Ready() <-chan struct{}
- func (c *Context) Release()
- func (c *Context) ServiceInfo(svcaddr string) (*service.Info, error)
- func (c *Context) Settings() *settings.Profile
- func (*Context) String() string
- func (s *Context) Time(t time.Time) time.Time
- func (c *Context) Valid() bool
- func (c *Context) Value(key any) any
- func (c *Context) Wait(ctrlc bool) <-chan struct{}
- type Register
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ReadyEvent ¶
Types ¶
type Config ¶
type Config struct {
Logger logging.Logger
Profile *settings.Profile
Opts *options.Options
TimeLocation *time.Location
ReadyEvent events.Event
EventCh chan<- events.Event
APIs map[string]api.Provider
}
Config is a session builder used internally by the SDK to initialize a session.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func (*Context) CanRecover ¶
func (*Context) Deadline ¶
Deadline returns the time when work done on behalf of this context should be canceled. Deadline returns ok==false when no deadline is set. Successive calls to Deadline return the same results.
func (*Context) Done ¶
func (c *Context) Done() <-chan struct{}
Done enables you to hook into chan to know when application exits however DO NOT use that for graceful shutdown actions. Use Application.AddExitFunc or Wait instead.
func (*Context) Err ¶
Err returns session error if any or nil If Done is not yet closed, Err returns nil. If Done is closed, Err returns a non-nil error explaining why: Canceled if the context was canceled or DeadlineExceeded if the context's deadline passed. After Err returns a non-nil error, successive calls to Err return the same error.
func (*Context) Opts ¶
Opts returns a map of all options which are defined by application turing current session life cycle.
func (*Context) Ready ¶
func (c *Context) Ready() <-chan struct{}
Ready returns channel which blocks until session considers application to be ready. It is ensured that Ready closes before root or command Do function is called.
func (*Context) Release ¶ added in v0.101.0
func (c *Context) Release()
Release releases os.Interrupt and os.Kill signals. Caller becomes responsible of signals.
func (*Context) Settings ¶
Settings returns a map of all settings which are defined by application and are user configurable.
func (*Context) Wait ¶
Wait allows user to cancel application by pressing Ctrl+C or sending SIGINT or SIGTERM while application is running. By default this is not allowed. It returns a Done channel which blocks until application is closed by user or signal is reveived. Argument ctrlc=true will print to stdout "Press Ctrl+C to cancel"