go.temporal.io/server/common/archiver/options.go
77 LOC · 11 covered · 66 uncovered · 4 ranges · 108 concepts · 2 introducers · 50 tests
File neighbourhood
The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.
Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file
In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.
Graph controls are ready.
Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.
package archiver
import (
"context"
"errors"
"go.temporal.io/sdk/activity"
)
type (
// ArchiveOption is used to provide options for adding features to
// the Archive method of History/Visibility Archiver
ArchiveOption func(featureCatalog *ArchiveFeatureCatalog)
// ArchiveFeatureCatalog is a collection features for the Archive method of
// History/Visibility Archiver
ArchiveFeatureCatalog struct {
ProgressManager ProgressManager
NonRetryableError NonRetryableError
}
// NonRetryableError returns an error indicating archiver has encountered an non-retryable error
NonRetryableError func() error
// ProgressManager is used to record and load archive progress
ProgressManager interface {
RecordProgress(ctx context.Context, progress any) error
LoadProgress(ctx context.Context, valuePtr any) error
HasProgress(ctx context.Context) bool
}
)
// GetFeatureCatalog applies all the ArchiveOptions to the catalog and returns the catalog.
// It should be called inside the Archive method.
catalog := &ArchiveFeatureCatalog{}
for _, opt := range opts {
}
}
// GetHeartbeatArchiveOption returns an ArchiveOption for enabling heartbeating.
// It should be used when the Archive method is invoked inside an activity.
func GetHeartbeatArchiveOption() ArchiveOption {
return func(catalog *ArchiveFeatureCatalog) {
catalog.ProgressManager = &heartbeatProgressManager{}
}
}
type heartbeatProgressManager struct{}
func (h *heartbeatProgressManager) RecordProgress(ctx context.Context, progress any) error {
activity.RecordHeartbeat(ctx, progress)
return nil
}
func (h *heartbeatProgressManager) LoadProgress(ctx context.Context, valuePtr any) error {
if !h.HasProgress(ctx) {
return errors.New("no progress information in the context")
}
return activity.GetHeartbeatDetails(ctx, valuePtr)
}
func (h *heartbeatProgressManager) HasProgress(ctx context.Context) bool {
return activity.HasHeartbeatDetails(ctx)
}
// GetNonRetryableErrorOption returns an ArchiveOption so that archiver knows what should
// be returned when an non-retryable error is encountered.
return func(catalog *ArchiveFeatureCatalog) {
catalog.NonRetryableError = func() error {
return nonRetryableErr
}
}
}