async

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package async contains infrastructure for performing asynchronous tasks in the CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	// Text is a description of the event. Events with the same text represent
	// updates to the status of a single sub-operation.
	Text string
	// Status is the updated status of the sub-operation.
	Status EventStatus
}

Event represents an event that happened during an asynchronous operation. It is used to pass information back to callers that are interested in the operation's progress.

type EventChannel

type EventChannel chan Event

EventChannel is a channel for sending events. We define our own type for it so we can attach useful functions to it.

func (EventChannel) SendEvent

func (ch EventChannel) SendEvent(text string, status EventStatus)

SendEvent sends an event to an event channel. It is a no-op if the channel is nil. This allows event producers to produce events unconditionally, with callers providing an optionally nil channel.

type EventStatus

type EventStatus string

EventStatus represents the status of an async process.

const (
	// EventStatusStarted indicates that an operation has started.
	EventStatusStarted EventStatus = "started"
	// EventStatusSuccess indicates that an operation has completed
	// successfully.
	EventStatusSuccess EventStatus = "success"
	// EventStatusFailure indicates that an operation has failed.
	EventStatusFailure EventStatus = "failure"
)

Jump to

Keyboard shortcuts

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