stdimagorfx

package
v0.0.266 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package stdimagorfx provides a client of Imagor (https://docs.imagor.net), which transforms images as a service of its own, so no image is processed in Go.

No image passes through the service or its workers. Imagor downloads its input with a request that the caller pre-signs (stds3fx), and writes its result to its result storage, at a key it derives from the request: run it with an S3 result storage and the "digest" path style. Client.Render asks for a result with a HEAD request, which returns no body, and returns that key; callers then move the result into place within object storage, and wait for it with Client.Await, since Imagor writes it after it answers.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotDelivered = errors.New("stdimagorfx: result not delivered")

ErrNotDelivered reports that Imagor answered a transformation but its result did not arrive in object storage in time. Imagor writes it after it answers, and only logs when that fails.

View Source
var ErrRejected = errors.New("stdimagorfx: rejected")

ErrRejected reports that Imagor refused a transformation, such as of a source it cannot download or decode; sending it again fails the same way.

Functions

func Provide

func Provide() fx.Option

Provide wires the module. It needs the *http.Client of stdhttpclientfx.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client transforms images with Imagor. It is safe for concurrent use.

func New

func New(cfg Config, client *http.Client) *Client

New builds the client, which sends its requests with client, such as that of stdhttpclientfx.

func (*Client) Await

func (c *Client) Await(ctx context.Context, adopt func(context.Context) (bool, error)) error

Await calls adopt, which moves a result into place and reports whether it was there, until it reports that it was, backing off between calls. It fails with ErrNotDelivered once the delivery timeout passes, and with adopt's error when adopt fails before then.

func (*Client) Render

func (c *Client) Render(ctx context.Context, params imagorpath.Params) (string, error)

Render has Imagor transform as params describe, and returns the key, under Imagor's result storage base directory, that Imagor writes the result to: a hash of the request, as the "digest" path style makes it. The result arrives after Render returns; wait for it with Client.Await.

It fails with ErrRejected when Imagor refuses the request, such as when it cannot download or decode params.Image.

type Config

type Config struct {
	// URL is where the service reaches Imagor.
	URL string `env:"URL,required"`
	// Secret signs the requests to Imagor, which must have the same
	// IMAGOR_SECRET, so nobody else can have it transform images.
	Secret string `env:"SECRET,required"`
	// DeliveryTimeout is how long [Client.Await] waits for a result to arrive
	// in object storage after Imagor answered.
	DeliveryTimeout time.Duration `env:"DELIVERY_TIMEOUT" envDefault:"10s"`
}

Config configures the module, from the environment with the STDIMAGOR_ prefix.

Directories

Path Synopsis
Package stdimagortestfx provides the stdimagorfx client for tests, on an Imagor server of the fx app's own, so they need no Docker Compose or other prior setup.
Package stdimagortestfx provides the stdimagorfx client for tests, on an Imagor server of the fx app's own, so they need no Docker Compose or other prior setup.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL