interceptortest

package
v1.18.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package interceptortest contains internal utilities for testing interceptors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertSpanPropagation

func AssertSpanPropagation(t *testing.T, tracer TestTracer)

func NewProxy

func NewProxy(invoker Invoker) interceptor.Interceptor

NewProxy creates a proxy interceptor that calls the given invoker.

func RunTestWorkflow added in v1.13.1

func RunTestWorkflow(t *testing.T, tracer interceptor.Tracer)

RunTestWorkflow executes a test workflow with a tracing interceptor.

Types

type CallRecordingInvoker

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

CallRecordingInvoker is an Invoker that records all calls made to it before continuing normal invocation.

func (*CallRecordingInvoker) Calls

func (c *CallRecordingInvoker) Calls() []*RecordedCall

Calls provides a copy of the currently recorded calls.

func (*CallRecordingInvoker) Invoke

func (c *CallRecordingInvoker) Invoke(p *ProxyCall) []reflect.Value

Invoke implements Invoker.Invoke to record calls.

type Invoker

type Invoker interface {
	// Invoke is called for every intercepted call. This may be called
	// concurrently from separate goroutines.
	Invoke(*ProxyCall) []reflect.Value
}

Invoker is an interface that is called for every intercepted call by a proxy.

type InvokerFunc

type InvokerFunc func(*ProxyCall) []reflect.Value

InvokerFunc implements Invoker for a single function.

func (InvokerFunc) Invoke

func (i InvokerFunc) Invoke(p *ProxyCall) []reflect.Value

InvokerFunc implements Invoker.Invoke.

type ProxyCall

type ProxyCall struct {
	Interface reflect.Type
	Next      reflect.Value
	Method    reflect.Method
	Args      []reflect.Value
}

ProxyCall represents a call made to the proxy interceptor.

func (*ProxyCall) Call

func (p *ProxyCall) Call() []reflect.Value

Call invokes this proxied call.

type RecordedCall

type RecordedCall struct {
	*ProxyCall
	// Results of the call. This will not be set if still running and may be set
	// asynchronously in a non-concurrency-safe way once the call completes.
	Results []reflect.Value
}

RecordedCall is a ProxyCall that also has results.

type SpanInfo

type SpanInfo struct {
	Name     string
	Children []*SpanInfo
}

SpanInfo is information about a span.

func Span

func Span(name string, children ...*SpanInfo) *SpanInfo

Span creates a SpanInfo.

type TestTracer

type TestTracer interface {
	interceptor.Tracer
	FinishedSpans() []*SpanInfo
}

TestTracer is an interceptor.Tracer that returns finished spans.

Jump to

Keyboard shortcuts

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