Documentation ¶
Index ¶
- Variables
- func IsTTY() bool
- func Keys[T any](val map[string]T) []string
- func NextRetry(step int) time.Duration
- func OpenFileLimit() (limitStr string)
- func ToJSON[T any](val T) []byte
- type GoPool
- type GracefulSignals
- type MessageVerifier
- func (m *MessageVerifier) Generate(payload interface{}) (string, error)
- func (m *MessageVerifier) Sign(payload []byte) ([]byte, error)
- func (m *MessageVerifier) Validate(msg string) error
- func (m *MessageVerifier) Verified(msg string) (interface{}, error)
- func (m *MessageVerifier) VerifySignature(payload []byte, digest []byte) bool
- type PriorityQueue
- func (pq PriorityQueue[T, P]) Len() int
- func (pq PriorityQueue[T, P]) Less(i, j int) bool
- func (pq *PriorityQueue[T, P]) Peek() *PriorityQueueItem[T, P]
- func (pq *PriorityQueue[T, P]) Pop() any
- func (pq *PriorityQueue[T, P]) PopItem() *PriorityQueueItem[T, P]
- func (pq *PriorityQueue[T, P]) Push(x any)
- func (pq *PriorityQueue[T, P]) PushItem(v T, priority P) *PriorityQueueItem[T, P]
- func (pq *PriorityQueue[T, P]) Remove(item *PriorityQueueItem[T, P])
- func (pq PriorityQueue[T, P]) Swap(i, j int)
- func (pq *PriorityQueue[T, P]) Update(item *PriorityQueueItem[T, P], priority P)
- type PriorityQueueItem
Constants ¶
This section is empty.
Variables ¶
var ErrScheduleTimeout = fmt.Errorf("schedule error: timed out")
ErrScheduleTimeout returned by Pool to indicate that there no free goroutines during some period of time.
Functions ¶
func NextRetry ¶ added in v1.4.7
NextRetry returns a cooldown duration before next attempt using a simple exponential backoff
func OpenFileLimit ¶ added in v0.6.3
func OpenFileLimit() (limitStr string)
OpenFileLimit returns a string displaying the current open file limit for the process or unknown if it's not possible to detect it
Types ¶
type GoPool ¶ added in v1.1.0
type GoPool struct {
// contains filtered or unexported fields
}
GoPool contains logic of goroutine reuse. Copied from https://github.com/gobwas/ws-examples/blob/master/src/gopool/pool.go
func NewGoPool ¶ added in v1.1.0
NewGoPool creates new goroutine pool with given size. Start size defaults to 20% of the max size but not greater than 1024. Queue size defaults to 50% of the max size.
func (*GoPool) Schedule ¶ added in v1.1.0
func (p *GoPool) Schedule(task func())
Schedule schedules task to be executed over pool's workers.
func (*GoPool) ScheduleTimeout ¶ added in v1.1.0
ScheduleTimeout schedules task to be executed over pool's workers. It returns ErrScheduleTimeout when no free workers met during given timeout.
type GracefulSignals ¶ added in v1.4.2
type GracefulSignals struct {
// contains filtered or unexported fields
}
The struct implementing logic for graceful shutdown in response to OS signals.
func NewGracefulSignals ¶ added in v1.4.2
func NewGracefulSignals(timeout time.Duration) *GracefulSignals
Create new GracefulSignals struct.
func (*GracefulSignals) Handle ¶ added in v1.4.2
func (s *GracefulSignals) Handle(handler signalHandler)
func (*GracefulSignals) HandleForceTerminate ¶ added in v1.4.2
func (s *GracefulSignals) HandleForceTerminate(handler func())
func (*GracefulSignals) Listen ¶ added in v1.4.2
func (s *GracefulSignals) Listen()
type MessageVerifier ¶ added in v1.2.0
type MessageVerifier struct {
// contains filtered or unexported fields
}
func NewMessageVerifier ¶ added in v1.2.0
func NewMessageVerifier(key string) *MessageVerifier
func (*MessageVerifier) Generate ¶ added in v1.4.0
func (m *MessageVerifier) Generate(payload interface{}) (string, error)
func (*MessageVerifier) Sign ¶ added in v1.5.0
func (m *MessageVerifier) Sign(payload []byte) ([]byte, error)
func (*MessageVerifier) Validate ¶ added in v1.5.1
func (m *MessageVerifier) Validate(msg string) error
func (*MessageVerifier) Verified ¶ added in v1.2.0
func (m *MessageVerifier) Verified(msg string) (interface{}, error)
func (*MessageVerifier) VerifySignature ¶ added in v1.5.0
func (m *MessageVerifier) VerifySignature(payload []byte, digest []byte) bool
type PriorityQueue ¶ added in v1.4.0
type PriorityQueue[T any, P constraints.Ordered] []*PriorityQueueItem[T, P]
func NewPriorityQueue ¶ added in v1.4.0
func NewPriorityQueue[T any, P constraints.Ordered]() *PriorityQueue[T, P]
func (PriorityQueue[T, P]) Len ¶ added in v1.4.0
func (pq PriorityQueue[T, P]) Len() int
func (PriorityQueue[T, P]) Less ¶ added in v1.4.0
func (pq PriorityQueue[T, P]) Less(i, j int) bool
func (*PriorityQueue[T, P]) Peek ¶ added in v1.4.0
func (pq *PriorityQueue[T, P]) Peek() *PriorityQueueItem[T, P]
func (*PriorityQueue[T, P]) Pop ¶ added in v1.4.0
func (pq *PriorityQueue[T, P]) Pop() any
func (*PriorityQueue[T, P]) PopItem ¶ added in v1.4.0
func (pq *PriorityQueue[T, P]) PopItem() *PriorityQueueItem[T, P]
func (*PriorityQueue[T, P]) Push ¶ added in v1.4.0
func (pq *PriorityQueue[T, P]) Push(x any)
func (*PriorityQueue[T, P]) PushItem ¶ added in v1.4.0
func (pq *PriorityQueue[T, P]) PushItem(v T, priority P) *PriorityQueueItem[T, P]
func (*PriorityQueue[T, P]) Remove ¶ added in v1.4.0
func (pq *PriorityQueue[T, P]) Remove(item *PriorityQueueItem[T, P])
func (PriorityQueue[T, P]) Swap ¶ added in v1.4.0
func (pq PriorityQueue[T, P]) Swap(i, j int)
func (*PriorityQueue[T, P]) Update ¶ added in v1.4.0
func (pq *PriorityQueue[T, P]) Update(item *PriorityQueueItem[T, P], priority P)
Update modifies the priority and value of an Item in the queue.
type PriorityQueueItem ¶ added in v1.4.0
type PriorityQueueItem[T any, P constraints.Ordered] struct { // contains filtered or unexported fields }
An PriorityQueueItem is something we manage in a priority queue.
func (PriorityQueueItem[T, P]) Priority ¶ added in v1.4.0
func (pq PriorityQueueItem[T, P]) Priority() P
func (PriorityQueueItem[T, P]) Value ¶ added in v1.4.0
func (pq PriorityQueueItem[T, P]) Value() T