Documentation ¶
Index ¶
- Constants
- Variables
- func CloseFile(err error, f io.Closer) error
- func DecodeChannels(data []byte) ([]string, error)
- func EnsureBufBigEnough(buf []byte, needed int) []byte
- func FriendlyBytes(bytes int64) string
- func IsChannelNameLiteral(channel string) bool
- func IsChannelNameValid(channel string, wildcardsAllowed bool) bool
- func ReadInt(r io.Reader) (int, error)
- func SendChannelsList(channels []string, sendInbox, replyInbox string, nc *nats.Conn, ...) error
- func WriteInt(w io.Writer, v int) error
- type BackoffTimeCheck
- type LockFile
- type Sublist
- func (s *Sublist) CacheCount() int
- func (s *Sublist) Count() uint32
- func (s *Sublist) Insert(subject string, element interface{}) error
- func (s *Sublist) Match(subject string) []interface{}
- func (s *Sublist) NumLevels() int
- func (s *Sublist) Remove(subject string, element interface{}) error
- func (s *Sublist) Subjects() []string
Constants ¶
const RaceEnabled = false
RaceEnabled indicates that program/tests are running with race detection enabled or not. Some tests may chose to skip execution when race detection is on.
Variables ¶
var ( ErrInvalidSubject = errors.New("sublist: invalid subject") ErrNotFound = errors.New("sublist: no match found") )
Sublist related errors
var ByteOrder binary.ByteOrder
ByteOrder specifies how to convert byte sequences into 16-, 32-, or 64-bit unsigned integers.
var ErrUnableToLockNow = errors.New("unable to acquire the lock at the moment")
ErrUnableToLockNow is used to indicate that a lock cannot be immediately acquired.
Functions ¶
func CloseFile ¶ added in v0.4.0
CloseFile closes the given file and report the possible error only if the given error `err` is not already set.
func DecodeChannels ¶ added in v0.9.0
DecodeChannels decodes from the given byte array the list of channel names and return them as an array of strings.
func EnsureBufBigEnough ¶
EnsureBufBigEnough checks that given buffer is big enough to hold 'needed' bytes, otherwise returns a buffer of a size of at least 'needed' bytes.
func FriendlyBytes ¶ added in v0.4.0
FriendlyBytes returns a string with the given bytes int64 represented as a size, such as 1KB, 10MB, etc...
func IsChannelNameLiteral ¶ added in v0.6.0
IsChannelNameLiteral returns true if the channel name is a literal (that is, it does not contain any wildcard). The channel name is assumed to be valid.
func IsChannelNameValid ¶ added in v0.6.0
IsChannelNameValid returns false if any of these conditions for the channel name apply: - is empty - contains the `/` character - token separator `.` is first or last - there are two consecutives token separators `.` if wildcardsAllowed is false: - contains wildcards `*` or `>` if wildcardsAllowed is true: - '*' or '>' are not a token in their own - `>` is not the last token
func SendChannelsList ¶ added in v0.9.0
func SendChannelsList(channels []string, sendInbox, replyInbox string, nc *nats.Conn, serverID string) error
SendChannelsList sends the list of channels to the given subject, possibly splitting the list in several requests if it cannot fit in a single message.
Types ¶
type BackoffTimeCheck ¶ added in v0.4.0
type BackoffTimeCheck struct {
// contains filtered or unexported fields
}
BackoffTimeCheck allows to execute some code, but not too often.
func NewBackoffTimeCheck ¶ added in v0.4.0
func NewBackoffTimeCheck(minFrequency time.Duration, factor int, maxFrequency time.Duration) (*BackoffTimeCheck, error)
NewBackoffTimeCheck creates an instance of BackoffTimeCheck. The `minFrequency` indicates how frequently BackoffTimeCheck.Ok() can return true. When Ok() returns true, the allowed frequency is multiplied by `factor`. The resulting frequency is capped by `maxFrequency`.
func (*BackoffTimeCheck) Ok ¶ added in v0.4.0
func (bp *BackoffTimeCheck) Ok() bool
Ok returns true for the first time it is invoked after creation of the object or call to Reset(), or after an amount of time (based on the last success and the allowed frequency) has elapsed. When at the maximum frequency, if this call is made after a delay at least equal to 3x the max frequency (or in other words, 2x after what was the target for the next print), then the object is auto-reset.
func (*BackoffTimeCheck) Reset ¶ added in v0.4.0
func (bp *BackoffTimeCheck) Reset()
Reset the state so that next call to BackoffPrint.Ok() will return true.
type LockFile ¶ added in v0.4.0
LockFile is an interface for lock files utility.
func CreateLockFile ¶ added in v0.4.0
CreateLockFile attempt to lock the given file, creating it if necessary. On success, the file is returned, otherwise an error is returned. The file returned should be closed to release the lock quicker than if left to the operating system.
type Sublist ¶ added in v0.5.0
A Sublist stores and efficiently retrieves subscriptions.
func (*Sublist) CacheCount ¶ added in v0.5.0
CacheCount returns the number of result sets in the cache.
func (*Sublist) Match ¶ added in v0.5.0
Match will match all entries to the literal subject. It will return a set of results.
func (*Sublist) NumLevels ¶ added in v0.5.0
NumLevels returns the maximum number of levels in the sublist.
func (*Sublist) Subjects ¶ added in v0.5.0
Subjects returns an array of all subjects in this sublist ordered from the widest to the narrowest of subjects. Order between non wildcard tokens in a given level is random though.
For instance, if the sublist contains (in any inserted order):
*.*, foo.>, *.>, foo.*.>, >, bar.>, foo.bar.>, bar.baz
the returned array will be one of the two possibilities:
>, *.>, *.*, foo.>, foo.*.>, foo.bar.>, bar.>, bar.baz
or
>, *.>, *.*, bar.>, bar.baz, foo.>, foo.*.>, foo.bar.>
For a given level, the order will still always be from wider to narrower, that is, foo.> comes before foo.*.> which comes before foo.bar.>, and bar.> always comes before bar.baz, but all the "bar" subjects may be before or after all the "foo" subjects.