util

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HeaderID    = []byte("id:")
	HeaderData  = []byte("data:")
	HeaderEvent = []byte("event:")
	HeaderRetry = []byte("retry:")
)

Functions

func Backoff

func Backoff(rfn Retfn) error

func Bytes2str

func Bytes2str(b []byte) string

func GetBuf

func GetBuf() *bytes.Buffer

func GetEnvAny

func GetEnvAny(names ...string) string

func HasChineseChar

func HasChineseChar(str string) bool

func IsHttp20xCode

func IsHttp20xCode(num int) bool

func IsNewline

func IsNewline(r rune) bool

func ParseUrl

func ParseUrl(u string) (*url.URL, error)

func PutBuf

func PutBuf(b *bytes.Buffer)

func StartLoop

func StartLoop(r io.Reader) (chan *Event, chan error)

func Str2bytes

func Str2bytes(s string) []byte

func TimeBackoff

func TimeBackoff(rfn Retfn, maxtime time.Duration) error

maxtime is 0 will forever

func Validurl

func Validurl(u *url.URL) error

Types

type Event

type Event struct {
	ID      []byte
	Data    []byte
	Event   []byte
	Retry   []byte
	Comment []byte
}

Event holds all of the event source fields

type EventStreamReader

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

EventStreamReader scans an io.Reader looking for EventStream messages.

func NewEventStreamReader

func NewEventStreamReader(eventStream io.Reader, maxBufferSize int) *EventStreamReader

NewEventStreamReader creates an instance of EventStreamReader.

func (*EventStreamReader) ReadEvent

func (e *EventStreamReader) ReadEvent() ([]byte, error)

ReadEvent scans the EventStream for events.

type Retfn

type Retfn func() error

type RoundTripper

type RoundTripper struct {
	Client tlsclient.HttpClient
}

func NewRoundTripper

func NewRoundTripper(httpClientOption ...tlsclient.HttpClientOption) (*RoundTripper, error)

func (RoundTripper) RoundTrip

func (s RoundTripper) RoundTrip(hReq *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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