cockroach: github.com/cockroachdb/cockroach/pkg/sql/colflow/colrpc Index | Files

package colrpc

import "github.com/cockroachdb/cockroach/pkg/sql/colflow/colrpc"

Index

Package Files

inbox.go outbox.go

type Dialer Uses

type Dialer interface {
    Dial(context.Context, roachpb.NodeID, rpc.ConnectionClass) (*grpc.ClientConn, error)
}

Dialer is used for dialing based on node IDs. It extracts out the single method that Outbox.Run needs from nodedialer.Dialer so that we can mock it in tests outside of this package.

type Inbox Uses

type Inbox struct {
    colexecbase.ZeroInputNode
    // contains filtered or unexported fields
}

Inbox is used to expose data from remote flows through an exec.Operator interface. FlowStream RPC handlers should call RunWithStream (which blocks until operation terminates, gracefully or unexpectedly) to pass the stream to the inbox. Next may be called before RunWithStream, it will just block until the stream is made available or its context is canceled. Note that ownership of the stream is passed from the RunWithStream goroutine to the Next goroutine. In exchange, the RunWithStream goroutine receives the first context passed into Next and listens for cancellation. Returning from RunWithStream (or more specifically, the RPC handler) will unblock Next by closing the stream.

func NewInbox Uses

func NewInbox(
    ctx context.Context, allocator *colmem.Allocator, typs []*types.T, streamID execinfrapb.StreamID,
) (*Inbox, error)

NewInbox creates a new Inbox.

func (*Inbox) DrainMeta Uses

func (i *Inbox) DrainMeta(ctx context.Context) []execinfrapb.ProducerMetadata

DrainMeta is part of the MetadataGenerator interface. DrainMeta may not be called concurrently with Next.

func (*Inbox) Init Uses

func (i *Inbox) Init()

Init is part of the Operator interface.

func (*Inbox) Next Uses

func (i *Inbox) Next(ctx context.Context) coldata.Batch

Next returns the next batch. It will block until there is data available. The Inbox will exit when either the context passed in on the first call to Next is canceled or when DrainMeta goroutine tells it to do so.

func (*Inbox) RunWithStream Uses

func (i *Inbox) RunWithStream(streamCtx context.Context, stream flowStreamServer) error

RunWithStream sets the Inbox's stream and waits until either streamCtx is canceled, a caller of Next cancels the first context passed into Next, or an EOF is encountered on the stream by the Next goroutine.

func (*Inbox) Timeout Uses

func (i *Inbox) Timeout(err error)

Timeout sends the given error to any readers waiting for a stream to be established (i.e. RunWithStream to be called).

type Outbox Uses

type Outbox struct {
    colexec.OneInputNode
    // contains filtered or unexported fields
}

Outbox is used to push data from local flows to a remote endpoint. Run may be called with the necessary information to establish a connection to a given remote endpoint.

func NewOutbox Uses

func NewOutbox(
    allocator *colmem.Allocator,
    input colexecbase.Operator,
    typs []*types.T,
    metadataSources []execinfrapb.MetadataSource,
    toClose []colexec.Closer,
) (*Outbox, error)

NewOutbox creates a new Outbox.

func (*Outbox) Run Uses

func (o *Outbox) Run(
    ctx context.Context,
    dialer Dialer,
    nodeID roachpb.NodeID,
    flowID execinfrapb.FlowID,
    streamID execinfrapb.StreamID,
    cancelFn context.CancelFunc,
)

Run starts an outbox by connecting to the provided node and pushing coldata.Batches over the stream after sending a header with the provided flow and stream ID. Note that an extra goroutine is spawned so that Recv may be called concurrently wrt the Send goroutine to listen for drain signals. If an io.EOF is received while sending, the outbox will call cancelFn to indicate an unexpected termination of the stream. If an error is encountered that cannot be sent over the stream, the error will be logged but not returned. There are several ways the bidirectional FlowStream RPC may terminate. 1) Execution is finished. In this case, the upstream operator signals

termination by returning a zero-length batch. The Outbox will drain its
metadata sources, send the metadata, and then call CloseSend on the
stream. The Outbox will wait until its Recv goroutine receives a non-nil
error to not leak resources.

2) A cancellation happened. This can come from the provided context or the

remote reader. Refer to tests for expected behavior.

3) A drain signal was received from the server (consumer). In this case, the

Outbox goes through the same steps as 1).

Package colrpc imports 20 packages (graph) and is imported by 2 packages. Updated 2020-07-31. Refresh now. Tools for package owners.