impls

package module
v0.0.0-...-eb7cf90 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 21 Imported by: 1

Documentation

Index

Constants

View Source
const (
	BP_StatusReady   = 0
	BP_StatusRunning = 1
	BP_StatusClosed  = -1
)

Variables

This section is empty.

Functions

func Base64DecodeFilename

func Base64DecodeFilename(src string) ([]byte, error)

replace +/ with -_

func Base64DecodeMap

func Base64DecodeMap(str string) (data map[string]any, err error)

func Base64EncodeFilename

func Base64EncodeFilename(src string) string

replace +/ with -_

func Base64EncodeMap

func Base64EncodeMap(data map[string]any) string

func ExampleRequestTmpls

func ExampleRequestTmpls() string

func NTSFunc

func NTSFunc(delay int64) http.HandlerFunc

func SegnmentsDiv

func SegnmentsDiv(length, num int) (segs [][2]int)

func SortSliceOfSlice

func SortSliceOfSlice[T constraints.Ordered](slice [][]T)

demo:

[[1,2], [3]] => [[3], [1,2]]
[[2,1], [1,2]] => [[1,2], [2, 1]]

func ValidJSON

func ValidJSON(bts []byte) (err error)

Types

type BatchProcess

type BatchProcess[T any] struct {
	// contains filtered or unexported fields
}

func NewBatchProcess

func NewBatchProcess[T any](count int, duration time.Duration, process func([]T)) (
	bp *BatchProcess[T], err error)

func (*BatchProcess[T]) Down

func (bp *BatchProcess[T]) Down()

func (*BatchProcess[T]) Recv

func (bp *BatchProcess[T]) Recv(v T) (err error)

type Email

type Email struct {
	Recipients []string `mapstructure:"recipients"`
	Title      string   `mapstructure:"title"`
	Body       string   `mapstructure:"body"`
	Attachs    []string `mapstructure:"attachs"`
}

type NetworkTimeResult

type NetworkTimeResult struct {
	T1    time.Time `json:"t1"`
	T2    time.Time `json:"t2"`
	T3    time.Time `json:"t3"`
	T4    time.Time `json:"t4"`
	Sigma int64     `json:"sigma"`
	Delta int64     `json:"delta"`
}

func GetNetworkTime

func GetNetworkTime(addr string, delay int64) (result *NetworkTimeResult, err error)

func (NetworkTimeResult) String

func (result NetworkTimeResult) String() string

type NetworkTimeServer

type NetworkTimeServer struct {
	*http.Server
	// contains filtered or unexported fields
}

https://en.wikipedia.org/wiki/Network_Time_Protocol https://en.wikipedia.org/wiki/File:NTP-Algorithm.svg

func NewNetworkTimeServer

func NewNetworkTimeServer(addr string, delay int64) (ser *NetworkTimeServer, err error)

func (*NetworkTimeServer) Run

func (ser *NetworkTimeServer) Run() error

type Output

type Output struct {
	Key    string `mapstructure:"key"`    // key in json
	Header string `mapstructure:"header"` // header key
	Tmpl   string `mapstructure:"tmpl"`   // header value template
}

func (*Output) Get

func (output *Output) Get(bts []byte) (value string, err error)

type Parallel

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

func NewParallel

func NewParallel(n int) (p *Parallel)

func (*Parallel) Do

func (p *Parallel) Do(fn func())

func (p *Parallel) Do(fn func() error, handle func(error)) {

func (*Parallel) Wait

func (p *Parallel) Wait()

type RequestTmpl

type RequestTmpl struct {
	Name            string            `mapstructure:"name"`
	Method          string            `mapstructure:"method"`
	Path            string            `mapstructure:"path"`
	Params          string            `mapstructure:"params"`
	Body            string            `mapstructure:"body"`
	NoPublicHeaders bool              `mapstructure:"no_public_headers"`
	Headers         map[string]string `mapstructure:"headers"`
	Outputs         []Output          `mapstructure:"outputs"`
}

type RequestTmpls

type RequestTmpls struct {
	Url     string            `mapstructure:"url"`
	Headers map[string]string `mapstructure:"headers"`
	Prelude []RequestTmpl     `mapstructure:"prelude"`
	APIs    []RequestTmpl     `mapstructure:"apis"`
	// contains filtered or unexported fields
}

func LoadRequestTmpls

func LoadRequestTmpls(name, fp string) (item *RequestTmpls, err error)

func (*RequestTmpls) Match

func (item *RequestTmpls) Match(names ...string) (tmpls []*RequestTmpl, err error)

func (*RequestTmpls) Request

func (item *RequestTmpls) Request(tmpl *RequestTmpl) (
	statusCode int, body string, err error)

type Sender

type Sender struct {
	SMTPAddr string `mapstructure:"smtp_addr"`
	SMTPPort int    `mapstructure:"smtp_port"`
	Address  string `mapstructure:"address"`
	Password string `mapstructure:"password"`
}

func NewSender

func NewSender(fp, field string) (sender *Sender, err error)

func (*Sender) Send

func (sender *Sender) Send(email *Email) (err error)

type SigningMd5

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

func NewSigningMd5

func NewSigningMd5(secrete, key string, lowcase bool) (*SigningMd5, error)

func (*SigningMd5) SignQuery

func (sign *SigningMd5) SignQuery(param map[string]string) (query string)

func (*SigningMd5) SignValues

func (sign *SigningMd5) SignValues(param map[string]string) (value string)

func (*SigningMd5) VerifyQuery

func (sign *SigningMd5) VerifyQuery(query string) (err error)

Jump to

Keyboard shortcuts

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