Help us shape the future of Go! Take the 2026 Go Developer Survey

lifetime

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const TICK_10_ERROR = 2 * time.Millisecond
View Source
const TICK_10_ERROR_EXTEND = 1000 * time.Millisecond

For Lambdas with 1vCPU(1792M) and above.

View Source
const TICK_1_ERROR = 10 * time.Millisecond
View Source
const TICK_1_ERROR_EXTEND = 10000 * time.Millisecond

For Lambdas below 0.5vCPU(896M).

View Source
const TICK_5_ERROR = 10 * time.Millisecond
View Source
const TICK_5_ERROR_EXTEND = 1000 * time.Millisecond

For Lambdas with 0.5vCPU(896M) and above.

View Source
const TICK_EXTENSION = 100 * time.Millisecond

Variables

View Source
var (
	TICK              = 100 * time.Millisecond
	TICK_ERROR_EXTEND = TICK_10_ERROR_EXTEND
	TICK_ERROR        = TICK_10_ERROR

	ErrTimeout      = errors.New("timeout")
	MemoryLimitInMB = 3096
)
View Source
var (
	// If immortal, the function will not be reset anytime.
	Immortal = true
)

Functions

func ClearSession

func ClearSession()

func Init

func Init()

Set public to allow reconfiguration.

func TimeoutAfter

func TimeoutAfter(f func(), timeout time.Duration) error

func TimeoutAfterWithReturn

func TimeoutAfterWithReturn(f func() (interface{}, error), timeout time.Duration) (rsp interface{}, err error)

Types

type Lifetime

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

Lifetime defines how long a function can survive. It ticks across invocations.

func New

func New(expected time.Duration) *Lifetime

func (*Lifetime) Id

func (l *Lifetime) Id() int64

func (*Lifetime) IsTimeUp

func (l *Lifetime) IsTimeUp() bool

Is it the time for function to dead.

func (*Lifetime) Reborn

func (l *Lifetime) Reborn()

Reset function's identification.

func (*Lifetime) RebornIfDead

func (l *Lifetime) RebornIfDead()

Only reset function's identification if the function has been dead.

func (*Lifetime) Rest

func (l *Lifetime) Rest()

Set function as dead.

type Session

type Session struct {
	Sid        string // Id from proxy
	Id         string // Id from provider
	Input      *protocol.InputEvent
	Requests   int
	Setup      sync.WaitGroup // Used to wait for setup on invocation
	CleanUp    sync.WaitGroup // Used to wait for cleanup on ending invocation
	Migrator   *migrator.Client
	Timeout    *Timeout
	Connection net.Conn
	// contains filtered or unexported fields
}

func GetOrCreateSession

func GetOrCreateSession() *Session

func GetSession

func GetSession() *Session

func (*Session) Done

func (s *Session) Done()

func (*Session) DoneLocked

func (s *Session) DoneLocked()

func (*Session) IsDone

func (s *Session) IsDone() bool

func (*Session) IsMigrating

func (s *Session) IsMigrating() bool

func (*Session) Lock

func (s *Session) Lock()

func (*Session) Unlock

func (s *Session) Unlock()

func (*Session) WaitDone

func (s *Session) WaitDone() <-chan struct{}

type Timeout

type Timeout struct {
	Confirm func(*Timeout) bool
	// contains filtered or unexported fields
}

func NewTimeout

func NewTimeout(s *Session, d time.Duration) *Timeout

func (*Timeout) Busy

func (t *Timeout) Busy(reason string)

func (*Timeout) C

func (t *Timeout) C() <-chan time.Time

func (*Timeout) Disable

func (t *Timeout) Disable() bool

Disable timeout and returns false if timeout has been disabled already

func (*Timeout) DoneBusy

func (t *Timeout) DoneBusy(reason string)

func (*Timeout) DoneBusyWithReset

func (t *Timeout) DoneBusyWithReset(ext time.Duration, reason string)

func (*Timeout) Enable

func (t *Timeout) Enable() bool

Enable timeout and returns false if timeout has been enabled already

func (*Timeout) EndInterruption

func (t *Timeout) EndInterruption() time.Time

func (*Timeout) GetDue

func (t *Timeout) GetDue() time.Time

func (*Timeout) GetEstimateDue

func (t *Timeout) GetEstimateDue(ext time.Duration) time.Time

func (*Timeout) Halt

func (t *Timeout) Halt()

func (*Timeout) Interrupted

func (t *Timeout) Interrupted() time.Duration

func (*Timeout) IsBusy

func (t *Timeout) IsBusy() bool

func (*Timeout) IsDisabled

func (t *Timeout) IsDisabled() bool

func (*Timeout) Reset

func (t *Timeout) Reset() bool

func (*Timeout) ResetWithExtension

func (t *Timeout) ResetWithExtension(ext time.Duration, reason string) bool

func (*Timeout) Restart

func (t *Timeout) Restart(ext time.Duration)

func (*Timeout) SetLogger

func (t *Timeout) SetLogger(log logger.ILogger)

func (*Timeout) Since

func (t *Timeout) Since() time.Duration

func (*Timeout) Start

func (t *Timeout) Start() time.Time

func (*Timeout) StartWithCalibration

func (t *Timeout) StartWithCalibration(startAt time.Time) time.Time

func (*Timeout) StartWithDeadline

func (t *Timeout) StartWithDeadline(deadline time.Time) time.Time

func (*Timeout) Stop

func (t *Timeout) Stop()

Jump to

Keyboard shortcuts

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