Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit63ffcc7

Browse files
refactor: improve docs
1 parent101df47 commit63ffcc7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

‎coderd/prebuilds/preset_snapshot.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ func (ra *ReconciliationActions) IsNoop() bool {
8787
returnra.Create==0&&len(ra.DeleteIDs)==0&&ra.BackoffUntil.IsZero()
8888
}
8989

90-
// MatchesCronchecks if the given time matches the cron expression
91-
//Assumesthe timeis already in the correct timezone
90+
// MatchesCroninterprets a cron spec as a continuous time range,
91+
//and returns whethertheprovidedtimevalue falls within that range.
9292
funcMatchesCron(cronExpressionstring,at time.Time) (bool,error) {
9393
sched,err:=cron.Weekly(cronExpression)
9494
iferr!=nil {
@@ -98,14 +98,17 @@ func MatchesCron(cronExpression string, at time.Time) (bool, error) {
9898
returnsched.IsWithinRange(at),nil
9999
}
100100

101+
// CalculateDesiredInstances returns the number of desired instances based on the provided time.
102+
// If the time matches any defined autoscaling schedule, the corresponding number of instances is returned.
103+
// Otherwise, it falls back to the default number of instances specified in the prebuild configuration.
101104
func (pPresetSnapshot)CalculateDesiredInstances(at time.Time) (int32,error) {
102105
if!p.Preset.AutoscalingEnabled {
103106
returnp.Preset.DesiredInstances.Int32,nil
104107
}
105108

106109
_,err:=time.LoadLocation(p.Preset.AutoscalingTimezone)
107110
iferr!=nil {
108-
return0,xerrors.Errorf("can't parse location %v: %w",p.Preset.AutoscalingTimezone,err)
111+
return0,xerrors.Errorf("failed to parse location %v: %w",p.Preset.AutoscalingTimezone,err)
109112
}
110113

111114
// Check each schedule

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp