Documentation
¶
Overview ¶
Package testplugins provides managed plugins for lifecycle integration tests.
Example (EventTransformation) ¶
package main
import (
"fmt"
"maps"
"slices"
"github.com/blinklabs-io/adder/event"
)
func main() {
type reading struct {
Labels map[string]string
Values []int
}
incoming := event.Event{Payload: reading{
Labels: map[string]string{"source": "original"},
Values: []int{1, 2},
}}
transformed := incoming
payload := incoming.Payload.(reading)
payload.Labels = maps.Clone(payload.Labels)
payload.Values = slices.Clone(payload.Values)
payload.Labels["source"] = "transformed"
payload.Values[0] = 9
transformed.Payload = payload
fmt.Println(
incoming.Payload.(reading).Labels["source"],
incoming.Payload.(reading).Values,
)
fmt.Println(
transformed.Payload.(reading).Labels["source"],
transformed.Payload.(reading).Values,
)
}
Output: original [1 2] transformed [9 2]
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HandlerOutput ¶
HandlerOutput passes immutable events to a cancellation-aware handler. A handler error is terminal. The handler must return on context cancellation.
func NewHandlerOutput ¶
NewHandlerOutput validates its dependency without acquiring resources.
func (*HandlerOutput) Role ¶
func (*HandlerOutput) Role() plugin.PluginType
Role declares this plugin's event ports.
func (*HandlerOutput) Start ¶
func (p *HandlerOutput) Start() error
Start starts an independently owned run. Pipelines use StartContext.
func (*HandlerOutput) StartContext ¶
func (p *HandlerOutput) StartContext(ctx context.Context) error
StartContext starts the handler worker with the run's context.
func (*HandlerOutput) Stop ¶
func (p *HandlerOutput) Stop() error
Stop cancels the handler and joins it. Cancellation must be cooperative.
type TickerInput ¶
TickerInput publishes example.tick events until its run is canceled.
func NewTickerInput ¶
func NewTickerInput(interval time.Duration) (*TickerInput, error)
NewTickerInput validates its configuration without acquiring resources.
func (*TickerInput) Role ¶
func (*TickerInput) Role() plugin.PluginType
Role declares this plugin's event ports.
func (*TickerInput) Start ¶
func (p *TickerInput) Start() error
Start starts an independently owned run. Pipelines use StartContext.
func (*TickerInput) StartContext ¶
func (p *TickerInput) StartContext(ctx context.Context) error
StartContext starts production with cancellation controlled by ctx.
func (*TickerInput) Stop ¶
func (p *TickerInput) Stop() error
Stop cancels production and joins the worker before closing its channels.