Documentation
¶
Index ¶
- Constants
- func IsHTTPRetryableError(err error) bool
- type Base64
- type ChromedpClient
- type Clock
- type CloudflareClient
- type EthClient
- type EthClientDialer
- type FileSystem
- type HTTPClient
- type IO
- type ImageEncoder
- type JCS
- type JSON
- type RealBase64
- type RealChromedpClient
- func (c *RealChromedpClient) EmulateViewport(width, height int64) chromedp.EmulateAction
- func (c *RealChromedpClient) Evaluate(expr string, result interface{}, options ...chromedp.EvaluateOption) chromedp.EvaluateAction
- func (c *RealChromedpClient) FullScreenshot(result *[]byte, quality int) chromedp.Action
- func (c *RealChromedpClient) Navigate(url string) chromedp.NavigateAction
- func (c *RealChromedpClient) NewContext(ctx context.Context) (context.Context, context.CancelFunc)
- func (c *RealChromedpClient) NewExecAllocator(ctx context.Context, opts []chromedp.ExecAllocatorOption) (context.Context, context.CancelFunc)
- func (c *RealChromedpClient) Run(ctx context.Context, actions ...chromedp.Action) error
- func (c *RealChromedpClient) Sleep(duration time.Duration) chromedp.Action
- func (c *RealChromedpClient) WaitReady(sel string, waitReadyOpts ...chromedp.QueryOption) chromedp.QueryAction
- type RealClock
- func (c *RealClock) After(d time.Duration) <-chan time.Time
- func (c *RealClock) NewTicker(d time.Duration) *time.Ticker
- func (c *RealClock) Now() time.Time
- func (c *RealClock) Parse(layout, value string) (time.Time, error)
- func (c *RealClock) Since(t time.Time) time.Duration
- func (c *RealClock) Sleep(d time.Duration)
- func (c *RealClock) Unix(sec int64, nsec int64) time.Time
- type RealCloudflareClient
- func (c *RealCloudflareClient) GetImage(ctx context.Context, rc *cloudflare.ResourceContainer, id string) (cloudflare.Image, error)
- func (c *RealCloudflareClient) GetVideo(ctx context.Context, params cloudflare.StreamParameters) (cloudflare.StreamVideo, error)
- func (c *RealCloudflareClient) UploadImage(ctx context.Context, rc *cloudflare.ResourceContainer, ...) (cloudflare.Image, error)
- func (c *RealCloudflareClient) UploadVideoFromFile(ctx context.Context, params cloudflare.StreamUploadFileParameters) (cloudflare.StreamVideo, error)
- func (c *RealCloudflareClient) UploadVideoFromURL(ctx context.Context, params cloudflare.StreamUploadFromURLParameters) (cloudflare.StreamVideo, error)
- type RealEthClient
- func (c *RealEthClient) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
- func (c *RealEthClient) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
- func (c *RealEthClient) Close()
- func (c *RealEthClient) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)
- func (c *RealEthClient) FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error)
- func (c *RealEthClient) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
- func (c *RealEthClient) SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
- func (c *RealEthClient) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
- func (c *RealEthClient) TransactionSender(ctx context.Context, tx *types.Transaction, block common.Hash, index uint) (common.Address, error)
- type RealEthClientDialer
- type RealFileSystem
- func (f *RealFileSystem) Close(file *os.File) error
- func (f *RealFileSystem) Create(name string) (*os.File, error)
- func (f *RealFileSystem) CreateTemp(dir, pattern string) (*os.File, error)
- func (f *RealFileSystem) ReadFile(filePath string) ([]byte, error)
- func (f *RealFileSystem) Remove(name string) error
- func (f *RealFileSystem) TempDir() string
- func (f *RealFileSystem) WriteFile(file *os.File, data []byte) (int, error)
- type RealHTTPClient
- func (c *RealHTTPClient) GetAndUnmarshal(ctx context.Context, url string, result interface{}) error
- func (c *RealHTTPClient) GetBytes(ctx context.Context, url string, headers map[string]string) ([]byte, error)
- func (c *RealHTTPClient) GetPartialBytes(ctx context.Context, url string, maxBytes int) ([]byte, error)
- func (c *RealHTTPClient) GetPartialBytesNoRetry(ctx context.Context, url string, maxBytes int) ([]byte, error)
- func (c *RealHTTPClient) GetResponse(ctx context.Context, url string, headers map[string]string) (*http.Response, error)
- func (c *RealHTTPClient) GetResponseNoRetry(ctx context.Context, url string, headers map[string]string) (*http.Response, error)
- func (c *RealHTTPClient) Head(ctx context.Context, url string) (*http.Response, error)
- func (c *RealHTTPClient) HeadNoRetry(ctx context.Context, url string) (*http.Response, error)
- func (c *RealHTTPClient) PostBytes(ctx context.Context, url string, headers map[string]string, body io.Reader) ([]byte, error)
- func (c *RealHTTPClient) PostNoRetry(ctx context.Context, url string, headers map[string]string, body io.Reader) (*http.Response, error)
- type RealIO
- type RealImageEncoder
- type RealJCS
- type RealJSON
- type RealResvgClient
- type RealSignalR
- type RealVipsClient
- type RealXML
- type ResvgClient
- type SignalR
- type SignalRClient
- type VipsClient
- type VipsImage
- type VipsSource
- type XML
Constants ¶
const MAX_MESSAGE_SIZE = 1 * 1024 * 1024 // 1MB
Variables ¶
This section is empty.
Functions ¶
func IsHTTPRetryableError ¶ added in v0.5.0
IsHTTPRetryableError determines if an error is retryable for HTTP requests
Types ¶
type ChromedpClient ¶ added in v0.5.0
type ChromedpClient interface {
NewExecAllocator(ctx context.Context, opts []chromedp.ExecAllocatorOption) (context.Context, context.CancelFunc)
NewContext(ctx context.Context) (context.Context, context.CancelFunc)
Run(ctx context.Context, actions ...chromedp.Action) error
WaitReady(sel string, waitReadyOpts ...chromedp.QueryOption) chromedp.QueryAction
Sleep(duration time.Duration) chromedp.Action
EmulateViewport(width, height int64) chromedp.EmulateAction
FullScreenshot(result *[]byte, quality int) chromedp.Action
Evaluate(expr string, result interface{}, options ...chromedp.EvaluateOption) chromedp.EvaluateAction
}
ChromedpClient defines an interface for chromedp operations to enable mocking
func NewChromedpClient ¶ added in v0.5.0
func NewChromedpClient() ChromedpClient
type Clock ¶
type Clock interface {
Now() time.Time
Since(t time.Time) time.Duration
Sleep(d time.Duration)
Parse(layout, value string) (time.Time, error)
Unix(sec int64, nsec int64) time.Time
After(d time.Duration) <-chan time.Time
NewTicker(d time.Duration) *time.Ticker
}
Clock defines an interface for time operations to enable mocking
type CloudflareClient ¶
type CloudflareClient interface {
// UploadImage uploads a single image to Cloudflare Images
UploadImage(ctx context.Context, rc *cloudflare.ResourceContainer, params cloudflare.UploadImageParams) (cloudflare.Image, error)
// GetImage gets the details of an uploaded image, including variant URLs
GetImage(ctx context.Context, rc *cloudflare.ResourceContainer, id string) (cloudflare.Image, error)
// UploadVideoFromURL uploads a video to Cloudflare Stream via URL
UploadVideoFromURL(ctx context.Context, params cloudflare.StreamUploadFromURLParameters) (cloudflare.StreamVideo, error)
// UploadVideoFromFile uploads a video to Cloudflare Stream from a file path
UploadVideoFromFile(ctx context.Context, params cloudflare.StreamUploadFileParameters) (cloudflare.StreamVideo, error)
// GetVideo retrieves video details from Cloudflare Stream
GetVideo(ctx context.Context, params cloudflare.StreamParameters) (cloudflare.StreamVideo, error)
}
CloudflareClient defines an interface for Cloudflare Images and Stream API operations to enable mocking
func NewCloudflareClient ¶
func NewCloudflareClient(apiToken string) (CloudflareClient, error)
NewCloudflareClient creates a new real Cloudflare client
type EthClient ¶
type EthClient interface {
// SubscribeFilterLogs subscribes to filter logs
SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
// FilterLogs retrieves logs that match the filter query
FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error)
// BlockByNumber returns a block by number
BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
// HeaderByNumber returns a header by number
HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
// CallContract calls a contract function
CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
// CodeAt returns the code of the given account at the given block number
CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)
// TransactionReceipt returns the receipt of a transaction by transaction hash
TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
// TransactionSender returns the sender address of a transaction
TransactionSender(ctx context.Context, tx *types.Transaction, block common.Hash, index uint) (common.Address, error)
// Close closes the connection
Close()
}
EthClient defines an interface for Ethereum client operations to enable mocking
type EthClientDialer ¶
EthClientDialer defines an interface for dialing Ethereum clients
func NewEthClientDialer ¶
func NewEthClientDialer() EthClientDialer
NewEthClientDialer creates a new real Ethereum client dialer
type FileSystem ¶
type FileSystem interface {
// Create creates a file
Create(name string) (*os.File, error)
// CreateTemp creates a temporary file
CreateTemp(dir, pattern string) (*os.File, error)
// Remove removes a file
Remove(name string) error
// WriteFile writes data to a file
WriteFile(file *os.File, data []byte) (int, error)
// Close closes a file
Close(file *os.File) error
// ReadFile reads a file and returns its contents
ReadFile(filePath string) ([]byte, error)
// TempDir returns the temporary directory
TempDir() string
}
FileSystem defines an interface for filesystem operations to enable mocking
func NewFileSystem ¶
func NewFileSystem() FileSystem
type HTTPClient ¶
type HTTPClient interface {
// GetAndUnmarshal performs a GET request and unmarshals the response into result
GetAndUnmarshal(ctx context.Context, url string, result interface{}) error
// GetResponse performs a GET request and returns the full HTTP response
// The caller is responsible for checking status code and closing the response body
GetResponse(ctx context.Context, url string, headers map[string]string) (*http.Response, error)
// GetResponseNoRetry performs a GET request and returns the full HTTP response without retry
// The caller is responsible for checking status code and closing the response body
GetResponseNoRetry(ctx context.Context, url string, headers map[string]string) (*http.Response, error)
// GetBytes performs a GET request with custom headers and returns the response body
GetBytes(ctx context.Context, url string, headers map[string]string) ([]byte, error)
// GetPartialBytes performs a GET request with Range header to fetch partial content
// Returns the partial content as bytes
GetPartialBytes(ctx context.Context, url string, maxBytes int) ([]byte, error)
// GetPartialBytesNoRetry performs a GET request with Range header to fetch partial content without retry
// Returns the partial content as bytes
GetPartialBytesNoRetry(ctx context.Context, url string, maxBytes int) ([]byte, error)
// PostBytes performs a POST request and returns the response body as bytes
PostBytes(ctx context.Context, url string, headers map[string]string, body io.Reader) ([]byte, error)
// PostNoRetry performs a POST request with custom headers and returns the response without retry
PostNoRetry(ctx context.Context, url string, headers map[string]string, body io.Reader) (*http.Response, error)
// Head performs a HEAD request
// The caller is responsible for closing the response body
Head(ctx context.Context, url string) (*http.Response, error)
// HeadNoRetry performs a HEAD request without retry
HeadNoRetry(ctx context.Context, url string) (*http.Response, error)
}
HTTPClient defines an interface for HTTP client operations to enable mocking
func NewHTTPClient ¶
func NewHTTPClient(timeout time.Duration) HTTPClient
NewHTTPClient creates a new real HTTP client
type ImageEncoder ¶ added in v0.4.0
type ImageEncoder interface {
// EncodePNG encodes an image to PNG format
EncodePNG(w io.Writer, img image.Image) error
// EncodeJPEG encodes an image to JPEG format with specified quality
EncodeJPEG(w io.Writer, img image.Image, quality int) error
}
ImageEncoder defines an interface for encoding images
func NewImageEncoder ¶ added in v0.4.0
func NewImageEncoder() ImageEncoder
NewImageEncoder creates a new real image encoder
type JSON ¶
type JSON interface {
Marshal(v interface{}) ([]byte, error)
Unmarshal(data []byte, v interface{}) error
}
JSON defines an interface for JSON operations to enable mocking
type RealBase64 ¶
type RealBase64 struct{}
func (*RealBase64) Encode ¶
func (b *RealBase64) Encode(data []byte) string
type RealChromedpClient ¶ added in v0.5.0
type RealChromedpClient struct{}
func (*RealChromedpClient) EmulateViewport ¶ added in v0.5.0
func (c *RealChromedpClient) EmulateViewport(width, height int64) chromedp.EmulateAction
func (*RealChromedpClient) Evaluate ¶ added in v0.5.0
func (c *RealChromedpClient) Evaluate(expr string, result interface{}, options ...chromedp.EvaluateOption) chromedp.EvaluateAction
func (*RealChromedpClient) FullScreenshot ¶ added in v0.5.0
func (c *RealChromedpClient) FullScreenshot(result *[]byte, quality int) chromedp.Action
func (*RealChromedpClient) Navigate ¶ added in v0.5.0
func (c *RealChromedpClient) Navigate(url string) chromedp.NavigateAction
func (*RealChromedpClient) NewContext ¶ added in v0.5.0
func (c *RealChromedpClient) NewContext(ctx context.Context) (context.Context, context.CancelFunc)
func (*RealChromedpClient) NewExecAllocator ¶ added in v0.5.0
func (c *RealChromedpClient) NewExecAllocator(ctx context.Context, opts []chromedp.ExecAllocatorOption) (context.Context, context.CancelFunc)
func (*RealChromedpClient) Sleep ¶ added in v0.5.0
func (c *RealChromedpClient) Sleep(duration time.Duration) chromedp.Action
func (*RealChromedpClient) WaitReady ¶ added in v0.5.0
func (c *RealChromedpClient) WaitReady(sel string, waitReadyOpts ...chromedp.QueryOption) chromedp.QueryAction
type RealCloudflareClient ¶
type RealCloudflareClient struct {
// contains filtered or unexported fields
}
RealCloudflareClient implements CloudflareClient using the official Cloudflare SDK
func (*RealCloudflareClient) GetImage ¶
func (c *RealCloudflareClient) GetImage(ctx context.Context, rc *cloudflare.ResourceContainer, id string) (cloudflare.Image, error)
GetImage gets the details of an uploaded image
func (*RealCloudflareClient) GetVideo ¶
func (c *RealCloudflareClient) GetVideo(ctx context.Context, params cloudflare.StreamParameters) (cloudflare.StreamVideo, error)
GetVideo retrieves video details from Cloudflare Stream
func (*RealCloudflareClient) UploadImage ¶
func (c *RealCloudflareClient) UploadImage(ctx context.Context, rc *cloudflare.ResourceContainer, params cloudflare.UploadImageParams) (cloudflare.Image, error)
UploadImage uploads a single image to Cloudflare Images
func (*RealCloudflareClient) UploadVideoFromFile ¶
func (c *RealCloudflareClient) UploadVideoFromFile(ctx context.Context, params cloudflare.StreamUploadFileParameters) (cloudflare.StreamVideo, error)
UploadVideoFromFile uploads a video to Cloudflare Stream from a file path
func (*RealCloudflareClient) UploadVideoFromURL ¶
func (c *RealCloudflareClient) UploadVideoFromURL(ctx context.Context, params cloudflare.StreamUploadFromURLParameters) (cloudflare.StreamVideo, error)
UploadVideoFromURL uploads a video to Cloudflare Stream via URL
type RealEthClient ¶ added in v0.5.0
type RealEthClient struct {
// contains filtered or unexported fields
}
RealEthClient wraps the ethclient.Client with retry logic
func NewRealEthClient ¶ added in v0.5.0
func NewRealEthClient(client *ethclient.Client, url string) *RealEthClient
NewRealEthClient creates a new RealEthClient
func (*RealEthClient) BlockByNumber ¶ added in v0.5.0
BlockByNumber returns a block by number with retry logic
func (*RealEthClient) CallContract ¶ added in v0.5.0
func (c *RealEthClient) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
CallContract calls a contract function with retry logic
func (*RealEthClient) Close ¶ added in v0.5.0
func (c *RealEthClient) Close()
Close closes the connection
func (*RealEthClient) CodeAt ¶ added in v0.5.0
func (c *RealEthClient) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)
CodeAt returns the code of the given account at the given block number with retry logic
func (*RealEthClient) FilterLogs ¶ added in v0.5.0
func (c *RealEthClient) FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error)
FilterLogs retrieves logs that match the filter query with retry logic
func (*RealEthClient) HeaderByNumber ¶ added in v0.5.0
HeaderByNumber returns a header by number with retry logic
func (*RealEthClient) SubscribeFilterLogs ¶ added in v0.5.0
func (c *RealEthClient) SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
SubscribeFilterLogs subscribes to filter logs with retry logic
func (*RealEthClient) TransactionReceipt ¶ added in v0.5.0
func (c *RealEthClient) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
TransactionReceipt returns the receipt of a transaction by transaction hash with retry logic
func (*RealEthClient) TransactionSender ¶ added in v0.5.0
func (c *RealEthClient) TransactionSender(ctx context.Context, tx *types.Transaction, block common.Hash, index uint) (common.Address, error)
TransactionSender returns the sender address of a transaction with retry logic
type RealEthClientDialer ¶
type RealEthClientDialer struct{}
RealEthClientDialer implements EthClientDialer using the standard ethclient package
type RealFileSystem ¶
type RealFileSystem struct{}
func (*RealFileSystem) CreateTemp ¶ added in v0.5.0
func (f *RealFileSystem) CreateTemp(dir, pattern string) (*os.File, error)
func (*RealFileSystem) ReadFile ¶
func (f *RealFileSystem) ReadFile(filePath string) ([]byte, error)
func (*RealFileSystem) Remove ¶
func (f *RealFileSystem) Remove(name string) error
func (*RealFileSystem) TempDir ¶
func (f *RealFileSystem) TempDir() string
type RealHTTPClient ¶
type RealHTTPClient struct {
// contains filtered or unexported fields
}
RealHTTPClient implements HTTPClient using the standard http package
func (*RealHTTPClient) GetAndUnmarshal ¶ added in v0.5.0
func (c *RealHTTPClient) GetAndUnmarshal(ctx context.Context, url string, result interface{}) error
GetAndUnmarshal performs a GET request and unmarshals the response into result Implements exponential backoff retry for rate limiting (429) responses
func (*RealHTTPClient) GetBytes ¶ added in v0.5.0
func (c *RealHTTPClient) GetBytes(ctx context.Context, url string, headers map[string]string) ([]byte, error)
GetBytes performs a GET request with custom headers and returns the response body Implements exponential backoff retry for rate limiting (429) responses
func (*RealHTTPClient) GetPartialBytes ¶ added in v0.5.0
func (c *RealHTTPClient) GetPartialBytes(ctx context.Context, url string, maxBytes int) ([]byte, error)
GetPartialBytes performs a GET request with Range header to fetch partial content Returns the partial content as bytes
func (*RealHTTPClient) GetPartialBytesNoRetry ¶ added in v0.5.0
func (c *RealHTTPClient) GetPartialBytesNoRetry(ctx context.Context, url string, maxBytes int) ([]byte, error)
GetPartialBytesNoRetry performs a GET request with Range header to fetch partial content without retry Returns the partial content as bytes
func (*RealHTTPClient) GetResponse ¶ added in v0.5.0
func (c *RealHTTPClient) GetResponse(ctx context.Context, url string, headers map[string]string) (*http.Response, error)
GetResponse performs a GET request and returns the full HTTP response The caller is responsible for checking status code and closing the response body
func (*RealHTTPClient) GetResponseNoRetry ¶ added in v0.5.0
func (c *RealHTTPClient) GetResponseNoRetry(ctx context.Context, url string, headers map[string]string) (*http.Response, error)
GetResponseNoRetry performs a GET request and returns the full HTTP response without retry The caller is responsible for checking status code and closing the response body
func (*RealHTTPClient) Head ¶
Head performs a HEAD request The caller is responsible for closing the response body
func (*RealHTTPClient) HeadNoRetry ¶ added in v0.5.0
HeadNoRetry performs a HEAD request without retry
func (*RealHTTPClient) PostBytes ¶ added in v0.5.0
func (c *RealHTTPClient) PostBytes(ctx context.Context, url string, headers map[string]string, body io.Reader) ([]byte, error)
PostBytes performs a POST request and returns the response body Implements exponential backoff retry for rate limiting (429) responses
type RealIO ¶ added in v0.4.0
type RealIO struct{}
RealIO implements IO using the standard io package
type RealImageEncoder ¶ added in v0.4.0
type RealImageEncoder struct{}
RealImageEncoder implements ImageEncoder using standard library
func (*RealImageEncoder) EncodeJPEG ¶ added in v0.4.0
EncodeJPEG encodes an image to JPEG format with specified quality
type RealJSON ¶
type RealJSON struct{}
RealJSON implements JSON using the standard encoding/json package
type RealResvgClient ¶ added in v0.4.0
type RealResvgClient struct{}
RealResvgClient implements ResvgClient using the actual resvg library
type RealSignalR ¶
type RealSignalR struct{}
RealSignalR implements SignalR using the standard signalr package
func (*RealSignalR) NewClient ¶
func (s *RealSignalR) NewClient(ctx context.Context, address string, receiver interface{}) (SignalRClient, error)
type RealVipsClient ¶ added in v0.5.0
type RealVipsClient struct{}
RealVipsClient implements VipsClient using the actual vipsgen/vips library
func (*RealVipsClient) NewImageFromSource ¶ added in v0.5.0
func (v *RealVipsClient) NewImageFromSource(source VipsSource, options *vips.LoadOptions) (VipsImage, error)
func (*RealVipsClient) NewSource ¶ added in v0.5.0
func (v *RealVipsClient) NewSource(reader io.ReadCloser) VipsSource
func (*RealVipsClient) Shutdown ¶ added in v0.5.0
func (v *RealVipsClient) Shutdown()
func (*RealVipsClient) Startup ¶ added in v0.5.0
func (v *RealVipsClient) Startup(config *vips.Config)
type ResvgClient ¶ added in v0.4.0
type ResvgClient interface {
// Render renders SVG data to an image with specified width (0 = use SVG natural size)
// Uses ScaleBestFit mode to maintain aspect ratio
Render(data []byte, width int) (image.Image, error)
}
ResvgClient defines an interface for SVG rendering using resvg
func NewResvgClient ¶ added in v0.4.0
func NewResvgClient() ResvgClient
NewResvgClient creates a new real resvg client
type SignalR ¶
type SignalR interface {
NewClient(ctx context.Context, address string, receiver interface{}) (SignalRClient, error)
}
SignalR defines an interface for creating SignalR clients
type SignalRClient ¶
type SignalRClient interface {
Start()
Send(target string, args ...interface{}) <-chan error
Stop()
}
SignalRClient defines an interface for SignalR client operations to enable mocking
type VipsClient ¶ added in v0.5.0
type VipsClient interface {
// Startup initializes libvips
Startup(config *vips.Config)
// Shutdown shuts down libvips
Shutdown()
// NewSource creates a new vips source from an io.ReadCloser
NewSource(reader io.ReadCloser) VipsSource
// NewImageFromSource loads an image from a source
NewImageFromSource(source VipsSource, options *vips.LoadOptions) (VipsImage, error)
}
VipsClient defines an interface for libvips operations to enable mocking
func NewVipsClient ¶ added in v0.5.0
func NewVipsClient() VipsClient
NewVipsClient creates a new real vips client implementation
type VipsImage ¶ added in v0.5.0
type VipsImage interface {
Width() int
Height() int
HasAlpha() bool
Pages() int
PageHeight() int
SetPageHeight(height int) error
Resize(scale float64, options *vips.ResizeOptions) error
ExtractArea(left, top, width, height int) error
JpegsaveBuffer(options *vips.JpegsaveBufferOptions) ([]byte, error)
WebpsaveBuffer(options *vips.WebpsaveBufferOptions) ([]byte, error)
GetInt(name string) (int, error)
SetInt(name string, i int)
GetArrayInt(name string) ([]int, error)
SetArrayInt(name string, values []int) error
GetFields() []string
Close()
}
VipsImage wraps vips.Image to provide a mockable interface
type VipsSource ¶ added in v0.5.0
type VipsSource interface {
Close()
}
VipsSource wraps vips.Source to provide a mockable interface