Documentation
¶
Overview ¶
Package sink provides a typed, concurrency-safe Go client for the Sink gRPC service.
Index ¶
- func DeleteResultsError(results []DeleteResult) error
- func ReadResultsError(results []ReadResult) error
- func WriteResultsError(results []WriteResult) error
- type Address
- type BatchError
- type Client
- func (c *Client) CheckHealth(ctx context.Context) error
- func (c *Client) Close() error
- func (c *Client) Count(ctx context.Context, req CountRequest) (CountResponse, error)
- func (c *Client) Delete(ctx context.Context, req DeleteRequest) ([]DeleteResult, error)
- func (c *Client) Execute(ctx context.Context, req ExecuteRequest) (ExecuteResponse, error)
- func (c *Client) Query(ctx context.Context, req QueryRequest) (QueryResponse, error)
- func (c *Client) Raw() sinkv1.SinkClient
- func (c *Client) Read(ctx context.Context, req ReadRequest) ([]ReadResult, error)
- func (c *Client) Scan(ctx context.Context, req ScanRequest) (ScanResponse, error)
- func (c *Client) Write(ctx context.Context, req WriteRequest) ([]WriteResult, error)
- type ClientOptions
- type Command
- type CompletionMode
- type CountRequest
- type CountResponse
- type Dataset
- func (d *Dataset) Count(ctx context.Context, req CountRequest) (CountResponse, error)
- func (d *Dataset) Create(ctx context.Context, req DatasetWriteRequest) ([]WriteResult, error)
- func (d *Dataset) Execute(ctx context.Context, req ExecuteRequest) (ExecuteResponse, error)
- func (d *Dataset) Merge(ctx context.Context, req DatasetWriteRequest) ([]WriteResult, error)
- func (d *Dataset) NewBSONCommand(operation string, arguments bson.D) (Command, error)
- func (d *Dataset) Query(ctx context.Context, req QueryRequest) (QueryResponse, error)
- func (d *Dataset) Read(ctx context.Context, req DatasetReadRequest) ([]ReadResult, error)
- func (d *Dataset) Replace(ctx context.Context, req DatasetWriteRequest) ([]WriteResult, error)
- func (d *Dataset) Scan(ctx context.Context, req ScanRequest) (ScanResponse, error)
- func (d *Dataset) Upsert(ctx context.Context, req DatasetWriteRequest) ([]WriteResult, error)
- type DatasetOptions
- type DatasetReadRequest
- type DatasetWriteRequest
- type DeleteRequest
- type DeleteResult
- type DeleteStatus
- type DialOptions
- type Document
- type DocumentCallback
- type DocumentEncoding
- type ExecuteRequest
- type ExecuteResponse
- type FailureCode
- type Key
- type LuaProgram
- type MergeOptions
- type NativeError
- type OperationError
- type Projection
- type ProtocolError
- type QueryRequest
- func (r QueryRequest) WithCommand(command Command) QueryRequest
- func (r QueryRequest) WithOnDocument(callback DocumentCallback) QueryRequest
- func (r QueryRequest) WithPage(page int) QueryRequest
- func (r QueryRequest) WithPageSize(size int) QueryRequest
- func (r QueryRequest) WithProjection(projection *Projection) QueryRequest
- func (r QueryRequest) WithSort(fields ...SortField) QueryRequest
- type QueryResponse
- type ReadCallback
- type ReadRequest
- type ReadResult
- type ReadStatus
- type Record
- type RetryPolicy
- type ScanRequest
- func (r ScanRequest) WithBatchSize(size int) ScanRequest
- func (r ScanRequest) WithCommand(command Command) ScanRequest
- func (r ScanRequest) WithCursor(cursor []byte) ScanRequest
- func (r ScanRequest) WithOnDocument(callback DocumentCallback) ScanRequest
- func (r ScanRequest) WithProjection(projection *Projection) ScanRequest
- type ScanResponse
- type SortField
- type WriteCallback
- type WriteMode
- type WriteOperation
- type WriteRequest
- type WriteResult
- type WriteStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteResultsError ¶
func DeleteResultsError(results []DeleteResult) error
func ReadResultsError ¶
func ReadResultsError(results []ReadResult) error
func WriteResultsError ¶
func WriteResultsError(results []WriteResult) error
Types ¶
type Address ¶
type Address struct {
// contains filtered or unexported fields
}
Address wraps a canonical Store URI. Store adapters interpret the path.
func NewAddress ¶
func NewRecordAddress ¶
NewRecordAddress appends a typed key to a Store-owned resource URI.
type BatchError ¶
type BatchError struct {
Failures []*OperationError
}
BatchError collects per-operation failures while preserving errors.Is and errors.As traversal through every failure.
func (*BatchError) Error ¶
func (e *BatchError) Error() string
func (*BatchError) Unwrap ¶
func (e *BatchError) Unwrap() []error
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is safe for concurrent use.
func Dial ¶
func Dial(target string, opts DialOptions) (*Client, error)
Dial creates a lazily connected gRPC client with round-robin balancing across resolved addresses. Use a DNS target exposing backend addresses (for example a Kubernetes headless service) to distribute RPCs across replicas. Explicit GRPCOptions or resolver service configuration may override the default policy. DNS targets refresh at DNSRefreshInterval while the connection is active. Call CheckHealth when startup must prove the endpoint is reachable.
func New ¶
func New(connection grpc.ClientConnInterface, opts ClientOptions) (*Client, error)
New wraps an existing connection without taking ownership of it.
func (*Client) CheckHealth ¶
CheckHealth verifies that the server's standard gRPC health service reports SERVING.
func (*Client) Close ¶
Close closes connections created by Dial. It is a no-op for clients created with New because the caller owns that connection.
func (*Client) Count ¶
func (c *Client) Count(ctx context.Context, req CountRequest) (CountResponse, error)
Count counts matches before find/HTTP pagination, or after the supplied aggregate pipeline. MongoDB automatically uses metadata for ordinary empty find filters; other queries remain exact. Estimated identifies the strategy. Concurrent writes can make the count differ from a separately fetched page. The SDK never retries.
func (*Client) Delete ¶
func (c *Client) Delete(ctx context.Context, req DeleteRequest) ([]DeleteResult, error)
Delete permanently deletes records. Deleting an absent record is successful. Large collections are split automatically, and transport failures are not retried. Earlier batches may have completed when a later batch returns an error.
func (*Client) Execute ¶
func (c *Client) Execute(ctx context.Context, req ExecuteRequest) (ExecuteResponse, error)
Execute makes one native command request. The SDK never retries it. MongoDB cursor and session commands are rejected; use Scan for resumable find pages or Query for independent find/aggregate pages. The server validates supported commands and rejects search index lifecycle and alias management. Permitted native writes follow adapter safeguards. A database error returns both its response and a *NativeError. Transport failures return no database response and must not be assumed unapplied.
func (*Client) Query ¶
func (c *Client) Query(ctx context.Context, req QueryRequest) (QueryResponse, error)
Query fetches an independent page without retaining a cursor between calls. Use a stable native sort with a unique tie-breaker. Concurrent writes can shift pages; deep pages are subject to backend offset costs and result-window limits. HasMore uses one extra result. Query never automatically runs Count or retries. An optional callback receives documents without collecting them in Documents. HasMore is valid only when the stream finishes successfully.
func (*Client) Raw ¶
func (c *Client) Raw() sinkv1.SinkClient
Raw returns the generated gRPC client for advanced or forward-compatible usage.
func (*Client) Read ¶
func (c *Client) Read(ctx context.Context, req ReadRequest) ([]ReadResult, error)
Read collects results in request order, or passes them in arrival order to an optional callback without collecting them. It automatically splits large collections into configured operation-count batches. Transport-level Unavailable errors and retryable per-operation failures are retried because reads are idempotent. Returned operation indexes refer to the original collection.
func (*Client) Scan ¶
func (c *Client) Scan(ctx context.Context, req ScanRequest) (ScanResponse, error)
Scan returns one live page without retaining a server session. Reuse Command and Projection, and pass NextCursor back after processing Documents. An empty NextCursor marks the end observed by this request. Cursors do not expire and survive server restarts. Concurrent changes can affect pages and retries. The SDK retries only explicitly marked temporary admission rejections, using the same request and cursor within ScanRetry and ScanTimeout. Checkpointing and idempotent processing belong to the caller. Cancellation of one request does not invalidate an existing cursor. An optional callback receives documents without collecting them in Documents. NextCursor is returned only after the stream finishes successfully.
func (*Client) Write ¶
func (c *Client) Write(ctx context.Context, req WriteRequest) ([]WriteResult, error)
Write submits mixed put and merge operations and automatically splits large collections into configured operation-count batches. It deliberately does not retry transport failures because the server may already have applied or durably accepted the mutation. Earlier batches may have completed when a later batch returns an error. Without a callback, acknowledged results are collected in request order. With a callback, results arrive incrementally and the returned result slice is nil.
type ClientOptions ¶
type ClientOptions struct {
MaxOperations int
ReadRetry RetryPolicy
ScanRetry RetryPolicy
// ScanTimeout bounds a whole page, including admission retries and backoff.
// Zero adds no deadline. A positive value is an explicit caller-selected
// page limit; a shorter context deadline wins.
ScanTimeout time.Duration
MaxReceiveMessageBytes int
MaxSendMessageBytes int
}
ClientOptions controls request limits and safe read retries.
type Command ¶
type Command struct {
URI string
Method string
Path string
Query string
Headers http.Header
ContentType string
Payload []byte
}
Command is shared by Execute, Query, Count and Scan. Store configuration selects the adapter; use only the fields that adapter needs. Payload contains native command or body bytes, never an additional Sink-specific envelope. URI identifies a resource; Path describes an operation relative to it.
func NewBSONCommand ¶
NewBSONCommand encodes an ordered document without opening a database connection. Use a struct, bson.D, or bson.Raw to preserve command field order. The Store interprets the target resource URI and command semantics.
type CompletionMode ¶
type CompletionMode = sinkv1.CompletionMode
const ( CompletionWaitUntilApplied CompletionMode = sinkv1.CompletionMode_COMPLETION_MODE_WAIT_UNTIL_APPLIED CompletionReturnAfterAccepted CompletionMode = sinkv1.CompletionMode_COMPLETION_MODE_RETURN_AFTER_ACCEPTED CompletionWaitUntilVisible CompletionMode = sinkv1.CompletionMode_COMPLETION_MODE_WAIT_UNTIL_VISIBLE )
type CountRequest ¶
type CountRequest struct {
Command Command
}
type CountResponse ¶
type Dataset ¶
type Dataset struct {
// contains filtered or unexported fields
}
Dataset binds record and native operations to one routing and encoding scope. Record methods return decoded results and a BatchError when any individual operation fails; native methods retain the corresponding Client semantics.
func NewDataset ¶
func NewDataset(client *Client, opts DatasetOptions) (*Dataset, error)
NewDataset binds stable dataset settings to a Client. MergeProgram is optional and is copied when configured.
func (*Dataset) Count ¶
func (d *Dataset) Count(ctx context.Context, req CountRequest) (CountResponse, error)
Count counts matches in this Dataset. An empty Command counts all records; ordinary unfiltered MongoDB counts automatically use collection metadata.
func (*Dataset) Create ¶
func (d *Dataset) Create(ctx context.Context, req DatasetWriteRequest) ([]WriteResult, error)
Create writes complete documents only when their keys do not already exist.
func (*Dataset) Execute ¶
func (d *Dataset) Execute(ctx context.Context, req ExecuteRequest) (ExecuteResponse, error)
Execute binds a native command to this Dataset's resource URI. The Store interprets the resource path and validates the command against that resource.
func (*Dataset) Merge ¶
func (d *Dataset) Merge(ctx context.Context, req DatasetWriteRequest) ([]WriteResult, error)
Merge atomically applies the Dataset's bound Lua program to every incoming record, creating a record when none exists. A Dataset without MergeProgram rejects Merge before sending an RPC.
func (*Dataset) NewBSONCommand ¶
NewBSONCommand encodes a collection command for this Dataset. Arguments contain only the remaining command fields, e.g. filter, pipeline or indexes. The Store binds the empty collection placeholder using the resource URI. Ordered arguments and native BSON types are retained.
func (*Dataset) Query ¶
func (d *Dataset) Query(ctx context.Context, req QueryRequest) (QueryResponse, error)
Query fetches a page from this Dataset. An empty Command selects all records. The Store selects its default query. Query controls and native payload semantics are the same as Client.Query.
func (*Dataset) Read ¶
func (d *Dataset) Read(ctx context.Context, req DatasetReadRequest) ([]ReadResult, error)
Read fetches one or more records by key, splits large collections automatically, and treats not-found results as successful reads. Without a callback, results are collected in key order. With a callback, results arrive incrementally and the returned result slice is nil.
func (*Dataset) Replace ¶
func (d *Dataset) Replace(ctx context.Context, req DatasetWriteRequest) ([]WriteResult, error)
Replace writes complete documents only when their keys already exist.
func (*Dataset) Scan ¶
func (d *Dataset) Scan(ctx context.Context, req ScanRequest) (ScanResponse, error)
Scan returns one live page scoped to this Dataset. Reuse the request with NextCursor to continue. JSON commands must provide a unique stable sort.
func (*Dataset) Upsert ¶
func (d *Dataset) Upsert(ctx context.Context, req DatasetWriteRequest) ([]WriteResult, error)
Upsert writes complete documents whether or not their keys already exist.
type DatasetOptions ¶
type DatasetOptions struct {
URI string
Encoding DocumentEncoding
MergeProgram *LuaProgram
}
DatasetOptions binds the stable routing, encoding, and optional merge program shared by records in one logical dataset. Completion mode remains a per-call choice because callers of the same dataset can require different durability and visibility guarantees.
type DatasetReadRequest ¶
type DatasetReadRequest struct {
Keys []Key
// OnResult has the same delivery and collection semantics as ReadRequest.OnResult.
OnResult ReadCallback
}
DatasetReadRequest selects keys within the Dataset's bound resource.
func NewDatasetReadRequest ¶
func NewDatasetReadRequest(keys ...Key) DatasetReadRequest
NewDatasetReadRequest selects keys to collect in request order by default.
func (DatasetReadRequest) WithOnResult ¶
func (r DatasetReadRequest) WithOnResult(callback ReadCallback) DatasetReadRequest
WithOnResult consumes results without collecting them. Nil restores collection.
type DatasetWriteRequest ¶
type DatasetWriteRequest struct {
// CompletionMode defaults to CompletionWaitUntilApplied when zero.
CompletionMode CompletionMode
Records []Record
// OnResult has the same delivery and collection semantics as WriteRequest.OnResult.
OnResult WriteCallback
}
DatasetWriteRequest supplies records for Create, Replace, Upsert or Merge. Routing, encoding and merge programs come from the Dataset.
func NewDatasetWriteRequest ¶
func NewDatasetWriteRequest(records ...Record) DatasetWriteRequest
NewDatasetWriteRequest supplies records with APPLIED completion by default.
func (DatasetWriteRequest) WithCompletionMode ¶
func (r DatasetWriteRequest) WithCompletionMode(mode CompletionMode) DatasetWriteRequest
WithCompletionMode selects when mutations are acknowledged. Zero means APPLIED.
func (DatasetWriteRequest) WithOnResult ¶
func (r DatasetWriteRequest) WithOnResult(callback WriteCallback) DatasetWriteRequest
WithOnResult consumes acknowledgements without collecting them. Nil restores collection.
type DeleteRequest ¶
type DeleteRequest struct {
// CompletionMode defaults to CompletionWaitUntilApplied when zero.
CompletionMode CompletionMode
Addresses []Address
}
DeleteRequest permanently deletes records with one completion mode.
func NewDeleteRequest ¶
func NewDeleteRequest(addresses ...Address) DeleteRequest
NewDeleteRequest deletes records with APPLIED completion by default.
func (DeleteRequest) WithCompletionMode ¶
func (r DeleteRequest) WithCompletionMode(mode CompletionMode) DeleteRequest
WithCompletionMode selects when deletes are acknowledged. Zero means APPLIED.
type DeleteResult ¶
type DeleteResult struct {
OperationIndex int
Status DeleteStatus
Failure *OperationError
}
func (DeleteResult) Err ¶
func (r DeleteResult) Err() error
type DeleteStatus ¶
type DeleteStatus = sinkv1.DeleteStatus
const ( DeleteAccepted DeleteStatus = sinkv1.DeleteStatus_DELETE_STATUS_ACCEPTED DeleteApplied DeleteStatus = sinkv1.DeleteStatus_DELETE_STATUS_APPLIED DeleteFailed DeleteStatus = sinkv1.DeleteStatus_DELETE_STATUS_FAILED )
type DialOptions ¶
type DialOptions struct {
Client ClientOptions
TransportCredentials credentials.TransportCredentials
GRPCOptions []grpc.DialOption
// DNSRefreshInterval is the delay after a successful DNS update before
// another lookup. Zero defaults to 30 seconds; negative values are invalid.
// This is per client and does not bypass DNS-server caches. Explicit
// resolvers in GRPCOptions control their own refresh behavior.
DNSRefreshInterval time.Duration
}
DialOptions controls connection creation. TLS with a minimum version of 1.2 is used when TransportCredentials is nil. Use insecure.NewCredentials only for a trusted plaintext development endpoint.
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document contains one immutable, explicitly encoded user object.
func NewDocument ¶
func NewDocument(value any, encoding DocumentEncoding) (Document, error)
NewDocument encodes a Go value using exactly the requested format. JSON uses json struct tags and BSON uses bson struct tags.
func NewRawDocument ¶
func NewRawDocument(encoding DocumentEncoding, payload []byte) (Document, error)
NewRawDocument validates and copies an already encoded document payload.
func (Document) Encoding ¶
func (d Document) Encoding() DocumentEncoding
type DocumentCallback ¶
DocumentCallback consumes a Query or Scan document in query order. Returning an error cancels the RPC. The SDK does not collect these documents.
type DocumentEncoding ¶
type DocumentEncoding = sinkv1.DocumentEncoding
const ( DocumentEncodingJSON DocumentEncoding = sinkv1.DocumentEncoding_DOCUMENT_ENCODING_JSON DocumentEncodingBSON DocumentEncoding = sinkv1.DocumentEncoding_DOCUMENT_ENCODING_BSON )
type ExecuteRequest ¶
type ExecuteRequest struct {
Command Command
}
type ExecuteResponse ¶
type ExecuteResponse struct {
ContentType string
Payload []byte
Success bool
StatusCode int
Headers http.Header
}
func (ExecuteResponse) Decode ¶
func (r ExecuteResponse) Decode(destination any) error
Decode interprets a native JSON or BSON response. Payload remains available for responses in another content type and for byte-preserving forwarding.
type FailureCode ¶
type FailureCode = sinkv1.FailureCode
const ( FailureInvalidArgument FailureCode = sinkv1.FailureCode_FAILURE_CODE_INVALID_ARGUMENT FailurePreconditionFailed FailureCode = sinkv1.FailureCode_FAILURE_CODE_PRECONDITION_FAILED FailureNotFound FailureCode = sinkv1.FailureCode_FAILURE_CODE_NOT_FOUND FailureConflict FailureCode = sinkv1.FailureCode_FAILURE_CODE_CONFLICT FailureResourceExhausted FailureCode = sinkv1.FailureCode_FAILURE_CODE_RESOURCE_EXHAUSTED FailureDeadlineExceeded FailureCode = sinkv1.FailureCode_FAILURE_CODE_DEADLINE_EXCEEDED FailureInternal FailureCode = sinkv1.FailureCode_FAILURE_CODE_INTERNAL )
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key is an immutable logical record key. Use one of the key constructors.
type LuaProgram ¶
type LuaProgram struct {
// contains filtered or unexported fields
}
LuaProgram is an immutable, self-contained merge rule. Sink verifies the digest and caches the compiled program while executing each merge in a fresh VM.
func NewLuaProgram ¶
func NewLuaProgram(source []byte) (LuaProgram, error)
func (LuaProgram) SHA256 ¶
func (p LuaProgram) SHA256() []byte
func (LuaProgram) Source ¶
func (p LuaProgram) Source() []byte
type MergeOptions ¶
type MergeOptions struct {
Incoming Document
Program LuaProgram
}
MergeOptions describes a Lua-driven read-modify-write operation.
type NativeError ¶
type NativeError struct {
Response ExecuteResponse
}
NativeError retains the database's complete response, including errors not represented by the record API's storage-independent failure codes.
func (*NativeError) Error ¶
func (e *NativeError) Error() string
type OperationError ¶
type OperationError struct {
OperationIndex int
Code FailureCode
Message string
Retryable bool
}
OperationError reports a per-record failure without discarding successful results from the same batch.
func (*OperationError) Error ¶
func (e *OperationError) Error() string
type Projection ¶
Projection includes or excludes native document paths. An empty Fields list selects all fields. Search paths are relative to _source; hit metadata remains.
type ProtocolError ¶
ProtocolError means the server returned a structurally invalid response.
func (*ProtocolError) Error ¶
func (e *ProtocolError) Error() string
type QueryRequest ¶
type QueryRequest struct {
Command Command
Page int // One-based; zero selects page 1.
PageSize int // Zero selects 100; maximum 1000.
Sort []SortField // Ordered keys; empty preserves native sorting.
Projection *Projection // Nil preserves the native projection.
// OnDocument consumes each document without collecting it in the response.
// Nil collects documents. Returning an error cancels the stream.
OnDocument DocumentCallback
}
func NewQueryRequest ¶
func NewQueryRequest() QueryRequest
NewQueryRequest selects page 1 with 100 documents and collection enabled. Dataset supplies the resource; Client callers must supply a Command.
func (QueryRequest) WithCommand ¶
func (r QueryRequest) WithCommand(command Command) QueryRequest
WithCommand supplies the native query and resource.
func (QueryRequest) WithOnDocument ¶
func (r QueryRequest) WithOnDocument(callback DocumentCallback) QueryRequest
WithOnDocument consumes documents without collecting them. Nil restores collection. Page metadata is still returned after successful completion.
func (QueryRequest) WithPage ¶
func (r QueryRequest) WithPage(page int) QueryRequest
WithPage selects a one-based page. Zero means page 1.
func (QueryRequest) WithPageSize ¶
func (r QueryRequest) WithPageSize(size int) QueryRequest
WithPageSize selects the page size. Zero means 100; the maximum is 1000.
func (QueryRequest) WithProjection ¶
func (r QueryRequest) WithProjection(projection *Projection) QueryRequest
WithProjection selects returned fields. Nil preserves native projection.
func (QueryRequest) WithSort ¶
func (r QueryRequest) WithSort(fields ...SortField) QueryRequest
WithSort replaces the native sort with the supplied ordered fields. No fields preserves the native sort.
type QueryResponse ¶
type ReadCallback ¶
type ReadCallback func(ReadResult) error
ReadCallback consumes a final read result before the next receive. Returning an error cancels the RPC. The SDK retains no result documents when a callback is supplied. Already delivered results remain valid if the stream fails.
type ReadRequest ¶
type ReadRequest struct {
Addresses []Address
// OnResult consumes each final result without collecting a result slice.
// Nil collects results in request order. Returning an error cancels the stream.
OnResult ReadCallback
}
ReadRequest selects records and how their results are consumed.
func NewReadRequest ¶
func NewReadRequest(addresses ...Address) ReadRequest
NewReadRequest selects records to collect in request order by default.
func (ReadRequest) WithOnResult ¶
func (r ReadRequest) WithOnResult(callback ReadCallback) ReadRequest
WithOnResult consumes results without collecting them. Nil restores collection.
type ReadResult ¶
type ReadResult struct {
OperationIndex int
Status ReadStatus
Document Document
Failure *OperationError
}
func (ReadResult) Err ¶
func (r ReadResult) Err() error
type ReadStatus ¶
type ReadStatus = sinkv1.ReadStatus
const ( ReadFound ReadStatus = sinkv1.ReadStatus_READ_STATUS_FOUND ReadNotFound ReadStatus = sinkv1.ReadStatus_READ_STATUS_NOT_FOUND ReadFailed ReadStatus = sinkv1.ReadStatus_READ_STATUS_FAILED )
type Record ¶
type Record struct {
Key Key
Value any
// ReturnDocument requires a synchronous completion mode.
ReturnDocument bool
}
Record pairs one logical key with the Go value to encode for a Dataset mutation.
type RetryPolicy ¶
type RetryPolicy struct {
MaxAttempts int
InitialBackoff time.Duration
MaxBackoff time.Duration
Multiplier float64
Jitter float64
}
RetryPolicy controls backoff and attempt limits. Read retries Unavailable and retryable per-operation failures; Scan retries only explicit temporary admission rejections. Mutating RPCs are never retried automatically.
type ScanRequest ¶
type ScanRequest struct {
Command Command
BatchSize int // Zero selects 100; maximum 1000.
Cursor []byte
Projection *Projection // Nil preserves the native projection.
// OnDocument consumes each document without collecting it in the response.
// Nil collects documents. Returning an error cancels the stream.
OnDocument DocumentCallback
}
func NewScanRequest ¶
func NewScanRequest() ScanRequest
NewScanRequest starts a scan with 100 documents per page and collection enabled. Dataset supplies the resource; Client callers must supply a Command.
func (ScanRequest) WithBatchSize ¶
func (r ScanRequest) WithBatchSize(size int) ScanRequest
WithBatchSize selects the page size. Zero means 100; the maximum is 1000.
func (ScanRequest) WithCommand ¶
func (r ScanRequest) WithCommand(command Command) ScanRequest
WithCommand supplies the native query and resource.
func (ScanRequest) WithCursor ¶
func (r ScanRequest) WithCursor(cursor []byte) ScanRequest
WithCursor resumes from a committed checkpoint. Empty starts a new scan.
func (ScanRequest) WithOnDocument ¶
func (r ScanRequest) WithOnDocument(callback DocumentCallback) ScanRequest
WithOnDocument consumes documents without collecting them. Nil restores collection. The next cursor is still returned after successful completion.
func (ScanRequest) WithProjection ¶
func (r ScanRequest) WithProjection(projection *Projection) ScanRequest
WithProjection selects returned fields. Nil preserves native projection.
type ScanResponse ¶
type WriteCallback ¶
type WriteCallback func(WriteResult) error
WriteCallback consumes a final write result without collecting documents. Returning an error cancels the RPC. Unacknowledged writes have an unknown outcome and are never replayed by the SDK.
type WriteMode ¶
const ( WriteCreate WriteMode = sinkv1.WriteMode_WRITE_MODE_CREATE WriteReplace WriteMode = sinkv1.WriteMode_WRITE_MODE_REPLACE WriteUpsert WriteMode = sinkv1.WriteMode_WRITE_MODE_UPSERT )
type WriteOperation ¶
type WriteOperation struct {
// contains filtered or unexported fields
}
WriteOperation is either a put or merge operation. Use NewPut or NewMerge.
func NewMerge ¶
func NewMerge(address Address, opts MergeOptions) (WriteOperation, error)
func NewPut ¶
func NewPut(address Address, document Document, mode WriteMode) (WriteOperation, error)
func (WriteOperation) WithReturnedDocument ¶
func (o WriteOperation) WithReturnedDocument() WriteOperation
WithReturnedDocument requests the logical document used by this operation's successful commit. It requires synchronous completion and an independent commit for this operation; surrounding operations may still fold. Backend-generated fields are excluded.
type WriteRequest ¶
type WriteRequest struct {
// CompletionMode defaults to CompletionWaitUntilApplied when zero.
CompletionMode CompletionMode
Operations []WriteOperation
// OnResult consumes each acknowledgement without collecting a result slice.
// Nil collects results in request order. Returning an error cancels the stream;
// unacknowledged operations may have completed and are never replayed.
OnResult WriteCallback
}
WriteRequest submits mixed put and merge operations with one completion mode.
func NewWriteRequest ¶
func NewWriteRequest(operations ...WriteOperation) WriteRequest
NewWriteRequest submits operations with APPLIED completion by default.
func (WriteRequest) WithCompletionMode ¶
func (r WriteRequest) WithCompletionMode(mode CompletionMode) WriteRequest
WithCompletionMode selects when writes are acknowledged. Zero means APPLIED.
func (WriteRequest) WithOnResult ¶
func (r WriteRequest) WithOnResult(callback WriteCallback) WriteRequest
WithOnResult consumes acknowledgements without collecting them. Nil restores collection.
type WriteResult ¶
type WriteResult struct {
OperationIndex int
Status WriteStatus
Failure *OperationError
Document Document
}
func (WriteResult) Err ¶
func (r WriteResult) Err() error
type WriteStatus ¶
type WriteStatus = sinkv1.WriteStatus
const ( WriteAccepted WriteStatus = sinkv1.WriteStatus_WRITE_STATUS_ACCEPTED WriteApplied WriteStatus = sinkv1.WriteStatus_WRITE_STATUS_APPLIED WritePreconditionFailed WriteStatus = sinkv1.WriteStatus_WRITE_STATUS_PRECONDITION_FAILED WriteFailed WriteStatus = sinkv1.WriteStatus_WRITE_STATUS_FAILED )