Documentation ¶
Overview ¶
Package shared provides everything shared between entities.
Index ¶
- Variables
- func Decode(r io.Reader, v any) error
- func Encode(w io.Writer, v any) error
- func ExtractID[T any](t T, idFieldName string) string
- func Flatten2D[T any](data [][]T) []T
- func GenerateIDBasedOnContent(ct string) string
- func GenerateUUID() string
- func GetPaused() int32
- func Marshal(v any) ([]byte, error)
- func OnErrorHandler(tracedContext context.Context, iMetric IMetrics, l sypl.ISypl, err error, ...) error
- func ReadAll(r io.Reader) ([]byte, error)
- func SetPaused(val int32)
- func Unmarshal(data []byte, v any) error
- type IMeta
- type IMetrics
Constants ¶
This section is empty.
Variables ¶
var Paused int32 = 0
Paused is a flag that indicates if the pipeline is paused.
Functions ¶
func ExtractID ¶
ExtractID extracts `possibleIDFieldNames` from `v` - an arbitrary struct.
NOTE: Only exported fields are considered.
func Flatten2D ¶
func Flatten2D[T any](data [][]T) []T
Flatten2D takes a 2D slice and returns a 1D slice containing all the elements.
func GenerateIDBasedOnContent ¶
GenerateIDBasedOnContent generates MD5 hash (content-based) for message ID. Good to be used to avoid duplicated messages.
func GenerateUUID ¶
func GenerateUUID() string
GenerateUUID generates a RFC4122 UUID and DCE 1.1: Authentication and Security Services.
func OnErrorHandler ¶ added in v2.1.0
func OnErrorHandler( tracedContext context.Context, iMetric IMetrics, l sypl.ISypl, err error, message, t, name string, ) error
OnErrorHandler deals with observability (update status, logging, metrics) when an processor, or stage, or the pipeline error.
Types ¶
type IMeta ¶
type IMeta interface { // GetName returns the `Name` of the entity. GetName() string // GetLogger returns the `Logger` of the entity. GetLogger() sypl.ISypl // GetDescription returns the `Description` of the processor. GetDescription() string // GetType returns the entity type. GetType() string }
IMeta defines what an `Entity` must do.
type IMetrics ¶
type IMetrics interface { // GetCounterCreated returns the `CounterCreated` metric. GetCounterCreated() *expvar.Int // GetCounterRunning returns the `CounterRunning` metric. GetCounterRunning() *expvar.Int // GetCounterFailed returns the `CounterFailed` metric. GetCounterFailed() *expvar.Int // GetCounterDone returns the `CounterDone` metric. GetCounterDone() *expvar.Int // GetStatus returns the `Status` metric. GetStatus() *expvar.String // GetCreatedAt returns the created at time. GetCreatedAt() time.Time // GetDuration returns the `CounterDuration` of the stage. GetDuration() *expvar.Int // GetMetrics returns the stage's metrics. GetMetrics() map[string]string }
IMetrics defines how to interact with the metrics.