ctx

package module
v2.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: MIT Imports: 6 Imported by: 26

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearContext

func ClearContext(context Context)

Clear Background Context, best used with a defer function after creating the new context.

func GetGoContext deprecated

func GetGoContext(context Context) goContext.Context

Get Go Context

Deprecated: Use GoContext function instead. Will be removed in 3.0

func GoContext

func GoContext(context Context) goContext.Context

Get Go Context

func SetMaxAttempt deprecated

func SetMaxAttempt(context Context, maxAttempt int)

Set Health Check Max Attempt on Background Context

Deprecated: Use ContextSettings instead. Will be removed in 3.0

func SetTimeout deprecated

func SetTimeout(context Context, timeout time.Duration)

Set Health Check Time Out on Background Context

Deprecated: Use ContextSettings instead. Will be remove in 3.0

Types

type Context

type Context interface {
	// Set content to map, cannot use the same key value over and over again, otherwise it will panic.
	Set(key, value interface{})

	// Get content from map, return two values, the bool value indicated if it was found or not.
	Get(key interface{}) (interface{}, bool)

	// The fn function only gets called if there is a cache miss. Return error as nil to bypass health check.
	Persist(key interface{}, fn func() (interface{}, error)) interface{}
}

func NewBackgroundContext

func NewBackgroundContext() Context

New Background Context, default max attempt is 5 and timeout is 2 seconds

func NewContext

func NewContext(context goContext.Context) Context

New Context, default max attempt is 1 and timeout is 0

func NewContextWithMap

func NewContextWithMap(m map[interface{}]interface{}) Context

New Context with Map, default max attempt is 1 and timeout is 0

type Settings added in v2.0.6

type Settings struct {
	// Set Health Check Max Attempt on Background Context
	MaxAttempt int

	// Set Health Check Time Out on Background Context
	Timeout time.Duration
}

func ContextSettings added in v2.0.6

func ContextSettings(context Context) *Settings

Get Settings from Context

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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