Documentation
¶
Overview ¶
Package objectobs observes the object operations the platform makes on the buckets it owns (#1896): portal assets, managed resources, thumbnails, a script's outputs, exports and webhook segments. Every put, get, list and delete is a client span named storage.<operation> and one storage_operations_total observation labeled by what the bucket is used for (its purpose), with a failure read into a reason class, so a credential or bucket-policy mistake reads differently from an outage.
The adapters that hold an S3 client (pkg/portal/s3adapter and the webhook objects) call Do around each operation with the purpose they were built for. A caller that writes for another purpose through a shared client -- the thumbnail worker through the portal's client, an export through it -- names that purpose on the context with WithPurpose, and the operation is reported under it.
Index ¶
- Constants
- func Do(ctx context.Context, fallback, op, bucket string, ...) (int64, error)
- func DoObject(ctx context.Context, fallback, op string, obj Object, ...) (int64, error)
- func Reason(err error) string
- func SetUsageRecorder(r UsageRecorder)
- func WithPurpose(ctx context.Context, purpose string) context.Context
- type Object
- type UsageRecorder
Constants ¶
const ( OpPut = "put" OpGet = "get" OpGetRange = "get_range" OpList = "list" OpDelete = "delete" )
The operations an object adapter reports.
Variables ¶
This section is empty.
Functions ¶
func Do ¶
func Do(ctx context.Context, fallback, op, bucket string, fn func(context.Context) (int64, error)) (int64, error)
Do runs one object operation under a client span and records it. fn returns the bytes it stored (zero for anything but a put) and its error, which Do returns unchanged. A put or delete of one named object goes through DoObject instead, so the bucket's usage moves with it.
func DoObject ¶ added in v1.143.0
func DoObject(ctx context.Context, fallback, op string, obj Object, fn func(context.Context) (int64, error)) (int64, error)
DoObject is Do for a put or delete of one object. Once it succeeds the usage recorder SetUsageRecorder installed is told: a put adds one object and the bytes it stored, a delete removes one object. A delete does not know the size it freed; the next full listing corrects the bytes (#1899).
func Reason ¶
Reason classifies a failed object operation: access_denied for a refused credential or policy, bucket_missing, quota_exceeded for a store that is full, not_found for an absent object, and other for everything else (a timeout, a refused connection, a server error). Empty for nil.
The S3 error code is read when the error chain carries one; the mcp-s3 client does not always wrap with %w, so the code is also looked for in the error text, where the SDK writes it.
func SetUsageRecorder ¶ added in v1.143.0
func SetUsageRecorder(r UsageRecorder)
SetUsageRecorder installs r as the recorder DoObject reports to; nil removes it.
Types ¶
type UsageRecorder ¶ added in v1.143.0
UsageRecorder is told of every object put or deleted through DoObject. internal/platform/capacity installs the one that keeps each bucket's shared usage row current between full listings.