api

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2020 License: Apache-2.0 Imports: 10 Imported by: 183

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(entry *base.SentinelEntry, err error)

TraceError 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 WithAttachment added in v0.3.0

func WithAttachment(key interface{}, value interface{}) EntryOption

WithAttachment set the resource entry with the given k-v pair

func WithAttachments added in v0.3.0

func WithAttachments(data map[interface{}]interface{}) EntryOption

WithAttachment set the resource entry with the given k-v pairs

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.

Jump to

Keyboard shortcuts

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