Implemented the initial Go framework
This commit is contained in:
47
internal/builtin/postprocess.go
Normal file
47
internal/builtin/postprocess.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package builtin
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.maximumdirect.net/eric/seriatim/internal/config"
|
||||
"gitea.maximumdirect.net/eric/seriatim/internal/model"
|
||||
"gitea.maximumdirect.net/eric/seriatim/internal/report"
|
||||
)
|
||||
|
||||
type noopPostprocessor struct {
|
||||
name string
|
||||
}
|
||||
|
||||
func (p noopPostprocessor) Name() string {
|
||||
return p.name
|
||||
}
|
||||
|
||||
func (p noopPostprocessor) Process(ctx context.Context, in model.MergedTranscript, cfg config.Config) (model.MergedTranscript, []report.Event, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return model.MergedTranscript{}, nil, err
|
||||
}
|
||||
|
||||
return in, []report.Event{
|
||||
report.Info("postprocessing", p.name, "completed no-op postprocessing module"),
|
||||
}, nil
|
||||
}
|
||||
|
||||
type assignIDs struct{}
|
||||
|
||||
func (assignIDs) Name() string {
|
||||
return "assign-ids"
|
||||
}
|
||||
|
||||
func (assignIDs) Process(ctx context.Context, in model.MergedTranscript, cfg config.Config) (model.MergedTranscript, []report.Event, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return model.MergedTranscript{}, nil, err
|
||||
}
|
||||
|
||||
for index := range in.Segments {
|
||||
in.Segments[index].ID = index + 1
|
||||
}
|
||||
|
||||
return in, []report.Event{
|
||||
report.Info("postprocessing", "assign-ids", "assigned final segment IDs"),
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user