fake

package
v0.67.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2025 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package fake implements fake switches with different position counts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSwitch

func NewSwitch(
	ctx context.Context,
	deps resource.Dependencies,
	conf resource.Config,
	logger logging.Logger,
) (toggleswitch.Switch, error)

NewSwitch instantiates a new switch of the fake model type.

Types

type Config

type Config struct {
	resource.TriviallyValidateConfig

	// PositionCount is the number of positions that the switch can be in.
	// If omitted, the switch will have two positions.
	PositionCount *uint32 `json:"position_count"`
}

Config is the config for a fake switch.

type Switch

type Switch struct {
	resource.Named
	resource.TriviallyCloseable
	resource.AlwaysRebuild
	// contains filtered or unexported fields
}

Switch is a fake switch that can be set to different positions.

func (*Switch) GetNumberOfPositions

func (s *Switch) GetNumberOfPositions(ctx context.Context, extra map[string]interface{}) (uint32, error)

GetNumberOfPositions returns the total number of valid positions for this switch.

func (*Switch) GetPosition

func (s *Switch) GetPosition(ctx context.Context, extra map[string]interface{}) (uint32, error)

GetPosition returns the current position of the switch.

func (*Switch) SetPosition

func (s *Switch) SetPosition(ctx context.Context, position uint32, extra map[string]interface{}) error

SetPosition sets the switch to the specified position.

Jump to

Keyboard shortcuts

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