circuitgentest

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregator

type Aggregator struct {
	IncSumError error
	// contains filtered or unexported fields
}

Aggregator is a test struct for wrapper generation

func (*Aggregator) IncSum

func (a *Aggregator) IncSum(ctx context.Context, v int) error

IncSum increments sum by v

func (*Aggregator) Sum

func (a *Aggregator) Sum() int

Sum returns sum

type CircuitWrapperAggregator

type CircuitWrapperAggregator struct {
	*Aggregator

	// ShouldSkipError determines whether an error should be skipped and have the circuit
	// track the call as successful. This takes precedence over IsBadRequest
	ShouldSkipError func(error) bool

	// IsBadRequest checks whether to count a user error against the circuit. It is recommended to set this
	IsBadRequest func(error) bool

	// CircuitIncSum is the circuit for method IncSum
	CircuitIncSum *circuit.Circuit
}

CircuitWrapperAggregator is a circuit wrapper for *Aggregator

func NewCircuitWrapperAggregator

func NewCircuitWrapperAggregator(
	manager *circuit.Manager,
	embedded *Aggregator,
	conf CircuitWrapperAggregatorConfig,
) (*CircuitWrapperAggregator, error)

NewCircuitWrapperAggregator creates a new circuit wrapper and initializes circuits

func (*CircuitWrapperAggregator) IncSum

func (w *CircuitWrapperAggregator) IncSum(ctx context.Context, p1 int) error

IncSum calls the embedded *Aggregator's method IncSum with CircuitIncSum

type CircuitWrapperAggregatorConfig

type CircuitWrapperAggregatorConfig struct {
	// ShouldSkipError determines whether an error should be skipped and have the circuit
	// track the call as successful. This takes precedence over IsBadRequest
	ShouldSkipError func(error) bool

	// IsBadRequest is an optional bad request checker. It is useful to not count user errors as faults
	IsBadRequest func(error) bool

	// Prefix is prepended to all circuit names
	Prefix string

	// Defaults are used for all created circuits. Per-circuit configs override this
	Defaults circuit.Config

	// CircuitIncSum is the configuration used for the IncSum circuit. This overrides values set by Defaults
	CircuitIncSum circuit.Config
}

CircuitWrapperAggregatorConfig contains configuration for CircuitWrapperAggregator. All fields are optional

type CircuitWrapperPublisher

type CircuitWrapperPublisher struct {
	Publisher

	// ShouldSkipError determines whether an error should be skipped and have the circuit
	// track the call as successful. This takes precedence over IsBadRequest
	ShouldSkipError func(error) bool

	// IsBadRequest checks whether to count a user error against the circuit. It is recommended to set this
	IsBadRequest func(error) bool

	// CircuitPublish is the circuit for method Publish
	CircuitPublish *circuit.Circuit
	// CircuitPublishWithResult is the circuit for method PublishWithResult
	CircuitPublishWithResult *circuit.Circuit
}

CircuitWrapperPublisher is a circuit wrapper for Publisher

func NewCircuitWrapperPublisher

func NewCircuitWrapperPublisher(
	manager *circuit.Manager,
	embedded Publisher,
	conf CircuitWrapperPublisherConfig,
) (*CircuitWrapperPublisher, error)

NewCircuitWrapperPublisher creates a new circuit wrapper and initializes circuits

func (*CircuitWrapperPublisher) Publish

func (w *CircuitWrapperPublisher) Publish(ctx context.Context, p1 map[Seed][][]Grant, p2 TopicsList, p3 ...rep.PublishOption) (map[string]struct{}, error)

Publish calls the embedded Publisher's method Publish with CircuitPublish

func (*CircuitWrapperPublisher) PublishWithResult

func (w *CircuitWrapperPublisher) PublishWithResult(ctx context.Context, p1 rep.PublishInput) (*model.Result, error)

PublishWithResult calls the embedded Publisher's method PublishWithResult with CircuitPublishWithResult

type CircuitWrapperPublisherCircuitV3 added in v1.1.0

type CircuitWrapperPublisherCircuitV3 struct {
	Publisher

	// ShouldSkipError determines whether an error should be skipped and have the circuit
	// track the call as successful. This takes precedence over IsBadRequest
	ShouldSkipError func(error) bool

	// IsBadRequest checks whether to count a user error against the circuit. It is recommended to set this
	IsBadRequest func(error) bool

	// CircuitPublish is the circuit for method Publish
	CircuitPublish *circuit.Circuit
	// CircuitPublishWithResult is the circuit for method PublishWithResult
	CircuitPublishWithResult *circuit.Circuit
}

CircuitWrapperPublisherCircuitV3 is a circuit wrapper for Publisher

func NewCircuitWrapperPublisherCircuitV3 added in v1.1.0

func NewCircuitWrapperPublisherCircuitV3(
	manager *circuit.Manager,
	embedded Publisher,
	conf CircuitWrapperPublisherCircuitV3Config,
) (*CircuitWrapperPublisherCircuitV3, error)

NewCircuitWrapperPublisherCircuitV3 creates a new circuit wrapper and initializes circuits

func (*CircuitWrapperPublisherCircuitV3) Publish added in v1.1.0

func (w *CircuitWrapperPublisherCircuitV3) Publish(ctx context.Context, p1 map[Seed][][]Grant, p2 TopicsList, p3 ...rep.PublishOption) (map[string]struct{}, error)

Publish calls the embedded Publisher's method Publish with CircuitPublish

func (*CircuitWrapperPublisherCircuitV3) PublishWithResult added in v1.1.0

PublishWithResult calls the embedded Publisher's method PublishWithResult with CircuitPublishWithResult

type CircuitWrapperPublisherCircuitV3Config added in v1.1.0

type CircuitWrapperPublisherCircuitV3Config struct {
	// ShouldSkipError determines whether an error should be skipped and have the circuit
	// track the call as successful. This takes precedence over IsBadRequest
	ShouldSkipError func(error) bool

	// IsBadRequest is an optional bad request checker. It is useful to not count user errors as faults
	IsBadRequest func(error) bool

	// Prefix is prepended to all circuit names
	Prefix string

	// Defaults are used for all created circuits. Per-circuit configs override this
	Defaults circuit.Config

	// CircuitPublish is the configuration used for the Publish circuit. This overrides values set by Defaults
	CircuitPublish circuit.Config
	// CircuitPublishWithResult is the configuration used for the PublishWithResult circuit. This overrides values set by Defaults
	CircuitPublishWithResult circuit.Config
}

CircuitWrapperPublisherCircuitV3Config contains configuration for CircuitWrapperPublisherCircuitV3. All fields are optional

type CircuitWrapperPublisherConfig

type CircuitWrapperPublisherConfig struct {
	// ShouldSkipError determines whether an error should be skipped and have the circuit
	// track the call as successful. This takes precedence over IsBadRequest
	ShouldSkipError func(error) bool

	// IsBadRequest is an optional bad request checker. It is useful to not count user errors as faults
	IsBadRequest func(error) bool

	// Prefix is prepended to all circuit names
	Prefix string

	// Defaults are used for all created circuits. Per-circuit configs override this
	Defaults circuit.Config

	// CircuitPublish is the configuration used for the Publish circuit. This overrides values set by Defaults
	CircuitPublish circuit.Config
	// CircuitPublishWithResult is the configuration used for the PublishWithResult circuit. This overrides values set by Defaults
	CircuitPublishWithResult circuit.Config
}

CircuitWrapperPublisherConfig contains configuration for CircuitWrapperPublisher. All fields are optional

type Grant

type Grant struct {
	// Name is a name
	Name string
}

Grant is a test struct

type MockPublisher

type MockPublisher struct {
	mock.Mock
}

MockPublisher is a test mock for the Publisher interface

func (*MockPublisher) Close

func (m *MockPublisher) Close() error

Close mocks the method

func (*MockPublisher) Publish

func (m *MockPublisher) Publish(ctx context.Context, g map[Seed][][]Grant, s TopicsList, opts ...rep.PublishOption) (map[string]struct{}, error)

Publish mocks the method

func (*MockPublisher) PublishWithResult

func (m *MockPublisher) PublishWithResult(ctx context.Context, input rep.PublishInput) (*model.Result, error)

PublishWithResult mocks the method

type Publisher

type Publisher interface {
	// PublishWithResult is a test method and should be wrapped
	PublishWithResult(context.Context, rep.PublishInput) (*model.Result, error)
	// PublishWithResult is a test method and should be wrapped
	Publish(context.Context, map[Seed][][]Grant, TopicsList, ...rep.PublishOption) (map[string]struct{}, error)
	// PublishWithResult is a test method and should not be wrapped
	Close() error
}

Publisher is an interface for testing. This interface has many different types to test generation.

type Seed

type Seed string

Seed is a test type

type TopicsList

type TopicsList struct {
	List []string
}

TopicsList is a test struct

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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