service

package
v0.0.0-...-b998301 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: AGPL-3.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service defines a service for interacting with the underlying state.

func NewService

func NewService(st State, logger logger.Logger) *Service

NewService returns a new Service for interacting with the underlying state.

func (*Service) GetBlockSwitchedOn

func (s *Service) GetBlockSwitchedOn(ctx context.Context, t blockcommand.BlockType) (string, error)

GetBlockSwitchedOn returns the optional block message if it is switched on for the given type. Returns an error errors.NotFound if the block does not exist.

func (*Service) GetBlocks

func (s *Service) GetBlocks(ctx context.Context) ([]blockcommand.Block, error)

GetBlocks returns all the blocks for the current model.

func (*Service) RemoveAllBlocks

func (s *Service) RemoveAllBlocks(ctx context.Context) error

RemoveAllBlocks removes all the blocks for the current model.

func (*Service) SwitchBlockOff

func (s *Service) SwitchBlockOff(ctx context.Context, t blockcommand.BlockType) error

SwitchBlockOff disables block of specified type for the current model. Returns an error errors.NotFound if the block does not exist.

func (*Service) SwitchBlockOn

func (s *Service) SwitchBlockOn(ctx context.Context, t blockcommand.BlockType, message string) error

SwitchBlockOn switches on a command block for a given type and message. Returns an error errors.AlreadyExists if the block already exists.

type State

type State interface {
	// SetBlock switches on a command block for a given type with an optional
	// message.
	SetBlock(ctx context.Context, t blockcommand.BlockType, message string) error

	// RemoveBlock disables block of specified type for the current model.
	RemoveBlock(ctx context.Context, t blockcommand.BlockType) error

	// RemoveAllBlocks removes all the blocks for the current model.
	RemoveAllBlocks(ctx context.Context) error

	// GetBlocks returns all the blocks for the current model.
	GetBlocks(ctx context.Context) ([]blockcommand.Block, error)

	// GetBlockMessage returns the optional block message if it is switched on.
	GetBlockMessage(ctx context.Context, t blockcommand.BlockType) (string, error)
}

State defines an interface for interacting with the underlying state.

Jump to

Keyboard shortcuts

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