util

package
v0.1.35 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const MaxHeaderBytes = 8192
View Source
const MaxReadHeaderTimeout = time.Second * 30
View Source
const MaxReadTimeout = time.Minute * 10

Variables

View Source
var CloseExceeded error = closeExceededError{}
View Source
var ErrTooLarge = errors.New("sliceQueue: too large")
View Source
var TimestampFormat = "2006-01-02 15:04:05"

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 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 Go added in v0.1.14

func Go(handle func())

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

func RecoverGo added in v0.1.13

func RecoverGo(handle func())

Types

type CancelContext added in v0.1.35

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

func NewCancelContext added in v0.1.35

func NewCancelContext() *CancelContext

func (*CancelContext) Cancel added in v0.1.35

func (c *CancelContext) Cancel()

func (*CancelContext) Close added in v0.1.35

func (c *CancelContext) Close()

func (*CancelContext) Err added in v0.1.35

func (c *CancelContext) Err() error

func (*CancelContext) Wait added in v0.1.35

func (c *CancelContext) Wait()

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 NewQueue

func NewQueue() *Queue

func (*Queue) Dequeue

func (queue *Queue) Dequeue(ctx context.Context) (value interface{}, hasClose bool)

func (*Queue) DequeueWithCanceled added in v0.1.35

func (queue *Queue) DequeueWithCanceled(ctx *CancelContext) (value interface{}, hasClose bool)

func (*Queue) Offer

func (queue *Queue) Offer(value interface{}) error

func (*Queue) Poll

func (queue *Queue) Poll() (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]) 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

Jump to

Keyboard shortcuts

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