Documentation
¶
Overview ¶
Package remotefile adapts provider-owned file transports to Braidplane's shared file connector execution contract.
Index ¶
- Constants
- func ApplyWriteParamOverrides(stmt *Statement, params map[string]any, opts WriteOverrideOptions)
- func OperationOrDefault(operation string) string
- func ReadAllLimited(reader io.Reader, maxBytes int64) ([]byte, error)
- func SpreadsheetResultSheet(sheet string) string
- func SubstituteCommonParams(stmt *Statement, params map[string]any, targetField string) error
- func SubstituteMetadata(metadata map[string]string, params map[string]any) error
- func SubstituteStringField(label string, value *string, params map[string]any) error
- type Adapter
- func (adapter Adapter) ExecuteOperation(ctx context.Context, provider Provider, target string, stmt Statement, ...) (*result.FileResult, error)
- func (adapter Adapter) ExecuteRead(ctx context.Context, provider Provider, target string, stmt Statement, ...) (*result.FileResult, error)
- func (adapter Adapter) ExecuteWrite(ctx context.Context, provider Provider, target string, stmt Statement, ...) (*result.FileResult, error)
- func (adapter Adapter) IntrospectSchema(ctx context.Context, provider SchemaProvider, opts SchemaOptions) (*filedata.Schema, error)
- func (adapter Adapter) SerializeWriteContent(stmt Statement, target string) ([]byte, filedata.QueryFormat, int, error)
- type ErrorKind
- type LimitPolicy
- type Provider
- type ReadResult
- type SchemaFile
- type SchemaOptions
- type SchemaProvider
- type Statement
- type StreamReader
- type StreamWriteRequest
- type StreamWriter
- type WriteOverrideOptions
- type WriteRequest
- type WriteResult
Constants ¶
const ( OperationRead = "read" OperationWrite = "write" )
Variables ¶
This section is empty.
Functions ¶
func ApplyWriteParamOverrides ¶
func ApplyWriteParamOverrides(stmt *Statement, params map[string]any, opts WriteOverrideOptions)
ApplyWriteParamOverrides lets runtime sink bindings override saved common write statement fields without provider-specific branching.
func OperationOrDefault ¶
OperationOrDefault normalizes operation text and defaults empty operations to read.
func ReadAllLimited ¶
ReadAllLimited reads a provider stream while enforcing the supplied byte guardrail.
func SpreadsheetResultSheet ¶
SpreadsheetResultSheet reports the sheet name used in spreadsheet write results.
func SubstituteCommonParams ¶
SubstituteCommonParams resolves placeholders in the shared target, sheet, and range fields.
func SubstituteMetadata ¶
SubstituteMetadata resolves placeholders in safe provider metadata values.
Types ¶
type Adapter ¶
type Adapter struct {
ConnectorName string
ErrorKind ErrorKind
LimitPolicy LimitPolicy
SchemaParsedColumns bool
}
Adapter contains the common Braidplane-owned remote-file behavior shared by provider-backed connectors.
func (Adapter) ExecuteOperation ¶
func (adapter Adapter) ExecuteOperation( ctx context.Context, provider Provider, target string, stmt Statement, limits types.ExecutionLimits, ) (*result.FileResult, error)
ExecuteOperation dispatches a normalized remote-file read or write operation.
func (Adapter) ExecuteRead ¶
func (adapter Adapter) ExecuteRead( ctx context.Context, provider Provider, target string, stmt Statement, limits types.ExecutionLimits, ) (*result.FileResult, error)
ExecuteRead fetches remote bytes through the provider and normalizes them into a file result.
func (Adapter) ExecuteWrite ¶
func (adapter Adapter) ExecuteWrite( ctx context.Context, provider Provider, target string, stmt Statement, limits ...types.ExecutionLimits, ) (*result.FileResult, error)
ExecuteWrite serializes statement content, writes it through the provider, and normalizes metadata.
func (Adapter) IntrospectSchema ¶
func (adapter Adapter) IntrospectSchema( ctx context.Context, provider SchemaProvider, opts SchemaOptions, ) (*filedata.Schema, error)
IntrospectSchema samples provider-listed files and maps them into normalized schema metadata.
func (Adapter) SerializeWriteContent ¶
func (adapter Adapter) SerializeWriteContent( stmt Statement, target string, ) ([]byte, filedata.QueryFormat, int, error)
SerializeWriteContent converts remote-file write content into provider bytes.
type ErrorKind ¶
type ErrorKind int
ErrorKind selects the xerror sentinel used for adapter-owned validation failures.
type LimitPolicy ¶
LimitPolicy captures existing connector differences in how byte limits are applied.
type Provider ¶
type Provider interface {
ReadFile(context.Context, string, int64) (*ReadResult, error)
WriteFile(context.Context, WriteRequest) (*WriteResult, error)
}
Provider performs protocol-owned remote file operations for one connector.
type ReadResult ¶
ReadResult carries bytes and safe provider metadata returned by a remote read.
type SchemaFile ¶
SchemaFile names one provider file candidate and the target used to read it.
type SchemaOptions ¶
type SchemaOptions struct {
MaxBytes int64
}
SchemaOptions controls schema sampling guardrails and compatibility behavior.
type SchemaProvider ¶
type SchemaProvider interface {
ListFiles(context.Context) ([]SchemaFile, error)
ReadFile(context.Context, string, int64) (*ReadResult, error)
}
SchemaProvider lists and samples candidate files through a provider-owned transport.
type Statement ¶
type Statement struct {
Type string `json:"type,omitempty"`
Operation string `json:"operation,omitempty"`
Path string `json:"path,omitempty"`
Key string `json:"key,omitempty"`
Bucket string `json:"bucket,omitempty"`
Format filedata.QueryFormat `json:"format,omitempty"`
Delimiter string `json:"delimiter,omitempty"`
HasHeader *bool `json:"has_header,omitempty"`
Sheet string `json:"sheet,omitempty"`
Range string `json:"range,omitempty"`
Content any `json:"content,omitempty"`
Overwrite *bool `json:"overwrite,omitempty"`
ContentType string `json:"content_type,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
Branch string `json:"branch,omitempty"`
Message string `json:"message,omitempty"`
ContentSet bool `json:"-"`
}
Statement is the shared remote-file query shape after connector-specific JSON fields are decoded into a common Braidplane-owned contract.
func DecodeStatement ¶
func DecodeStatement(raw json.RawMessage) (Statement, error)
DecodeStatement unmarshals a remote-file statement and records whether content was explicitly supplied, including a JSON null.
type StreamReader ¶
type StreamReader interface {
ReadFileTo(context.Context, string, int64, io.Writer) (*filestream.Metadata, error)
}
StreamReader retains backpressure instead of materializing provider bodies.
type StreamWriteRequest ¶
type StreamWriteRequest struct {
Target string
Body io.Reader
Reference filepayload.Reference
ContentType string
Metadata map[string]string
Overwrite bool
}
StreamWriteRequest supplies verified retained input to a provider adapter.
type StreamWriter ¶
type StreamWriter interface {
WriteFileFrom(context.Context, StreamWriteRequest) (int64, error)
}
type WriteOverrideOptions ¶
type WriteOverrideOptions struct {
TargetParamName string
}
WriteOverrideOptions controls which runtime parameter names can override common write statement fields.
type WriteRequest ¶
type WriteRequest struct {
Target string
Content []byte
ContentType string
Metadata map[string]string
Overwrite bool
}
WriteRequest carries serialized bytes and safe metadata into a provider write.
type WriteResult ¶
type WriteResult struct {
WrittenBytes int
}
WriteResult reports provider-accepted write metadata.