@@ -9,23 +9,24 @@ import (
9
9
)
10
10
11
11
// A Unit (named to represent its resemblance to the systemd concept) is a kind of lock that encodes metadata
12
- // about the state of a resource. Units are primarily meant tobe sections of processes such as coder scripts
13
- //that encapsulate a contended resource, such as a database lock or a socket.
12
+ // about the state of a resource. Units are primarily meant toencapsulate sections of processes such as coder scripts
13
+ //to coordinate access to a contended resource, such as a database lock or a socket that is used or provided by the script .
14
14
//
15
- // In most cases, `coder_script` resources will create and manage units by invocations of
15
+ // In most cases, `coder_script` resources will create and manage units by invocations of:
16
16
// * `coder agent unit start <unit> [--wants <unit>]`
17
17
// * `coder agent unit complete <unit>`
18
18
// * `coder agent unit fail <unit>`
19
- //Units may be acquired with no intention of releasing them as a signal to other scripts that
20
- // a contended resource has been provided and is available. For example, a script that installs curl
21
- //might acquire a unit called "curl-install" to signal to other scripts that curl has been installed
22
- //and is available. In this case, the unit will becompleted when theagent is stopped .
19
+ //* `coder agent unit lock <unit>`
20
+ //
21
+ //Those CLI command examples are implemented elsewhere and are only shown here as a convenient example of the functionality
22
+ //provided by Units. This file contains analogous methods to beused by theCLI implementations .
23
23
type Unit struct {
24
24
Name string
25
25
history []Event
26
26
Wants []* Unit
27
27
}
28
28
29
+ // Events provide a coarse grained record of the lifecycle and history of a unit.
29
30
type Event struct {
30
31
Type UnitEventType
31
32
Timestamp time.Time