cockroach: github.com/cockroachdb/cockroach/pkg/ccl/changefeedccl/schemafeed Index | Files | Directories

package schemafeed

import "github.com/cockroachdb/cockroach/pkg/ccl/changefeedccl/schemafeed"

Index

Package Files

schema_feed.go table_event_filter.go

type Config Uses

type Config struct {
    DB       *kv.DB
    Clock    *hlc.Clock
    Settings *cluster.Settings
    Targets  jobspb.ChangefeedTargets

    // SchemaChangeEvents controls the class of events which are emitted by this
    // SchemaFeed.
    SchemaChangeEvents changefeedbase.SchemaChangeEventClass

    // InitialHighWater is the timestamp after which events should occur.
    //
    // NB: When clients want to create a changefeed which has a resolved timestamp
    // of ts1, they care about write which occur at ts1.Next() and later but they
    // should scan the tables as of ts1. This is important so that writes which
    // change the table at ts1.Next() are emitted as an event.
    InitialHighWater hlc.Timestamp

    // LeaseManager is used to ensure that when an event is emitted that at a higher
    // level it is ensured that the right table descriptor will be used for the
    // event if this lease manager is used.
    //
    // TODO(ajwerner): Should this live underneath the FilterFunc?
    // Should there be another function to decide whether to update the
    // lease manager?
    LeaseManager *lease.Manager
}

Config configures a SchemaFeed.

type SchemaFeed Uses

type SchemaFeed struct {
    // contains filtered or unexported fields
}

SchemaFeed tracks changes to a set of tables and exports them as a queue of events. The queue allows clients to provide a timestamp at or before which all events must be seen by the time Peek or Pop returns. This allows clients to ensure that all table events which precede some rangefeed event are seen before propagating that rangefeed event.

Internally, two timestamps are tracked. The high-water is the highest timestamp such that every version of a TableDescriptor has met a provided invariant (via `validateFn`). An error timestamp is also kept, which is the lowest timestamp where at least one table doesn't meet the invariant.

func New Uses

func New(cfg Config) *SchemaFeed

New creates SchemaFeed with the given Config.

func (*SchemaFeed) Peek Uses

func (tf *SchemaFeed) Peek(
    ctx context.Context, atOrBefore hlc.Timestamp,
) (events []TableEvent, err error)

Peek returns all events which have not been popped which happen at or before the passed timestamp.

func (*SchemaFeed) Pop Uses

func (tf *SchemaFeed) Pop(
    ctx context.Context, atOrBefore hlc.Timestamp,
) (events []TableEvent, err error)

Pop pops events from the EventQueue.

func (*SchemaFeed) Run Uses

func (tf *SchemaFeed) Run(ctx context.Context) error

Run will run the SchemaFeed. It is an error to run a feed more than once.

type TableEvent Uses

type TableEvent struct {
    Before, After *sqlbase.ImmutableTableDescriptor
}

TableEvent represents a change to a table descriptor.

func (TableEvent) String Uses

func (e TableEvent) String() string

func (TableEvent) Timestamp Uses

func (e TableEvent) Timestamp() hlc.Timestamp

Timestamp refers to the ModificationTime of the After table descriptor.

Directories

PathSynopsis
schematestutilsPackage schematestutils is a utility package for constructing schema objects in the context of cdc.

Package schemafeed imports 21 packages (graph) and is imported by 3 packages. Updated 2020-08-11. Refresh now. Tools for package owners.