rkmidtimeout

package
v2.2.22 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 7 Imported by: 8

Documentation

Overview

Package rkmidtimeout provide options

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BeforeCtx

type BeforeCtx struct {
	Input struct {
		UrlPath        string
		InitHandler    func()
		NextHandler    func()
		PanicHandler   func()
		FinishHandler  func()
		TimeoutHandler func()
		Event          rkquery.Event
	}
	Output struct {
		WaitFunc       func()
		TimeoutErrResp rkerror.ErrorInterface
	}
}

BeforeCtx context for Before() function

func NewBeforeCtx

func NewBeforeCtx() *BeforeCtx

NewBeforeCtx create new BeforeCtx with fields initialized

type BootConfig

type BootConfig struct {
	Enabled   bool     `yaml:"enabled" json:"enabled"`
	TimeoutMs int      `yaml:"timeoutMs" json:"timeoutMs"`
	Ignore    []string `yaml:"ignore" json:"ignore"`
	Paths     []struct {
		Path      string `yaml:"path" json:"path"`
		TimeoutMs int    `yaml:"timeoutMs" json:"timeoutMs"`
	} `yaml:"paths" json:"paths"`
}

BootConfig for YAML

type Option

type Option func(*optionSet)

Option options provided to Interceptor or optionsSet while creating

func ToOptions

func ToOptions(config *BootConfig, entryName, entryType string) []Option

ToOptions convert BootConfig into Option list

func WithEntryNameAndType

func WithEntryNameAndType(entryName, entryType string) Option

WithEntryNameAndType provide entry name and entry type.

func WithMockOptionSet

func WithMockOptionSet(mock OptionSetInterface) Option

WithMockOptionSet provide mock OptionSetInterface

func WithPathToIgnore

func WithPathToIgnore(paths ...string) Option

WithPathToIgnore provide paths prefix that will ignore.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout Provide global timeout and response handler. If response is nil, default globalResponse will be assigned

func WithTimeoutByPath

func WithTimeoutByPath(path string, timeout time.Duration) Option

WithTimeoutByPath Provide timeout and response handler by path. If response is nil, default globalResponse will be assigned

type OptionSetInterface

type OptionSetInterface interface {
	GetEntryName() string

	GetEntryType() string

	BeforeCtx(*http.Request, rkquery.Event) *BeforeCtx

	Before(*BeforeCtx)

	ShouldIgnore(string) bool
}

OptionSetInterface mainly for testing purpose

func NewOptionSet

func NewOptionSet(opts ...Option) OptionSetInterface

NewOptionSet Create new optionSet with options.

func NewOptionSetMock

func NewOptionSetMock(before *BeforeCtx) OptionSetInterface

NewOptionSetMock for testing purpose

Jump to

Keyboard shortcuts

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