session

package
v0.25.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Error          = errors.New("session")
	ErrDestroyed   = fmt.Errorf("%w:destroyed", Error)
	ErrExitSuccess = fmt.Errorf("%w:exit(0)", Error)
)

Functions

func API

func API[API custom.API](sess *Context, addonSlug string) (api API, err error)

func AttachServiceInfo

func AttachServiceInfo(c *Context, svcinfo *service.Info) error

func ReadyEvent

func ReadyEvent() events.Event

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]custom.API
}

Config is a session builder used internally by the SDK to initialize a session.

func (*Config) Init

func (c *Config) Init() (*Context, error)

type Context

type Context struct {
	// contains filtered or unexported fields
}

func (*Context) CanRecover

func (c *Context) CanRecover(err error) bool

func (*Context) Deadline

func (c *Context) Deadline() (deadline time.Time, ok bool)

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) Describe

func (c *Context) Describe(key string) string

func (*Context) Destroy

func (c *Context) Destroy(err error)

func (*Context) Dispatch

func (c *Context) Dispatch(ev events.Event)

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 Cloesed instead.

func (*Context) Err

func (c *Context) Err() error

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) Get

func (c *Context) Get(key string) vars.Variable

func (*Context) Has

func (c *Context) Has(key string) bool

func (*Context) Log

func (c *Context) Log() logging.Logger

func (*Context) Opts

func (c *Context) Opts() *options.Options

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) ServiceInfo

func (c *Context) ServiceInfo(svcurl string) (*service.Info, error)

func (*Context) Settings

func (c *Context) Settings() *settings.Profile

Settings returns a map of all settings which are defined by application and are user configurable.

func (*Context) String

func (*Context) String() string

func (*Context) Time

func (s *Context) Time(t time.Time) time.Time

Time returns the time in the session's time location.

func (*Context) Valid

func (c *Context) Valid() bool

Valid returns true if the session is valid, false otherwise.

func (*Context) Value

func (c *Context) Value(key any) any

Value returns the value associated with this context for key, or nil

func (*Context) Wait

func (c *Context) Wait() <-chan struct{}

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.

type Register

type Register interface {
	Log() logging.Logger
	Settings() *settings.Profile
	Opts() *options.Options
	Time(t time.Time) time.Time
	Has(key string) bool
	Get(key string) vars.Variable
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL