Documentation
¶
Index ¶
- func BuildDefaultSlotChain() *base.SlotChain
- func Entry(resource string, opts ...EntryOption) (*base.SentinelEntry, *base.BlockError)
- func GlobalSlotChain() *base.SlotChain
- func Init(configPath string) error
- func InitDefault() error
- func SetSlotChain(chain *base.SlotChain)
- func TraceError(entry *base.SentinelEntry, err error)
- type EntryOption
- func WithAcquireCount(acquireCount uint32) EntryOption
- func WithArgs(args ...interface{}) EntryOption
- func WithAttachment(key interface{}, value interface{}) EntryOption
- func WithAttachments(data map[interface{}]interface{}) EntryOption
- func WithFlag(flag int32) EntryOption
- func WithResourceType(resourceType base.ResourceType) EntryOption
- func WithTrafficType(entryType base.TrafficType) EntryOption
- type EntryOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildDefaultSlotChain ¶
func Entry ¶
func Entry(resource string, opts ...EntryOption) (*base.SentinelEntry, *base.BlockError)
Entry is the basic API of Sentinel.
func GlobalSlotChain ¶
func Init ¶
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 ¶
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.