Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearBackgroundContext ¶ added in v1.0.2
func ClearBackgroundContext(context BackgroundContext)
Clear Background Context, best used with a defer function after creating the new context.
func SetHealthCheckMaxAttemptOnBackgroundContext ¶ added in v1.0.3
func SetHealthCheckMaxAttemptOnBackgroundContext(context BackgroundContext, maxAttempt int)
Set Health Check Max Attempt on Background Context
func SetHealthCheckTimeOutOnBackgroundContext ¶ added in v1.0.3
func SetHealthCheckTimeOutOnBackgroundContext(context BackgroundContext, timeout time.Duration)
Set Health Check Time Out on Background Context
Types ¶
type BackgroundContext ¶
type BackgroundContext interface {
Set(key, value interface{})
Get(key interface{}) interface{}
// 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{}
}
Background Context
func NewBackgroundContext ¶
func NewBackgroundContext() BackgroundContext
Create new background context.
type Context ¶
type Context interface {
Title() string
SetTitle(title string)
Data(key interface{}) interface{}
SetData(key, value interface{})
// The fn function only gets called if there is a cache miss.
PersistData(key interface{}, fn func() interface{}) interface{}
Ctx() context.Context
Request() *http.Request
ResponseWriter() http.ResponseWriter
}
For storing anything related to user request
func GetContext ¶
Pulls out user context that was saved to the *http.Request.
func NewContext ¶
Create new context for user request, also saves context inside *http.Request without disturbing the context of the user request.
func NewContextByContext ¶ added in v1.0.6
Create new context by context.
Click to show internal directories.
Click to hide internal directories.