Documentation
¶
Index ¶
- Constants
- func BuildImageDownloadURL(photoID string, width int, height int) string
- func ConsumeProcessedImages(images flx.Stream[ImageResult[[]byte]]) error
- func ConsumeUploadedImages(results flx.Stream[ImageResult[string]]) error
- func DownloadImageStage(sourceHTTPClient *http.Client, cfg PipelineConfig) func(context.Context, RemoteImage) ImageResult[[]byte]
- func DownloadImageWithRetry(ctx context.Context, client *http.Client, image RemoteImage, ...) ([]byte, error)
- func ExampleListEndpoint() string
- func ExampleUploadEndpoint() string
- func FormatDownloadRetryWarning(imageURL string, event flx.RetryEvent) string
- func FormatItemError(err error) string
- func ListExampleImages(ctx context.Context, sourceHTTPClient *http.Client, cfg PipelineConfig) flx.Stream[RemoteImage]
- func NewSourceHTTPClient() *http.Client
- func NewTargetHTTPClient() *http.Client
- func PostImage(ctx context.Context, client *http.Client, uploadEndpoint string, ...) (string, error)
- func SaveImageBytes(baseDir string, stage string, image ImageResult[[]byte]) error
- func SaveLocalImageStage(baseDir string, stage string) func(context.Context, ImageResult[[]byte]) ImageResult[[]byte]
- func TransformImageStage(transform ImageTransformer) func(context.Context, ImageResult[[]byte]) ImageResult[[]byte]
- func UploadImageStage(targetHTTPClient *http.Client, uploadEndpoint string) func(context.Context, ImageResult[[]byte]) ImageResult[string]
- type ImageCatalogEntry
- type ImageResult
- type ImageTransformer
- type PipelineConfig
- type RemoteImage
Constants ¶
const ( StageNameDownload = "download" StageNameSaveOriginal = "save-original" StageNameResize = "resize" StageNameWatermark = "watermark" StageNameSaveProcessed = "save-processed" StageNameUpload = "upload" )
Variables ¶
This section is empty.
Functions ¶
func BuildImageDownloadURL ¶
BuildImageDownloadURL derives one concrete image download URL from the image ID and target dimensions.
func ConsumeProcessedImages ¶
func ConsumeProcessedImages(images flx.Stream[ImageResult[[]byte]]) error
ConsumeProcessedImages drains the locally processed stream and logs one line per item plus one summary line.
func ConsumeUploadedImages ¶
func ConsumeUploadedImages(results flx.Stream[ImageResult[string]]) error
ConsumeUploadedImages drains the upload result stream and logs one line per item plus one summary line.
func DownloadImageStage ¶
func DownloadImageStage( sourceHTTPClient *http.Client, cfg PipelineConfig, ) func(context.Context, RemoteImage) ImageResult[[]byte]
DownloadImageStage returns the mapper used by the download step.
func DownloadImageWithRetry ¶
func DownloadImageWithRetry( ctx context.Context, client *http.Client, image RemoteImage, cfg PipelineConfig, ) ([]byte, error)
DownloadImageWithRetry centralizes the retry policy shared by the examples.
func ExampleListEndpoint ¶
func ExampleListEndpoint() string
ExampleListEndpoint returns the Picsum list endpoint used by the examples.
func ExampleUploadEndpoint ¶
func ExampleUploadEndpoint() string
ExampleUploadEndpoint returns the local upload endpoint used by the examples.
func FormatDownloadRetryWarning ¶
func FormatDownloadRetryWarning(imageURL string, event flx.RetryEvent) string
FormatDownloadRetryWarning keeps retry output aligned with the shared `kind=` logging contract.
func FormatItemError ¶
FormatItemError flattens wrapped and joined errors into one compact log line.
func ListExampleImages ¶
func ListExampleImages( ctx context.Context, sourceHTTPClient *http.Client, cfg PipelineConfig, ) flx.Stream[RemoteImage]
ListExampleImages is the source stage shared by the image-processing examples. It pages the Picsum list endpoint lazily and emits work items as soon as they are discovered.
func NewSourceHTTPClient ¶
NewSourceHTTPClient returns the source-side HTTP client used by the examples.
func NewTargetHTTPClient ¶
NewTargetHTTPClient returns the optional upload-side HTTP client used by the examples.
func PostImage ¶
func PostImage( ctx context.Context, client *http.Client, uploadEndpoint string, sourceURL string, imageBytes []byte, ) (string, error)
PostImage uploads transformed bytes to the optional target endpoint.
func SaveImageBytes ¶
func SaveImageBytes(baseDir string, stage string, image ImageResult[[]byte]) error
SaveImageBytes writes one successful image result into a stage-specific folder.
func SaveLocalImageStage ¶
func SaveLocalImageStage( baseDir string, stage string, ) func(context.Context, ImageResult[[]byte]) ImageResult[[]byte]
SaveLocalImageStage returns the mapper used by local persistence steps.
func TransformImageStage ¶
func TransformImageStage( transform ImageTransformer, ) func(context.Context, ImageResult[[]byte]) ImageResult[[]byte]
TransformImageStage returns the mapper used by transform steps.
func UploadImageStage ¶
func UploadImageStage( targetHTTPClient *http.Client, uploadEndpoint string, ) func(context.Context, ImageResult[[]byte]) ImageResult[string]
UploadImageStage returns the mapper used by the optional upload step.
Types ¶
type ImageCatalogEntry ¶
type ImageCatalogEntry struct {
ID string `json:"id"`
}
ImageCatalogEntry models the minimal response shape this example family needs from the Picsum list endpoint.
type ImageResult ¶
ImageResult carries either a successful value or an item-scoped failure for one image.
type ImageTransformer ¶
type ImageTransformer func(ctx context.Context, sourceURL string, imageBytes []byte) ([]byte, error)
ImageTransformer describes one pure image-processing step.
func AddWatermarkText ¶
func AddWatermarkText(text string) ImageTransformer
AddWatermarkText overlays a visible footer marker plus a tiny built-in bitmap text watermark.
func ResizeTo ¶
func ResizeTo(width int, height int) ImageTransformer
ResizeTo returns a transformer that resizes images with a nearest-neighbor strategy.
type PipelineConfig ¶
type PipelineConfig struct {
ListEndpoint string
ListPageSize int
ListMaxPages int
LocalOutputDir string
DownloadWidth int
DownloadHeight int
DownloadWorkers int
DownloadRetryTimes int
DownloadRetryInterval time.Duration
DownloadAttemptTimeout time.Duration
WatermarkWorkers int
UploadWorkers int
ResizeWidth int
ResizeHeight int
WatermarkText string
UploadEndpoint string
}
PipelineConfig collects the knobs used by the image-processing examples. Zero or empty values fall back to small demo-friendly defaults.
func DefaultPipelineConfig ¶
func DefaultPipelineConfig(outputDir string) PipelineConfig
DefaultPipelineConfig returns the baseline image-processing example config.
type RemoteImage ¶
RemoteImage is the payload emitted by the listing stage and consumed by the download stage.