util

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const MaxHeaderBytes = 8192
View Source
const MaxIdleTimeout = time.Minute * 3
View Source
const MaxReadHeaderTimeout = time.Second * 30
View Source
const MaxReadTimeout = time.Minute * 2

Variables

View Source
var ErrTooLarge = errors.New("sliceQueue: too large")
View Source
var TimestampFormat = "2006-01-02 15:04:05"
View Source
var TimestampFormat2 = "2006-01-02 15:04:05.000"

Functions

func ContainsArray added in v0.1.6

func ContainsArray(str string, targetStr ...string) bool

func ContainsInArray added in v0.1.1

func ContainsInArray(strArray []string, targetStr string) bool

func EqualsAnyIgnoreCase added in v0.1.27

func EqualsAnyIgnoreCase(s string, strs ...string) bool

func FormatTime

func FormatTime(tm *time.Time) string

func FormatTimeMillisecond added in v0.2.2

func FormatTimeMillisecond(tm *time.Time) string

func FreeQueue added in v0.1.34

func FreeQueue(queue *Queue)

func FreeSliceQueue added in v0.1.34

func FreeSliceQueue(sliceQueue *SliceQueue)

func GetGroupId

func GetGroupId(re *http.Request) string

func GetGroupIds

func GetGroupIds(re *http.Request) []string

func GetLiveTime

func GetLiveTime(re *http.Request) int

func GetMessage

func GetMessage(re *http.Request) string

func GetSize

func GetSize(re *http.Request) int

func GetStart

func GetStart(re *http.Request) int

func GetUsername

func GetUsername(re *http.Request) string

func HttpCross

func HttpCross(w http.ResponseWriter)

func HttpCrossChunked

func HttpCrossChunked(w http.ResponseWriter)

func Millisecond

func Millisecond() uint32

func NewPtr

func NewPtr(v interface{}) interface{}

func NewWaitNumGroup added in v0.1.10

func NewWaitNumGroup() *waitNumGroup

Types

type Handle added in v0.2.5

type Handle func(value ...any)

type HttpServer

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

func NewServer

func NewServer() *HttpServer

func (*HttpServer) AddRoute

func (hs *HttpServer) AddRoute(pattern string, handler func(http.ResponseWriter, *http.Request))

func (*HttpServer) IsTls

func (hs *HttpServer) IsTls() bool

func (*HttpServer) Start

func (hs *HttpServer) Start(port int) error

func (*HttpServer) StartAutoTLS

func (hs *HttpServer) StartAutoTLS(port int, certFile, keyFile string) error

func (*HttpServer) StartTLS

func (hs *HttpServer) StartTLS(port int, certFile, keyFile string) error

type Queue

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

func GetQueue added in v0.1.34

func GetQueue() *Queue

func (*Queue) Dequeue

func (queue *Queue) Dequeue() (value any, hasValue bool)

func (*Queue) DequeueTimer added in v0.1.37

func (queue *Queue) DequeueTimer(timer *Timer) (value any, hasValue bool)

func (*Queue) Offer

func (queue *Queue) Offer(value any) error

type Queue2 added in v0.2.12

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

func NewQueue

func NewQueue() *Queue2

func (*Queue2) DequeueTimer added in v0.2.12

func (queue *Queue2) DequeueTimer(timer *Timer) (value interface{}, hasValue bool)

func (*Queue2) Offer added in v0.2.12

func (queue *Queue2) Offer(value interface{})

type Request

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

func NewRequest

func NewRequest() *Request

func (*Request) Call

func (r *Request) Call(link string, jsonData []byte) ([]byte, error)

func (*Request) CallBreak added in v0.1.3

func (r *Request) CallBreak(link string, jsonData []byte) ([]byte, error)

func (*Request) Get

func (r *Request) Get(link string) ([]byte, error)

func (*Request) JustCall

func (r *Request) JustCall(link string, jsonData []byte) error

type RetryTransport

type RetryTransport struct {
	Transport http.RoundTripper
	Retries   int
}

func (*RetryTransport) RoundTrip

func (r *RetryTransport) RoundTrip(req *http.Request) (*http.Response, error)

type SliceMap added in v0.1.34

type SliceMap[V any] struct {
	// contains filtered or unexported fields
}

func (*SliceMap[V]) Delete added in v0.1.34

func (b *SliceMap[V]) Delete(key string)

func (*SliceMap[V]) Each added in v0.1.34

func (b *SliceMap[V]) Each(f func(string, V))

func (*SliceMap[V]) EachIndex added in v0.1.35

func (b *SliceMap[V]) EachIndex(f func(int, string, V))

func (*SliceMap[V]) Empty added in v0.3.4

func (b *SliceMap[V]) Empty() bool

func (*SliceMap[V]) Get added in v0.1.34

func (b *SliceMap[V]) Get(key string) (V, bool)

func (*SliceMap[V]) Len added in v0.1.34

func (b *SliceMap[V]) Len() int

func (*SliceMap[V]) Put added in v0.1.34

func (b *SliceMap[V]) Put(key string, value V) error

func (*SliceMap[V]) PutOrReplace added in v0.1.35

func (b *SliceMap[V]) PutOrReplace(key string, value V) error

func (*SliceMap[V]) Read added in v0.1.34

func (b *SliceMap[V]) Read() (any, error)

func (*SliceMap[V]) Reset added in v0.1.34

func (b *SliceMap[V]) Reset()

type SliceQueue added in v0.1.34

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

func GetSliceQueue added in v0.1.34

func GetSliceQueue() *SliceQueue

func (*SliceQueue) Len added in v0.1.34

func (b *SliceQueue) Len() int

func (*SliceQueue) Read added in v0.1.34

func (b *SliceQueue) Read() (any, error)

func (*SliceQueue) Reset added in v0.1.34

func (b *SliceQueue) Reset()

func (*SliceQueue) Write added in v0.1.34

func (b *SliceQueue) Write(c any) error

type SliceQueueSafe added in v0.4.1

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

func NewSliceQueueSafe added in v0.4.1

func NewSliceQueueSafe() *SliceQueueSafe

func (*SliceQueueSafe) Read added in v0.4.1

func (sqs *SliceQueueSafe) Read() (any, error)

func (*SliceQueueSafe) Reset added in v0.4.1

func (sqs *SliceQueueSafe) Reset()

func (*SliceQueueSafe) Write added in v0.4.1

func (sqs *SliceQueueSafe) Write(c any) error

type TimeWheel added in v0.1.42

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

TimeWheel 单圈时间轮,只用于特定场景 ,timer 最大时间不能超过 tick*bucketsNum

func NewTimeWheel added in v0.1.42

func NewTimeWheel(tickSeconds int32, bucketsNum int32) *TimeWheel

NewTimeWheel TimeWheel 单圈时间轮,只用于特定场景 ,timer 最大时间不能超过 tick*bucketsNum

func (*TimeWheel) GetLog added in v0.2.2

func (tw *TimeWheel) GetLog() []*TimeWheelLog

func (*TimeWheel) NewTimer added in v0.1.42

func (tw *TimeWheel) NewTimer(tickSeconds int32) *Timer

func (*TimeWheel) Start added in v0.2.5

func (tw *TimeWheel) Start()

func (*TimeWheel) Stop added in v0.1.42

func (tw *TimeWheel) Stop()

type TimeWheel2 added in v0.2.5

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

func NewTimeWheel2 added in v0.2.5

func NewTimeWheel2(tickSeconds int32, bucketsNum int32) *TimeWheel2

func (*TimeWheel2) AfterFunc added in v0.2.5

func (tw *TimeWheel2) AfterFunc(tickSeconds int32, id string, f Handle, value ...any) int32

func (*TimeWheel2) DeleteFunc added in v0.2.5

func (tw *TimeWheel2) DeleteFunc(id string)

func (*TimeWheel2) DeleteIndexFunc added in v0.2.13

func (tw *TimeWheel2) DeleteIndexFunc(id string, index int32)

func (*TimeWheel2) Start added in v0.2.5

func (tw *TimeWheel2) Start()

func (*TimeWheel2) Stop added in v0.2.5

func (tw *TimeWheel2) Stop()

type TimeWheelLog added in v0.2.2

type TimeWheelLog struct {
	Num       int
	StartTime *time.Time
	EndTime   *time.Time
}

type Timer added in v0.1.42

type Timer struct {
	C <-chan bool
	// contains filtered or unexported fields
}

func (*Timer) Close added in v0.1.42

func (t *Timer) Close()

Jump to

Keyboard shortcuts

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