api

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2020 License: Apache-2.0 Imports: 10 Imported by: 191

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildDefaultSlotChain

func BuildDefaultSlotChain() *base.SlotChain

func Entry

func Entry(resource string, opts ...EntryOption) (*base.SentinelEntry, *base.BlockError)

Entry is the basic API of Sentinel.

func GlobalSlotChain

func GlobalSlotChain() *base.SlotChain

func Init

func Init(configPath string) error

Init loads Sentinel general configuration from the given YAML file and initializes Sentinel.

func InitDefault

func InitDefault() error

InitDefault initializes Sentinel using the configuration from system environment and the default value.

func SetSlotChain

func SetSlotChain(chain *base.SlotChain)

SetSlotChain replaces current slot chain with the given one. Note that this operation is not thread-safe, so it should be called when pre-initializing Sentinel.

func TraceError

func TraceError(resource string, err error, opts ...TraceErrorOption)

TraceError records the provided error to the statistic structure of the target resource.

func TraceErrorToCtx

func TraceErrorToCtx(ctx *base.EntryContext, err error, opts ...TraceErrorOption)

TraceErrorToCtx records the provided error to the given context.

func TraceErrorToEntry

func TraceErrorToEntry(entry *base.SentinelEntry, err error, opts ...TraceErrorOption)

TraceErrorToEntry records the provided error to the given SentinelEntry.

Types

type EntryOption

type EntryOption func(*EntryOptions)

func WithAcquireCount

func WithAcquireCount(acquireCount uint32) EntryOption

WithAcquireCount sets the resource entry with the given batch count (by default 1).

func WithArgs

func WithArgs(args ...interface{}) EntryOption

WithArgs sets the resource entry with the given additional parameters.

func WithFlag

func WithFlag(flag int32) EntryOption

WithFlag sets the resource entry with the given additional flag.

func WithResourceType

func WithResourceType(resourceType base.ResourceType) EntryOption

WithResourceType sets the resource entry with the given resource type.

func WithTrafficType

func WithTrafficType(entryType base.TrafficType) EntryOption

WithTrafficType sets the resource entry with the given traffic type.

type EntryOptions

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

EntryOptions represents the options of a Sentinel resource entry.

type TraceErrorOption

type TraceErrorOption func(*TraceErrorOptions)

func WithCount

func WithCount(count uint64) TraceErrorOption

WithCount sets the error count.

type TraceErrorOptions

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

Jump to

Keyboard shortcuts

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