Documentation
¶
Index ¶
- Variables
- type CancelableCommand
- type CargoCheckQRInputs
- type CargoCheckQROutputs
- type CargoCloseInputs
- type CargoCloseOutputs
- type CargoLiftInputs
- type CargoLiftOutputs
- type CargoLowerInputs
- type CargoLowerOutputs
- type CargoOpenInputs
- type CargoOpenOutputs
- type Command
- type CommandType
- type CreateCommandParams
- type DeleteCommandByIDParams
- type ExecutorService
- type GetCommandByIDParams
- type Inputs
- type ListCommandsParams
- type Location
- type MoveBackwardInputs
- type MoveBackwardOutputs
- type MoveDirection
- type MoveForwardInputs
- type MoveForwardOutputs
- type MoveToInputs
- type MoveToOutputs
- type Outputs
- type ProcessingLock
- type Repository
- type RunningCommandRepository
- type ScanLocationInputs
- type ScanLocationOutputs
- type Service
- type Source
- type Status
- type StopMovementInputs
- type StopMovementOutputs
- type UpdateCommandParams
- type WaitInputs
- type WaitOutputs
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrCommandNotFound = xerror.NotFound(nil, "command.notFound", "command not found") ErrNoNextExecutableCommand = xerror.NotFound(nil, "command.noNextExecutable", "no next executable command") ErrNoCommandBeingProcessed = xerror.BadRequest(nil, "command.noCommandBeingProcessed", "no command being processed") ErrCommandInProcessingCanNotBeDeleted = xerror.BadRequest(nil, "command.inProcessingCanNotBeDeleted", "command in processing can not be deleted") ErrCommandAlreadyExists = xerror.Conflict(nil, "command.alreadyExists", "command already exists") ErrRunningCommandNotFound = xerror.NotFound(nil, "command.runningCommandNotFound", "running command not found") ErrRunningCommandExists = xerror.BadRequest(nil, "command.runningCommandExists", "running command already exists") )
Functions ¶
This section is empty.
Types ¶
type CancelableCommand ¶ added in v0.15.0
type CancelableCommand struct {
Command
// contains filtered or unexported fields
}
CancelableCommand is a command that can be canceled.
func NewCancelableCommand ¶ added in v0.15.0
func NewCancelableCommand(ctx context.Context, cmd Command) CancelableCommand
func (*CancelableCommand) CanBeCanceled ¶ added in v0.16.0
func (c *CancelableCommand) CanBeCanceled() bool
func (*CancelableCommand) Cancel ¶ added in v0.15.0
func (c *CancelableCommand) Cancel()
func (*CancelableCommand) Context ¶ added in v0.15.0
func (c *CancelableCommand) Context() context.Context
type CargoCheckQRInputs ¶
type CargoCheckQRInputs struct {
QRCode string `json:"qr_code" validate:"required"`
}
func (CargoCheckQRInputs) CommandType ¶
func (CargoCheckQRInputs) CommandType() CommandType
type CargoCheckQROutputs ¶
type CargoCheckQROutputs struct{}
func (CargoCheckQROutputs) CommandType ¶
func (CargoCheckQROutputs) CommandType() CommandType
type CargoCloseInputs ¶
type CargoCloseInputs struct {
MotorSpeed uint8 `json:"motor_speed" validate:"required,max=100"`
}
func (CargoCloseInputs) CommandType ¶
func (CargoCloseInputs) CommandType() CommandType
type CargoCloseOutputs ¶
type CargoCloseOutputs struct{}
func (CargoCloseOutputs) CommandType ¶
func (CargoCloseOutputs) CommandType() CommandType
type CargoLiftInputs ¶
type CargoLiftInputs struct {
Position uint16 `json:"position" validate:"required"`
MotorSpeed uint8 `json:"motor_speed" validate:"required,max=100"`
}
func (CargoLiftInputs) CommandType ¶
func (CargoLiftInputs) CommandType() CommandType
type CargoLiftOutputs ¶
type CargoLiftOutputs struct{}
func (CargoLiftOutputs) CommandType ¶
func (CargoLiftOutputs) CommandType() CommandType
type CargoLowerInputs ¶
type CargoLowerInputs struct {
Position uint16 `json:"position" validate:"required"`
MotorSpeed uint8 `json:"motor_speed" validate:"required,max=100"`
}
func (CargoLowerInputs) CommandType ¶
func (CargoLowerInputs) CommandType() CommandType
type CargoLowerOutputs ¶
type CargoLowerOutputs struct{}
func (CargoLowerOutputs) CommandType ¶
func (CargoLowerOutputs) CommandType() CommandType
type CargoOpenInputs ¶
type CargoOpenInputs struct {
MotorSpeed uint8 `json:"motor_speed" validate:"required,max=100"`
}
func (CargoOpenInputs) CommandType ¶
func (CargoOpenInputs) CommandType() CommandType
type CargoOpenOutputs ¶
type CargoOpenOutputs struct{}
func (CargoOpenOutputs) CommandType ¶
func (CargoOpenOutputs) CommandType() CommandType
type Command ¶
type CommandType ¶
type CommandType string
const ( CommandTypeStopMovement CommandType = "STOP_MOVEMENT" CommandTypeMoveForward CommandType = "MOVE_FORWARD" CommandTypeMoveBackward CommandType = "MOVE_BACKWARD" CommandTypeMoveTo CommandType = "MOVE_TO" CommandTypeCargoOpen CommandType = "CARGO_OPEN" CommandTypeCargoClose CommandType = "CARGO_CLOSE" CommandTypeCargoLift CommandType = "CARGO_LIFT" CommandTypeCargoLower CommandType = "CARGO_LOWER" CommandTypeCargoCheckQR CommandType = "CARGO_CHECK_QR" CommandTypeScanLocation CommandType = "SCAN_LOCATION" CommandTypeWait CommandType = "WAIT" )
func (CommandType) String ¶
func (c CommandType) String() string
func (CommandType) Validate ¶
func (c CommandType) Validate() error
type CreateCommandParams ¶
type DeleteCommandByIDParams ¶
type DeleteCommandByIDParams struct {
CommandID int64 `validate:"required,min=1"`
}
type ExecutorService ¶ added in v0.15.0
type GetCommandByIDParams ¶
type GetCommandByIDParams struct {
CommandID int64 `validate:"required,min=1"`
}
type Inputs ¶
type Inputs interface {
CommandType() CommandType
// contains filtered or unexported methods
}
func UnmarshalInputs ¶
func UnmarshalInputs(cmdType CommandType, inputsBytes []byte) (Inputs, error)
type ListCommandsParams ¶
type MoveBackwardInputs ¶
type MoveBackwardInputs struct {
MotorSpeed uint8 `json:"motor_speed" validate:"required,max=100"`
}
func (MoveBackwardInputs) CommandType ¶
func (MoveBackwardInputs) CommandType() CommandType
type MoveBackwardOutputs ¶
type MoveBackwardOutputs struct{}
func (MoveBackwardOutputs) CommandType ¶
func (MoveBackwardOutputs) CommandType() CommandType
type MoveDirection ¶ added in v0.13.0
type MoveDirection string
const ( MoveDirectionForward MoveDirection = "FORWARD" MoveDirectionBackward MoveDirection = "BACKWARD" )
func (MoveDirection) String ¶ added in v0.13.0
func (m MoveDirection) String() string
func (MoveDirection) Validate ¶ added in v0.13.0
func (m MoveDirection) Validate() error
type MoveForwardInputs ¶
type MoveForwardInputs struct {
MotorSpeed uint8 `json:"motor_speed" validate:"required,max=100"`
}
func (MoveForwardInputs) CommandType ¶
func (MoveForwardInputs) CommandType() CommandType
type MoveForwardOutputs ¶
type MoveForwardOutputs struct{}
func (MoveForwardOutputs) CommandType ¶
func (MoveForwardOutputs) CommandType() CommandType
type MoveToInputs ¶
type MoveToInputs struct {
Location string `json:"location" validate:"required"`
Direction MoveDirection `json:"direction" validate:"required,enum"`
MotorSpeed uint8 `json:"motor_speed" validate:"required,max=100"`
}
func (MoveToInputs) CommandType ¶
func (MoveToInputs) CommandType() CommandType
type MoveToOutputs ¶
type MoveToOutputs struct{}
func (MoveToOutputs) CommandType ¶
func (MoveToOutputs) CommandType() CommandType
type Outputs ¶
type Outputs interface {
CommandType() CommandType
// contains filtered or unexported methods
}
func UnmarshalOutputs ¶
func UnmarshalOutputs(cmdType CommandType, outputsBytes []byte) (Outputs, error)
type ProcessingLock ¶ added in v0.13.0
type ProcessingLock interface {
// WithLock acquires the lock and executes the function.
// The lock is released when the function returns.
WithLock(fn func() error) error
// WaitUntilUnlocked blocks the execution until the lock is released.
// If the context is canceled, the function returns immediately.
WaitUntilUnlocked(ctx context.Context) error
}
ProcessingLock is responsible for controlling a lock mechanism that prevents the system from automatically picking up and processing the next command in the queue.
Note: This lock does not handle stopping or canceling a command that is already being executed. Its sole purpose is to block the transition to the next command, ensuring that no new command is started while the lock is held.
type Repository ¶
type Repository interface {
ListCommands(ctx context.Context, params ListCommandsParams) (paging.List[Command], error)
GetNextExecutableCommand(ctx context.Context) (Command, error)
GetCurrentProcessingCommand(ctx context.Context) (Command, error)
GetCommandByID(ctx context.Context, id int64) (Command, error)
CreateCommand(ctx context.Context, command Command) (Command, error)
UpdateCommand(ctx context.Context, params UpdateCommandParams) (Command, error)
// CancelPendingCommands cancels all pending commands by status QUEUED, PROCESSING, and CANCELING.
CancelPendingCommands(ctx context.Context) error
CancelQueuedAndProcessingCommandsCreatedByCloud(ctx context.Context) error
// DeleteCommandByID deletes a command by id.
// It does not delete the command if the status is PROCESSING, CANCELING.
DeleteCommandByID(ctx context.Context, id int64) error
DeleteOldCommands(ctx context.Context, cutoffTime time.Time) error
}
type RunningCommandRepository ¶ added in v0.15.0
type RunningCommandRepository interface {
Get(ctx context.Context) (CancelableCommand, error)
Add(ctx context.Context, cmd CancelableCommand) error
Update(ctx context.Context, cmd CancelableCommand) error
Remove(ctx context.Context) error
}
type ScanLocationInputs ¶
type ScanLocationInputs struct{}
func (ScanLocationInputs) CommandType ¶
func (ScanLocationInputs) CommandType() CommandType
type ScanLocationOutputs ¶
type ScanLocationOutputs struct {
Locations []Location `json:"locations"`
}
func (ScanLocationOutputs) CommandType ¶
func (ScanLocationOutputs) CommandType() CommandType
type Service ¶
type Service interface {
GetCommandByID(ctx context.Context, params GetCommandByIDParams) (Command, error)
GetCurrentProcessingCommand(ctx context.Context) (Command, error)
ListCommands(ctx context.Context, params ListCommandsParams) (paging.List[Command], error)
CreateCommand(ctx context.Context, params CreateCommandParams) (Command, error)
CancelCurrentProcessingCommand(ctx context.Context) error
// CancelActiveCloudCommands cancels all QUEUED and PROCESSING commands created by the cloud.
CancelActiveCloudCommands(ctx context.Context) error
RunNextExecutableCommand(ctx context.Context) error
// CancelAllRunningCommands cancels all running commands including the current processing command
// and the commands in the queue.
CancelAllRunningCommands(ctx context.Context) error
DeleteCommandByID(ctx context.Context, params DeleteCommandByIDParams) error
DeleteOldCommands(ctx context.Context) error
}
type StopMovementInputs ¶
type StopMovementInputs struct{}
func (StopMovementInputs) CommandType ¶
func (StopMovementInputs) CommandType() CommandType
type StopMovementOutputs ¶
type StopMovementOutputs struct{}
func (StopMovementOutputs) CommandType ¶
func (StopMovementOutputs) CommandType() CommandType
type UpdateCommandParams ¶
type WaitInputs ¶
type WaitInputs struct {
DurationMs int64 `json:"duration_ms" validate:"required"`
}
func (WaitInputs) CommandType ¶
func (WaitInputs) CommandType() CommandType
type WaitOutputs ¶
type WaitOutputs struct{}
func (WaitOutputs) CommandType ¶
func (WaitOutputs) CommandType() CommandType
Click to show internal directories.
Click to hide internal directories.