Documentation
¶
Overview ¶
Package transport is the SDK's HTTP engine: request building (with auth and User-Agent), the retry loop, JSON decoding, and the CDN token cache. The feature packages (run, queue, stream, upload, realtime) are built on a *Core, which the top-level fal package constructs and shares among them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DrainAndClose ¶
DrainAndClose consumes and closes a response body so the connection can be reused.
func IsCanceled ¶
IsCanceled reports whether err is a context cancellation/deadline.
func WithTimeout ¶
WithTimeout derives a context bounded by d; if d <= 0 the parent is returned with a no-op cancel.
Types ¶
type AuthProvider ¶
AuthProvider supplies the Authorization header value for a request. It is implemented by *auth.Manager and injected into Core, so transport never imports the auth package.
type Config ¶
type Config struct {
HTTPClient *http.Client
DefaultTimeout time.Duration
// Base URLs (scheme+host, no trailing slash).
RunBase string
QueueBase string
RestBase string
CDNBase string
UserAgent string
Auth AuthProvider
}
Config carries the values Core needs at construction.
type Core ¶
type Core struct {
HTTPClient *http.Client
DefaultTimeout time.Duration
RunBase string
QueueBase string
RestBase string
CDNBase string
UserAgent string
Auth AuthProvider
// contains filtered or unexported fields
}
Core is the shared HTTP engine. Its fields are exported so the facade can build it and tests can override base URLs; they must be set once before first use and not mutated afterward. With that contract, Core is safe for concurrent use by multiple goroutines (the only post-construction writers are tests, before any request is issued).
func (*Core) Do ¶
Do executes req with exponential backoff + jitter. On a 2xx it returns the response with the body still open (the caller must close it). On a terminal non-2xx it returns a *errs.HTTPError. The request body, if any, is rewound between attempts via GetBody.
func (*Core) DoJSON ¶
DoJSON executes req with retries and unmarshals a 2xx JSON body into out (which may be nil to discard the body).
func (*Core) NewRequest ¶
func (c *Core) NewRequest(ctx context.Context, method, url string, body []byte, headers map[string]string) (*http.Request, error)
NewRequest builds a request with the auth and User-Agent headers applied. Bodies passed as []byte are rewindable so the retry loop can resend them.
type Token ¶
type Token struct {
BaseURL string
// contains filtered or unexported fields
}
Token is a short-lived credential for the fal CDN. BaseURL is exported because upload targets it; the token material itself stays unexported and is only emitted through AuthHeader.
func (Token) AuthHeader ¶
AuthHeader returns the Authorization header value for a CDN request.