testplugins

package
v0.47.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

type HandlerOutput struct {
	plugin.Base
	// contains filtered or unexported fields
}

HandlerOutput passes immutable events to a cancellation-aware handler. A handler error is terminal. The handler must return on context cancellation.

func NewHandlerOutput

func NewHandlerOutput(
	handle func(context.Context, event.Event) error,
) (*HandlerOutput, error)

NewHandlerOutput validates its dependency without acquiring resources.

func (*HandlerOutput) Role

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

type TickerInput struct {
	plugin.Base
	// contains filtered or unexported fields
}

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.

Jump to

Keyboard shortcuts

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