processing

package
v0.0.0-...-9d9242c Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// InternalTemplatePreviewRenderPath is the private processing endpoint path
	// management calls for synchronous template preview renders.
	InternalTemplatePreviewRenderPath = "/internal/template-renders/preview"

	// InternalProcessingUsageBatchesPath is the private management endpoint path
	// processing nodes call to flush aggregated usage deltas.
	InternalProcessingUsageBatchesPath = "/internal/processing/usage-batches"

	// InternalAPISecretHeader carries the shared secret for internal management
	// to processing and processing to management requests.
	InternalAPISecretHeader = "X-Internal-API-Secret"

	// InternalTrafficQueryParam marks internally generated preview/browse traffic
	// so processing usage can classify it as non-billable.
	InternalTrafficQueryParam = "it"
)
View Source
const (
	PreviewPathPrefix    = "/preview/"
	PreviewTokenQuery    = "pt"
	PreviewTokenAudience = "processing-preview"
	PreviewTokenKind     = "editor-preview"
)
View Source
const InternalTrafficSignerTruncate = 32

Variables

This section is empty.

Functions

func AppendInternalTrafficSignature

func AppendInternalTrafficSignature(rawURL, canonicalPath, secret string) string

func CanonicalImagorPathFromRequestPath

func CanonicalImagorPathFromRequestPath(requestPath string) (string, bool)

func ResolveProcessingBaseURL

func ResolveProcessingBaseURL(template, spaceKey string) string

func SignInternalTraffic

func SignInternalTraffic(canonicalPath, secret string) string

func VerifyInternalTrafficRequest

func VerifyInternalTrafficRequest(r *http.Request, secret string) bool

func WithRequestMetadata

func WithRequestMetadata(ctx context.Context, metadata RequestMetadata) context.Context

Types

type HTTPTemplatePreviewRenderClient

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

func NewHTTPTemplatePreviewRenderClient

func NewHTTPTemplatePreviewRenderClient(baseURL, internalAPISecret string) *HTTPTemplatePreviewRenderClient

func (*HTTPTemplatePreviewRenderClient) RenderTemplatePreview

type NodeConfig

type NodeConfig struct {
	Runtime RuntimeConfig
}

type NodeHooks

type NodeHooks struct {
	ProcessorDecorator ProcessorDecorator
	UsageRecorder      UsageRecorder
	Processors         []imagor.Processor
}

type ProcessorDecorator

type ProcessorDecorator interface {
	WrapProcessor(next imagor.Processor) imagor.Processor
}

type RequestMetadata

type RequestMetadata struct {
	OrgID   string
	SpaceID string
	Class   UsageClass
}

func MarkRecorded

func MarkRecorded(ctx context.Context) (RequestMetadata, bool)

func RequestMetadataFromContext

func RequestMetadataFromContext(ctx context.Context) (RequestMetadata, bool)

type RuntimeConfig

type RuntimeConfig struct {
	SpacesEndpoint            string
	InternalAPISecret         string
	SpaceBaseDomain           string
	S3HTTPMaxIdleConnsPerHost int
}

type RuntimeFactory

type RuntimeFactory = func(runtimeCfg RuntimeConfig, logger *zap.Logger) (SpaceConfigReader, imagor.Loader, error)

type SpaceConfig

type SpaceConfig interface {
	GetOrgID() string
	GetKey() string
	GetPrefix() string
	GetBucket() string
	GetRegion() string
	GetEndpoint() string
	GetAccessKeyID() string
	GetSecretKey() string
	GetUsePathStyle() bool
	GetCustomDomain() string
	IsSuspended() bool
	GetSignerAlgorithm() string
	GetSignerTruncate() int
	GetImagorSecret() string
	GetImagorCORSOrigins() []string
}

func ResolveSpaceFromHost

func ResolveSpaceFromHost(store SpaceConfigReader, host, baseDomain string) SpaceConfig

type SpaceConfigReader

type SpaceConfigReader interface {
	Get(key string) (SpaceConfig, bool)
	GetByHostname(hostname string) (SpaceConfig, bool)
	Start(ctx context.Context) error
	Ready() bool
}

type TemplatePreviewRenderClient

type TemplatePreviewRenderClient interface {
	RenderTemplatePreview(ctx context.Context, req TemplatePreviewRenderRequest) (*TemplatePreviewRenderResponse, error)
}

TemplatePreviewRenderClient is implemented by management-side clients that call a private processing endpoint for synchronous template preview renders.

type TemplatePreviewRenderRequest

type TemplatePreviewRenderRequest struct {
	SpaceKey        string
	SourceImagePath string
	TemplateJSON    string
	PreviewParams   imagorpath.Params
}

TemplatePreviewRenderRequest describes the synchronous preview render input management can send to a processing node.

type TemplatePreviewRenderResponse

type TemplatePreviewRenderResponse struct {
	Image       []byte
	ContentType string
}

TemplatePreviewRenderResponse carries the rendered preview image bytes.

type UsageBatch

type UsageBatch struct {
	NodeID  string           `json:"node_id"`
	BatchID string           `json:"batch_id"`
	SentAt  time.Time        `json:"sent_at"`
	Items   []UsageBatchItem `json:"items"`
}

type UsageBatchApplyResult

type UsageBatchApplyResult struct {
	Accepted       bool   `json:"accepted"`
	BatchID        string `json:"batch_id"`
	AlreadyApplied bool   `json:"already_applied"`
}

type UsageBatchItem

type UsageBatchItem struct {
	OrgID          string    `json:"org_id"`
	SpaceID        string    `json:"space_id"`
	BucketStartAt  time.Time `json:"bucket_start_at"`
	ProcessedCount int64     `json:"processed_count"`
}

type UsageClass

type UsageClass string
const (
	UsageClassBillableProduction  UsageClass = "billable_production"
	UsageClassInternalNonBillable UsageClass = "internal_non_billable"
)

type UsageRecorder

type UsageRecorder interface {
	RecordProcessed(ctx context.Context)
	Flush(ctx context.Context) error
}

Jump to

Keyboard shortcuts

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