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 ¶
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.
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 ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client transforms images with Imagor. It is safe for concurrent use.
func New ¶
New builds the client, which sends its requests with client, such as that of stdhttpclientfx.
func (*Client) Await ¶
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 ¶
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. |