Documentation
¶
Overview ¶
Package helper exposes the service-scoped S3MinIO SDK contracts.
Index ¶
- Constants
- Variables
- func GetPresignedURL(ctx context.Context, d Downloader, object string, userID, merchantID int64, ...) (string, error)
- func GetViewURL(ctx context.Context, v Viewer, object string, userID, merchantID int64, ...) (string, error)
- func ObserveProbe(started time.Time, probeName, transport string, code uint32) error
- type Client
- type DownloadRequest
- type DownloadResponse
- type Downloader
- type FileDownloadResponse
- type FileDownloader
- type HealthProber
- type HealthRequest
- type HealthResponse
- type ReadinessProber
- type ReadyRequest
- type ReadyResponse
- type StreamViewer
- type UploadRequest
- type UploadResponse
- type UploadResult
- func UploadByFile(ctx context.Context, u Uploader, userID, merchantID int64, ...) (*UploadResult, error)
- func UploadByMultipart(ctx context.Context, u Uploader, userID, merchantID int64, path string, ...) (*UploadResult, error)
- func UploadByRequest(ctx context.Context, u Uploader, req *UploadRequest) (*UploadResult, error)
- type Uploader
- type ViewRequest
- type ViewResponse
- type Viewer
Constants ¶
const CodeOK uint32 = 0
CodeOK is the gRPC status code for success (google.golang.org/grpc/codes.OK == 0).
Variables ¶
var ( ErrNilDownloadResponse = errors.New("s3minio download response is nil") ErrNilUploadResponse = errors.New("s3minio upload response is nil") ErrNilUploadData = errors.New("s3minio upload response data is nil") ErrNilHealthResponse = errors.New("s3minio health response is nil") ErrNilReadyResponse = errors.New("s3minio ready response is nil") ErrNilFileResponse = errors.New("s3minio download file response is nil") )
var ProbeObserveFunc func(started time.Time, probeName string, transport string, code uint32)
ProbeObserveFunc is an optional hook for health/readiness probe latency and outcomes. Services may assign this at init (e.g. to emit metrics or structured logs) without importing the concrete gRPC adapter. When nil, probes incur no extra work.
Functions ¶
func GetPresignedURL ¶
func GetViewURL ¶
Types ¶
type Client ¶
type Client interface {
Downloader
Uploader
Viewer
HealthProber
ReadinessProber
FileDownloader
StreamViewer
}
Client groups all supported S3MinIO helper capabilities.
type DownloadRequest ¶
type DownloadRequest struct {
Object string
Path string
Bucket string
Expires int32
UserID int64
MerchantID int64
}
DownloadRequest mirrors common s3minio DownloadRequest fields used by PayCloud services.
func BuildDownloadRequest ¶
func BuildDownloadRequest(object string, userID, merchantID int64, args ...interface{}) DownloadRequest
BuildDownloadRequest builds a download/presigned request from object, ids, and optional args. args[0]: path string; args[1]: bucket string; args[2]: expires int (>0).
type DownloadResponse ¶
DownloadResponse mirrors a unary Download RPC result (code/message/data).
type Downloader ¶
type Downloader interface {
Download(ctx context.Context, req *DownloadRequest) (*DownloadResponse, error)
}
Downloader abstracts the download/presigned operation.
type FileDownloadResponse ¶
type FileDownloadResponse struct {
Code uint32
Message string
Status string
Data []byte
ContentType string
Filename string
}
FileDownloadResponse represents HTTP download-file style payload.
func DownloadFileByRequest ¶
func DownloadFileByRequest(ctx context.Context, d FileDownloader, req *DownloadRequest) (*FileDownloadResponse, error)
type FileDownloader ¶
type FileDownloader interface {
DownloadFile(ctx context.Context, req *DownloadRequest) (*FileDownloadResponse, error)
}
FileDownloader abstracts download_file behavior.
type HealthProber ¶
type HealthProber interface {
Health(ctx context.Context, req *HealthRequest) (*HealthResponse, error)
}
HealthProber abstracts service liveness checks.
type HealthRequest ¶
type HealthRequest struct{}
HealthRequest is a transport-neutral liveness probe request.
func BuildHealthRequest ¶
func BuildHealthRequest() HealthRequest
BuildHealthRequest returns a default health probe request.
type HealthResponse ¶
HealthResponse represents liveness output from a provider or adapter.
func CheckHealth ¶
func CheckHealth(ctx context.Context, p HealthProber) (*HealthResponse, error)
type ReadinessProber ¶
type ReadinessProber interface {
Ready(ctx context.Context, req *ReadyRequest) (*ReadyResponse, error)
}
ReadinessProber abstracts dependency-readiness checks.
type ReadyRequest ¶
type ReadyRequest struct{}
ReadyRequest is a transport-neutral readiness probe request.
func BuildReadyRequest ¶
func BuildReadyRequest() ReadyRequest
BuildReadyRequest returns a default readiness probe request.
type ReadyResponse ¶
type ReadyResponse struct {
Code uint32
Message string
Status string
Dependencies map[string]string
}
ReadyResponse represents readiness output and optional dependency map.
func CheckReady ¶
func CheckReady(ctx context.Context, p ReadinessProber) (*ReadyResponse, error)
type StreamViewer ¶
type StreamViewer interface {
View(ctx context.Context, req *ViewRequest) (*ViewResponse, error)
}
StreamViewer abstracts HTTP stream view behavior.
type UploadRequest ¶
type UploadRequest struct {
Filename string
Size uint64
ContentType string
Content []byte
Bucket string
Path string
Expires uint32
UserID int64
MerchantID int64
}
UploadRequest mirrors common s3minio UploadRequest fields.
func BuildUploadRequestForFile ¶
func BuildUploadRequestForFile(userID, merchantID int64, path, fileLocation string, args ...interface{}) (UploadRequest, error)
BuildUploadRequestForFile reads a file from disk and builds an upload request. Optional args use the same convention as legacy merchant services: first string at index 0 is bucket; int at index 1 is expires.
func BuildUploadRequestForMultipart ¶
func BuildUploadRequestForMultipart(userID, merchantID int64, path string, file multipart.File, fileHeader *multipart.FileHeader, args ...interface{}) (UploadRequest, error)
BuildUploadRequestForMultipart builds an upload request from a multipart file. args[0]: bucket string; args[1]: expires int (>0) as uint32.
type UploadResponse ¶
type UploadResponse struct {
Code uint32
Status string
Message string
Data *UploadResult
}
UploadResponse mirrors an Upload RPC result (code/message + optional data).
type UploadResult ¶
UploadResult is the payload returned on successful upload.
func UploadByFile ¶
func UploadByMultipart ¶
func UploadByRequest ¶
func UploadByRequest(ctx context.Context, u Uploader, req *UploadRequest) (*UploadResult, error)
type Uploader ¶
type Uploader interface {
Upload(ctx context.Context, req *UploadRequest) (*UploadResponse, error)
}
Uploader abstracts the upload operation.
type ViewRequest ¶
type ViewRequest struct {
Path string
}
ViewRequest represents HTTP stream view request semantics.
func BuildViewRequest ¶
func BuildViewRequest(path string) ViewRequest
BuildViewRequest builds a view-stream request from path.
type ViewResponse ¶
type ViewResponse struct {
Code uint32
Message string
Status string
Data []byte
ContentType string
}
ViewResponse represents HTTP stream view response semantics.
type Viewer ¶
type Viewer interface {
GenerateViewURL(ctx context.Context, req *DownloadRequest) (*DownloadResponse, error)
}
Viewer abstracts generate-view-url operation.