remotefile

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package remotefile adapts provider-owned file transports to Braidplane's shared file connector execution contract.

Index

Constants

View Source
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

func OperationOrDefault(operation string) string

OperationOrDefault normalizes operation text and defaults empty operations to read.

func ReadAllLimited

func ReadAllLimited(reader io.Reader, maxBytes int64) ([]byte, error)

ReadAllLimited reads a provider stream while enforcing the supplied byte guardrail.

func SpreadsheetResultSheet

func SpreadsheetResultSheet(sheet string) string

SpreadsheetResultSheet reports the sheet name used in spreadsheet write results.

func SubstituteCommonParams

func SubstituteCommonParams(stmt *Statement, params map[string]any, targetField string) error

SubstituteCommonParams resolves placeholders in the shared target, sheet, and range fields.

func SubstituteMetadata

func SubstituteMetadata(metadata map[string]string, params map[string]any) error

SubstituteMetadata resolves placeholders in safe provider metadata values.

func SubstituteStringField

func SubstituteStringField(label string, value *string, params map[string]any) error

SubstituteStringField resolves placeholders in a connector-specific string field.

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.

const (
	ErrorKindUnexpected ErrorKind = iota
	ErrorKindInvalidQuery
)

type LimitPolicy

type LimitPolicy struct {
	UseHTTPFallbackForRead  bool
	UseHTTPFallbackForParse bool
}

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

type ReadResult struct {
	Content     []byte
	ContentType string
}

ReadResult carries bytes and safe provider metadata returned by a remote read.

type SchemaFile

type SchemaFile struct {
	Name      string
	Target    string
	SizeBytes *int64
}

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.

func (*Statement) SetTarget

func (stmt *Statement) SetTarget(fieldName, value string)

SetTarget updates the connector-specific path/key field used for provider access.

func (Statement) Target

func (stmt Statement) Target(fieldName string) string

Target returns the connector-specific path/key field used for provider access.

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.

Jump to

Keyboard shortcuts

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