cumiddleware

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HeaderRDMAToken is the single combined header sent by the real
	// cuObject client. Its value is a colon-delimited token per the
	// cuObj RDMA descriptor protocol. The whole token is passed through
	// verbatim to the RDMA backend as the descriptor.
	//
	// This is the canonical definition of the wire format; the encoder in
	// cuwrapper/rdma_host_client_wrapper.cpp (build_token) must stay in
	// sync with it. Fields, in order, colon-delimited, lowercase hex:
	//
	//   # | Field                                  | Type     | Width
	//   --|-----------------------------------------|----------|-----------
	//   1 | Remote base address (GPUMEM/SYSMEM)      | uint64   | 16 chars
	//   2 | Max size of buffer region from base addr | uint32   | 8 chars
	//   3 | Remote key (rkey)                        | uint32   | 8 chars
	//   4 | LID of the client NIC                    | uint16   | 4 chars
	//   5 | DCTN                                     | uint32   | 6 chars
	//   6 | GID present (1|0)                        | bool     | 1 char
	//   7 | GID of client NIC                        | 16 bytes | 32 chars
	//
	// Example: "0102030405060708:01020304:01020304:0102:010203:1:0102030405060708090a0b0c0d0e0f10"
	HeaderRDMAToken = "X-Amz-Rdma-Token"

	// HeaderRDMAReply is the response header sent after a successful
	// RDMA-offloaded PUT/GET, per NVIDIA's documented cuObject workflow:
	// "If the transfer is successfully offloaded to RDMA, the proxy responds
	// with x-amz-rdma-reply." This implementation carries a numeric RDMA
	// status code (e.g. HTTP-style 200/204/206 success classes) and is set
	// only after the RDMA operation has actually succeeded.
	HeaderRDMAReply = "X-Amz-Rdma-Reply"

	// HeaderRDMABytesTransferred is the statistics header documented
	// alongside HeaderRDMAToken/HeaderRDMAReply ("x-amz-rdma-bytes-transferred
	// (for statistics)"). This header carries the numeric transferred-byte
	// count and is set together with HeaderRDMAReply — see SetRDMAReplyHeader.
	HeaderRDMABytesTransferred = "X-Amz-Rdma-Bytes-Transferred"
)

Header names used by the cuObject client to pass RDMA descriptor info.

Variables

This section is empty.

Functions

func CuObjMiddleware

func CuObjMiddleware(ctx fiber.Ctx) error

CuObjMiddleware extracts cuObject RDMA headers and stores them in the fasthttp request context so the backend can retrieve them via the GetRDMA* helper functions.

If the combined RDMA token header is not present, the request passes through unchanged — the backend will use the normal (non-RDMA) code path.

If a descriptor is present but required fields are malformed, a 400 Bad Request is returned immediately.

func GetRDMADescriptor

func GetRDMADescriptor(ctx context.Context) (string, bool)

GetRDMADescriptor retrieves the RDMA descriptor from the context. Returns ("", false) if the request is not an RDMA-accelerated request.

func GetRDMARemoteStart

func GetRDMARemoteStart(ctx context.Context) uint64

GetRDMARemoteStart retrieves the remote buffer start address from the context. Defaults to 0 if not set.

func GetRDMASize

func GetRDMASize(ctx context.Context) (int64, bool)

GetRDMASize retrieves the RDMA content length from the context.

func InjectRDMAContext

func InjectRDMAContext(ctx context.Context, descr string, size int64, remoteStart uint64) context.Context

InjectRDMAContext returns a copy of ctx with RDMA descriptor values set. This bypasses the Fiber middleware and is intended for testing and direct backend invocation without an HTTP layer.

func SetRDMAReplyHeader

func SetRDMAReplyHeader(ctx context.Context, rdmaStatus int, transferredBytes int64)

SetRDMAReplyHeader sets the HeaderRDMAReply (status code) and HeaderRDMABytesTransferred (byte count) response headers, signaling to the client that the transfer was completed via RDMA rather than the HTTP body. Call only after the RDMA transfer has actually succeeded. ctx must be the same *fasthttp.RequestCtx handed to the backend by versitygw; it is a no-op otherwise (e.g. in unit tests without an HTTP layer).

Types

This section is empty.

Jump to

Keyboard shortcuts

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