Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var InspectionTimeProducer common_task.Task[time.Time] = common_task.NewTask(inspectioncore_contract.InspectionTimeTaskID, []taskid.UntypedTaskReference{}, func(ctx context.Context) (time.Time, error) { return time.Now(), nil })
InspectionTimeProducer is a provider of inspection time. Tasks shouldn't use time.Now() directly to make test easier.
View Source
var SerializeTask = inspectiontaskbase.NewProgressReportableInspectionTask(inspectioncore_contract.SerializerTaskID, []taskid.UntypedTaskReference{}, func(ctx context.Context, taskMode inspectioncore_contract.InspectionTaskModeType, progress *inspectionmetadata.TaskProgressMetadata) (*inspectioncore_contract.FileSystemStore, error) { if taskMode == inspectioncore_contract.TaskModeDryRun { slog.DebugContext(ctx, "Skipping because this is in dryrun mode") return nil, nil } inspectionID := khictx.MustGetValue(ctx, inspectioncore_contract.InspectionTaskInspectionID) metadataSet := khictx.MustGetValue(ctx, inspectioncore_contract.InspectionRunMetadata) ioConfig := khictx.MustGetValue(ctx, inspectioncore_contract.CurrentIOConfig) builder := khictx.MustGetValue(ctx, inspectioncore_contract.Builder) for _, key := range metadataSet.Keys() { metadata, found := typedmap.Get(metadataSet, inspectionmetadata.NewMetadataLabelsKey[inspectionmetadata.Metadata](key)) if !found { return nil, fmt.Errorf("expected metadata not found: %s", key) } if err := builder.MetadataAccumulator.AddMetadata(metadata); err != nil { return nil, err } } store := inspectioncore_contract.NewFileSystemInspectionResultRepository(filepath.Join(ioConfig.DataDestination, inspectionID+".khi")) writer, err := store.GetWriter() if err != nil { return nil, err } if err := builder.Build(writer, &taskProgressReporter{progress: progress}); err != nil { writer.Close() return nil, err } if err := writer.Close(); err != nil { return nil, err } fileSize, err := store.GetInspectionResultSizeInBytes() if err != nil { return nil, err } header, found := typedmap.Get(metadataSet, inspectionmetadata.HeaderMetadataKey) if found { header.FileSize = fileSize } return store, nil })
SerializeTask is a subsequent task that must be included in the task graph after tasks like TimelineMapper and LogIngester. It retrieves the Builder instance populated by its preceding tasks and serializes its accumulated contents into the final KHI file.
View Source
var TestInspectionTimeTaskProducer func(timeStr string) common_task.Task[time.Time] = func(timeStr string) common_task.Task[time.Time] { return common_task.NewTask(inspectioncore_contract.InspectionTimeTaskID, []taskid.UntypedTaskReference{}, func(ctx context.Context) (time.Time, error) { t, err := time.Parse(time.RFC3339, timeStr) if err != nil { return time.Time{}, err } return t, nil }) }
TestInspectionTimeTaskProducer is a function to generate a fake InspectionTimeProducer task with the given time string.
View Source
var TimeZoneShiftInputTask = inspectiontaskbase.NewInspectionTask(inspectioncore_contract.TimeZoneShiftInputTaskID, []taskid.UntypedTaskReference{}, func(ctx context.Context, taskMode inspectioncore_contract.InspectionTaskModeType) (*time.Location, error) { req := khictx.MustGetValue(ctx, inspectioncore_contract.InspectionTaskInput) if tzShiftAny, found := req["timezoneShift"]; found { if tzShiftFloat, convertible := tzShiftAny.(float64); convertible { return time.FixedZone("Unknown", int(tzShiftFloat*3600)), nil } else { return time.UTC, nil } } else { return time.UTC, nil } })
Functions ¶
func Register ¶
func Register(registry coretask.TaskRegistry) error
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.