How minio/minio-go works
1. What this repository is
- This is a Go SDK/library, not a server application. Its main job is to let client programs talk to Amazon S3-compatible object storage and MinIO-specific extensions.
- The repository is organized around a single exported client API in the root package, with supporting packages under pkg/ for cross-cutting concerns.
2. Top-level architecture
- The root package contains the SDK surface: client creation, request construction, and all object/bucket operations.
- Most api-*.go files are grouped by S3 capability, so the codebase maps closely to S3 resources: buckets, objects, lifecycle, policies, encryption, replication, tagging, notifications, presigned URLs, and select/restore flows.
3. Client bootstrap and request pipeline
- api.go, core.go, endpoints.go, transport.go, constants.go, and utils.go form the core runtime path.
- A consumer creates a client with endpoint and options, then each API call builds an HTTP request, signs it, sends it through the configured transport, and decodes the response into SDK types or errors.
4. Authentication and signing boundary
- pkg/credentials is the credential provider layer. It supports multiple sources such as static credentials, environment variables, files, IAM-style flows, and STS/web identity/custom identity variants.
- pkg/signer contains the request-signing implementations for Signature V2, V4, and streaming variants. This is a hard boundary: the rest of the SDK relies on signed requests but does not embed auth logic directly.
5. HTTP transport and retry behavior
- transport.go, retry.go, and retry-continous.go control network behavior, including request execution, retries, and error handling.
- This layer is important for architecture diagrams because it sits between all operations and the storage service; every bucket/object API depends on it.
6. Object and bucket operations
- The dominant subsystem is the S3 API surface in the root package:
- Bucket lifecycle: create/list/exist/remove.
- Object lifecycle: put/get/stat/copy/delete.
- Multipart, streaming, compose, append, file-based upload/download, and remove-many operations.
- These APIs are the primary business path of the SDK and are the main external contract consumers use.
7. Streaming, multipart, and file transfer paths
- Upload/download logic is split across api-put-object*.go, api-get-object*.go, api-compose-object.go, and related helpers.
- The data flow here is from io.Reader, files, or streams into request bodies, often with checksum/part-management logic; on download, responses are exposed as readers or written to files.
- Multipart and streaming support are central because they determine how large objects move through the SDK.
8. Presigned and policy-based access
- api-presigned.go and post-policy.go support generating signed URLs and POST policies without directly performing the transfer.
- This creates a distinct flow: the SDK can hand off access to external clients instead of acting as the data mover itself.
9. Bucket and object configuration subsystems
- Several feature-specific files represent storage metadata/configuration APIs:
- api-bucket-cors.go
- api-bucket-encryption.go
- api-bucket-lifecycle.go
- api-bucket-notification.go
- api-bucket-policy.go
- api-bucket-qos.go
- api-bucket-replication.go
- api-bucket-tagging.go
- api-bucket-versioning.go
- object lock/retention/legal hold/tagging APIs
- These are separate control-plane paths from the main data-plane object transfer operations.
10. Supporting domain packages under pkg/
- pkg/policy, pkg/lifecycle, pkg/notification, pkg/replication, pkg/tags, pkg/cors, and pkg/encrypt model and parse the configuration payloads used by the corresponding APIs.
- pkg/sse handles server-side encryption metadata, and pkg/s3utils contains shared S3-specific helpers.
- These packages are mostly data/format boundaries: they convert between Go structures and the XML/JSON-ish shapes expected by S3/MinIO.
11. Caching and concurrency helpers
- bucket-cache.go, pkg/kvcache, and pkg/singleflight provide internal optimization primitives for repeated lookups and coordinated requests.
- These are not the main API surface, but they affect runtime behavior by reducing duplicate work and smoothing concurrent access patterns.
12. Error model and response decoding
- api-error-response.go, s3-error.go, 200OKwithError_test.go, and related tests show that the SDK explicitly handles non-trivial S3 responses, including “successful HTTP status with embedded error” cases.
- This is important architecturally because response handling is not just status-code driven; the SDK has to parse service-specific error formats.
13. MinIO-specific extensions and advanced features
- rdma.go / rdma_stub.go, api-prompt-object.go, api-inventory-ext.go, and notification listeners under examples/minio represent extensions beyond standard S3.
- The cmd/rdma-test binary and the RDMA workflow indicate optional transport/path behavior that is gated by platform or build support.
14. Examples, tests, and CI as usage documentation
- examples/s3 and examples/minio are effectively a secondary architecture layer showing supported flows: bucket admin, object CRUD, encryption, replication, notifications, presigned access, and streaming.
- The many *_test.go files plus GitHub Actions workflows indicate the SDK is validated across standard Go builds, Windows, RDMA-specific paths, and vulnerability checks.
15. How to draw the diagram
- The clearest diagram is: application code → root MinIO client → auth/signing + transport/retry → S3/MinIO endpoint, with side branches for credentials providers, configuration/domain packages, and special flows like presigned URLs, notifications, multipart streaming, and MinIO extensions.
Main entry points: api.go Client API · core.go Core Flow · rdma.go MinIO Extensions · api-bucket-policy.go Bucket Ops
Components 19
Root SDK
Public client API and the core request/response pipeline in the root package.
- Client API · Root package entrypoint for creating clients and exposing bucket/object operations.
api.go - Core Flow · Client setup, endpoint resolution, request construction, and response decoding.
core.go - Bucket Ops · Bucket lifecycle and configuration operations such as create, list, policy, versioning, lifecycle, encryption, replication, tagging, CORS, and notifications.
api-bucket-policy.go - Object Ops · Primary object lifecycle operations including put, get, stat, copy, delete, list, remove-many, and file-based transfer helpers.
api-put-object.go - Transfer Paths · Multipart upload, streaming upload, compose, append, and download/file-transfer flows for large objects.
api-put-object-multipart.go - Access Flows · Presigned URLs and POST policy generation for delegated access without performing the transfer directly.
api-presigned.go - Object Config · Object lock, retention, legal hold, tagging, and encryption update operations.
api-object-lock.go - Error Model · S3 error decoding and special handling for successful HTTP responses that still contain embedded errors.
api-error-response.go
Auth
Credential providers and request signing boundaries.
- Credentials · Credential source selection across static, environment, file, IAM, and STS/web-identity variants.
pkg/credentials/credentials.go - Signers · Request signing implementations for Signature V2, Signature V4, and streaming signatures.
pkg/signer/request-signature-v4.go
Domain Models
Shared S3/MinIO configuration and metadata packages.
Runtime
Transport, retry, caching, and concurrency helpers.
Extensions
MinIO-specific and advanced flows beyond basic S3 object access.
- MinIO Extensions · MinIO-specific additions such as RDMA paths, prompt object support, inventory extensions, and session creation.
rdma.go
Usage
Examples and binaries that demonstrate the SDK flows.
- S3 Examples · Example programs showing standard bucket, object, presigned, encryption, multipart, and admin workflows.
examples/s3/putobject.go - MinIO Examples · Example programs for MinIO-specific flows such as notifications, replication metrics, fan-out, and snowball.
examples/minio/listen-notification.go - RDMA Test · Standalone RDMA test command for platform- or build-gated transport behavior.
cmd/rdma-test/main.go
Connections 22
- Client API → Core Flow: uses · The public client API delegates request setup and execution to the core pipeline.
- Core Flow → Credentials: loads · Client initialization resolves credentials through provider chains and identity sources.
- Core Flow → Signers: signs · Requests are signed before being sent to the storage service.
- Core Flow → Transport: sends · The core pipeline dispatches HTTP requests through the transport layer.
- Transport → Retry: wraps · Transport behavior is governed by retry and error-handling logic.
- Client API → Bucket Ops: exposes · Bucket-level control-plane methods are part of the root SDK surface.
- Client API → Object Ops: exposes · Object CRUD and listing operations are the main user-facing contract.
- Client API → Transfer Paths: exposes · Large-object transfer APIs build on the same client surface.
- Client API → Access Flows: exposes · Presigned URL and policy generation are available from the root package.
- Client API → Object Config: exposes · Object retention, lock, legal hold, tagging, and encryption APIs are exported from the client.
- Client API → Error Model: decodes · API calls normalize service failures through the SDK error model.
- Bucket Ops → S3 Models: serializes · Bucket configuration APIs use shared domain models and XML payload structures.
- Object Config → S3 Models: serializes · Object configuration endpoints reuse shared metadata models.
- Transfer Paths → S3 Utils: streams · Transfer paths use common helpers for checksums, part handling, and body setup.
- Access Flows → Signers: derives · Presigned URLs and POST policies depend on signing primitives.
- Bucket Ops → Caches: optimizes · Repeated bucket and lookup work is accelerated with caching and singleflight coordination.
- Object Ops → S3 Utils: uses · Object operations rely on shared S3 helper utilities.
- MinIO Extensions → Signers: depends on · Advanced MinIO features still rely on the same signing boundary.
- MinIO Extensions → Transport: extends · Optional RDMA and related features integrate with the request execution path.
- S3 Examples → Client API: demonstrates · S3 examples show consumer usage of the root client API.
- MinIO Examples → MinIO Extensions: demonstrates · MinIO examples focus on advanced MinIO-specific flows.
- RDMA Test → MinIO Extensions: exercises · The RDMA test binary validates the optional RDMA extension path.