Unify chunk-plan caching and remove checkpoint execution paths
This commit is contained in:
@@ -36,29 +36,33 @@ func artifactProducerCache(input RunInput, typed *preparedTypedLane, class contr
|
||||
}
|
||||
return value, nil
|
||||
},
|
||||
Observe: func(ctx context.Context, observation contracts.CacheObservation) error {
|
||||
if chunk != nil {
|
||||
chunkIndex := chunk.Index
|
||||
observation.ChunkID, observation.ChunkIndex = chunk.ID, &chunkIndex
|
||||
}
|
||||
if observation.Err != nil {
|
||||
message := strings.ToValidUTF8(fmt.Sprintf("Artifact cache %s: %v", observation.Decision, observation.Err), "<22>")
|
||||
if len(message) > contracts.MaxDiagnosticMessageBytes {
|
||||
message = message[:contracts.MaxDiagnosticMessageBytes]
|
||||
for !utf8.ValidString(message) {
|
||||
message = message[:len(message)-1]
|
||||
}
|
||||
}
|
||||
*warnings = append(*warnings, contracts.ProducerDiagnostic{
|
||||
Disposition: contracts.DiagnosticDispositionWarning, Category: contracts.DiagnosticCategoryDegradation,
|
||||
ReasonCode: "cache_" + observation.Decision, OccurrenceCount: 1,
|
||||
Samples: []contracts.DiagnosticSample{{Scope: origin.ModuleKey, Message: message}},
|
||||
})
|
||||
}
|
||||
if input.ObserveCache != nil {
|
||||
return input.ObserveCache(ctx, origin, observation)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
Observe: producerCacheObserver(input, origin, chunk, warnings),
|
||||
}
|
||||
}
|
||||
|
||||
func producerCacheObserver(input RunInput, origin contracts.DiagnosticOrigin, chunk *source.Chunk, warnings *[]contracts.ProducerDiagnostic) func(context.Context, contracts.CacheObservation) error {
|
||||
return func(ctx context.Context, observation contracts.CacheObservation) error {
|
||||
if chunk != nil {
|
||||
chunkIndex := chunk.Index
|
||||
observation.ChunkID, observation.ChunkIndex = chunk.ID, &chunkIndex
|
||||
}
|
||||
if observation.Err != nil {
|
||||
message := strings.ToValidUTF8(fmt.Sprintf("Artifact cache %s: %v", observation.Decision, observation.Err), "<22>")
|
||||
if len(message) > contracts.MaxDiagnosticMessageBytes {
|
||||
message = message[:contracts.MaxDiagnosticMessageBytes]
|
||||
for !utf8.ValidString(message) {
|
||||
message = message[:len(message)-1]
|
||||
}
|
||||
}
|
||||
*warnings = append(*warnings, contracts.ProducerDiagnostic{
|
||||
Disposition: contracts.DiagnosticDispositionWarning, Category: contracts.DiagnosticCategoryDegradation,
|
||||
ReasonCode: "cache_" + observation.Decision, OccurrenceCount: 1,
|
||||
Samples: []contracts.DiagnosticSample{{Scope: origin.ModuleKey, Message: message}},
|
||||
})
|
||||
}
|
||||
if input.ObserveCache != nil {
|
||||
return input.ObserveCache(ctx, origin, observation)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user