Documentation ¶
Index ¶
- func Abbreviate(s string) string
- func ArrayToMap[T any](m map[string]T, e []T, f func(T) string) map[string]T
- func BaseName(src string) string
- func Contains(a string, b string) bool
- func CopyDir(src, dst string) error
- func CopyFile(source, target string) error
- func Dir(path string) string
- func EachTicked[T any](ctx context.Context, items []T, fn func(T), dt time.Duration)
- func ExpandFiles(rootDir string, filter ExtFilter, inputs ...string) ([]string, error)
- func ExpandInputs(rootDir string, inputs ...string) ([]string, error)
- func Ext(file string) string
- func FallbackDir(name string, dirs ...string) (string, error)
- func FindDocuments(path string) ([]string, error)
- func GetDocumentType(path string) string
- func GetFreePort() (int, error)
- func HasExt(file string, exts ...string) bool
- func HttpPost(url string, contentType string, data []byte) error
- func HttpPostJson(url string, data interface{}) error
- func IsDir(elem string) bool
- func IsDocument(path string) bool
- func IsExist(path string) bool
- func IsFile(path string) bool
- func Join(elem ...string) string
- func ListDir(path string)
- func MakeDir(dst string) error
- func MakeIdGenerator(prefix string) func() string
- func MakeIntIdGenerator() func() uint64
- func MapToArray[T any](m map[string]T) []T
- func Must(err error)
- func NewUUID() string
- func ParseJson(data []byte, out any) error
- func ParseYaml(data []byte, out any) error
- func ReadDocument(path string, v any) error
- func ReadYamlFromData(in []byte, out any) error
- func RemoveDir(dst string) error
- func ScanFile(fn string) ([][]byte, error)
- func ScanNDJSON[T any](r io.Reader) ([]T, error)
- func ScanNDJSONFile[T any](path string) ([]T, error)
- func ToSlice(v any) []any
- func WaitForInterrupt(cancel func())
- func WriteDocument(path string, v any) error
- func WriteFile(dst string, data []byte) error
- func YamlToJson(in []byte) ([]byte, error)
- type EventEmitter
- type EventHandler
- type ExtFilter
- type HTTPSender
- type Iterator
- type SenderControl
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Abbreviate ¶ added in v0.23.2
Used by templates to generate abbreviation inside the code
func ArrayToMap ¶ added in v0.15.6
ArrayToMap converts an array to a map using a key function
func EachTicked ¶ added in v0.26.3
EachTicked calls fn for each item in items every dt.
func ExpandFiles ¶ added in v0.24.0
func ExpandInputs ¶ added in v0.24.0
func FallbackDir ¶ added in v0.24.0
FallbackDir returns the first dir that exists.
func FindDocuments ¶
func GetDocumentType ¶ added in v0.20.0
func GetFreePort ¶ added in v0.8.0
func HttpPostJson ¶ added in v0.24.0
func IsDocument ¶
func MakeIdGenerator ¶ added in v0.8.0
func MakeIntIdGenerator ¶ added in v0.19.0
func MakeIntIdGenerator() func() uint64
func MapToArray ¶ added in v0.15.6
MapToArray converts a map to an array
func ReadDocument ¶
func ReadYamlFromData ¶
func ScanNDJSON ¶ added in v0.24.0
Scan scans a reader line by line and writes to the writer.
func ScanNDJSONFile ¶ added in v0.24.0
ScanFile scans a file line by line and writes to the writer.
func WaitForInterrupt ¶ added in v0.24.0
func WaitForInterrupt(cancel func())
WaitForInterrupt handles SIGINT and SIGTERM signals. It cancels the context when a signal is received.
func WriteDocument ¶
func YamlToJson ¶
Types ¶
type EventEmitter ¶ added in v0.24.0
EventEmitter is a typed event emitter.
func NewEventEmitter ¶ added in v0.24.0
func NewEventEmitter[T any]() *EventEmitter[T]
NewEventEmitter creates a new event emitter.
func (*EventEmitter[T]) Clear ¶ added in v0.24.0
func (e *EventEmitter[T]) Clear()
Clear removes all handlers.
func (*EventEmitter[T]) Emit ¶ added in v0.24.0
func (e *EventEmitter[T]) Emit(evt T)
Emit emits an event to all handlers.
func (*EventEmitter[T]) On ¶ added in v0.24.0
func (e *EventEmitter[T]) On(handler EventHandler[T])
On registers a new event handler.
type EventHandler ¶ added in v0.24.0
type EventHandler[T any] func(evt T)
EventHandler callback for an event.
type HTTPSender ¶ added in v0.24.0
type HTTPSender struct {
// contains filtered or unexported fields
}
func NewHTTPSender ¶ added in v0.24.0
func NewHTTPSender(url string) *HTTPSender
func (*HTTPSender) Send ¶ added in v0.24.0
func (s *HTTPSender) Send(data []byte, contentType string) error
Send sends the data to the sender.
func (*HTTPSender) SendValue ¶ added in v0.24.0
func (s *HTTPSender) SendValue(value interface{}) error
SendValue sends the value as json to the sender.
type Iterator ¶ added in v0.26.3
func NewIterator ¶ added in v0.26.3
type SenderControl ¶ added in v0.24.0
type SenderControl[T any] struct { // contains filtered or unexported fields }
func NewSenderControl ¶ added in v0.24.0
func NewSenderControl[T any](repeat int, sleep time.Duration) *SenderControl[T]
func (*SenderControl[T]) Run ¶ added in v0.24.0
func (t *SenderControl[T]) Run(items []T, send func(T) error) error