Documentation ¶
Index ¶
- func CheckScheduleState(origin ScheduledChangefeed, target ScheduledChangefeed) error
- type CaptureObservation
- type CaptureProgress
- type ChangefeedIdent
- type ChangefeedInfo
- type ChangefeedProgress
- type ChangefeedState
- type ChangefeedUUID
- type ControllerObservation
- type Elector
- type OwnerObservation
- type Querier
- type SchedState
- type ScheduleError
- type ScheduledChangefeed
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckScheduleState ¶
func CheckScheduleState(origin ScheduledChangefeed, target ScheduledChangefeed) error
CheckScheduleState checks whether the origin and target schedule state is valid.
Types ¶
type CaptureObservation ¶
type CaptureObservation interface { Elector // Run runs // the `eclector.RunElection` and other background tasks. // controllerCallback will be called when the capture campaign as the controller. Run( ctx context.Context, controllerCallback func(context.Context, ControllerObservation) error, ) error // Advance advances some changefeed progresses that are collected from processors. Advance(cp CaptureProgress) error // OwnerChanges fetch owner modifications. OwnerChanges() <-chan ScheduledChangefeed // OnOwnerLaunched create an owner observation for a changefeed owner. OnOwnerLaunched(cf ChangefeedUUID) OwnerObservation // PostOwnerRemoved inform the metadata storage when an owner exits. PostOwnerRemoved(cf ChangefeedUUID, taskPosition ChangefeedProgress) error }
CaptureObservation is for observing and updating metadata on a CAPTURE instance.
All intrefaces are thread-safe and shares one same Context.
type CaptureProgress ¶
type CaptureProgress map[ChangefeedUUID]ChangefeedProgress
CaptureProgress stores the progress of all ChangeFeeds on single capture.
func (*CaptureProgress) Scan ¶
func (cp *CaptureProgress) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type ChangefeedIdent ¶
type ChangefeedIdent struct { // UUID is generated internally by TiCDC to distinguish between changefeeds with the same ID. // Note that it can't be specified by the user. UUID ChangefeedUUID `gorm:"column:uuid;type:bigint(20) unsigned;primaryKey" json:"uuid"` // Namespace and ID pair is unique in one ticdc cluster. And in the current implementation, // Namespace can only be set to `default`. Namespace string `gorm:"column:namespace;type:varchar(128);not null;uniqueIndex:namespace,priority:1" json:"namespace"` ID string `gorm:"column:id;type:varchar(128);not null;uniqueIndex:namespace,priority:2" json:"id"` }
ChangefeedIdent identifies a changefeed.
func (*ChangefeedIdent) Compare ¶
func (c *ChangefeedIdent) Compare(other ChangefeedIdent) int
Compare compares two ChangefeedIDWithEpoch base on their string representation.
func (ChangefeedIdent) String ¶
func (c ChangefeedIdent) String() string
String implements fmt.Stringer interface
func (ChangefeedIdent) ToChangefeedID ¶
func (c ChangefeedIdent) ToChangefeedID() model.ChangeFeedID
ToChangefeedID converts ChangefeedUUID to model.ChangeFeedID.
type ChangefeedInfo ¶
type ChangefeedInfo struct { ChangefeedIdent UpstreamID uint64 `gorm:"column:upstream_id;type:bigint(20) unsigned;not null;index:upstream_id,priority:1" json:"upstream_id"` SinkURI string `gorm:"column:sink_uri;type:text;not null" json:"sink_uri"` StartTs uint64 `gorm:"column:start_ts;type:bigint(20) unsigned;not null" json:"start_ts"` TargetTs uint64 `gorm:"column:target_ts;type:bigint(20) unsigned;not null" json:"target_ts"` // Note that pointer type is used here for compatibility with the old model, and config should never be nil in practice. Config *config.ReplicaConfig `gorm:"column:config;type:longtext;not null" json:"config"` }
ChangefeedInfo is a minimal info collection to describe a changefeed.
type ChangefeedProgress ¶
type ChangefeedProgress model.ChangeFeedStatus
ChangefeedProgress is for changefeed progress. Use ChangeFeedStatus to maintain compatibility with older versions of the code.
func (*ChangefeedProgress) Scan ¶
func (cp *ChangefeedProgress) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type ChangefeedState ¶
type ChangefeedState struct { ChangefeedUUID ChangefeedUUID `gorm:"column:changefeed_uuid;type:bigint(20) unsigned;primaryKey" json:"changefeed_uuid"` State model.FeedState `gorm:"column:state;type:text;not null" json:"state"` Warning *model.RunningError `gorm:"column:warning;type:text" json:"warning"` Error *model.RunningError `gorm:"column:error;type:text" json:"error"` }
ChangefeedState is the status of a changefeed.
type ChangefeedUUID ¶
type ChangefeedUUID = uint64
ChangefeedUUID is the unique identifier of a changefeed.
type ControllerObservation ¶
type ControllerObservation interface { // CreateChangefeed creates a changefeed, UUID will be filled into the input ChangefeedInfo. CreateChangefeed(cf *ChangefeedInfo, up *model.UpstreamInfo) (ChangefeedIdent, error) // RemoveChangefeed removes a changefeed, will mark it as removed and stop the owner and processors asynchronizely. RemoveChangefeed(cf ChangefeedUUID) error // CleanupChangefeed cleans up a changefeed, will delete info, schdule and state metadata. CleanupChangefeed(cf ChangefeedUUID) error // RefreshCaptures Fetch the latest capture list in the TiCDC cluster. RefreshCaptures() (captures []*model.CaptureInfo, changed bool) // SetOwner Schedule a changefeed owner to a given target. // Notes: // * the target capture can fetch the event by `OwnerChanges`. // * target state can only be `SchedLaunched` or `SchedRemoving`. SetOwner(target ScheduledChangefeed) error // GetChangefeedSchedule Get current schedule of the given changefeed. GetChangefeedSchedule(cf ChangefeedUUID) (ScheduledChangefeed, error) // ScheduleSnapshot Get a snapshot of all changefeeds current schedule. ScheduleSnapshot() ([]ScheduledChangefeed, []*model.CaptureInfo, error) }
ControllerObservation is for observing and updating meta by Controller.
All intrefaces are thread-safe and shares one same Context.
type Elector ¶
type Elector interface { // Self tells the caller who am I. Self() *model.CaptureInfo // RunElection runs the elector to continuously campaign for leadership // until the context is canceled. // onTakeControl will be called when the capture campaign as the controller. RunElection(ctx context.Context, onTakeControl func(ctx context.Context) error) error // GetController returns the last observed controller whose lease is still valid. GetController() (*model.CaptureInfo, error) // GetCaptures queries some or all captures. GetCaptures(...model.CaptureID) ([]*model.CaptureInfo, error) }
Elector is used to campaign for capture controller.
func NewElector ¶
func NewElector( selfInfo *model.CaptureInfo, storage election.Storage, ) Elector
NewElector creates a new elector.
type OwnerObservation ¶
type OwnerObservation interface { // Self returns the changefeed info of the owner. Self() ChangefeedUUID // UpdateChangefeed updates changefeed metadata, must be called on a paused one. UpdateChangefeed(*ChangefeedInfo) error // PauseChangefeed pauses a changefeed. PauseChangefeed() error // ResumeChangefeed resumes a changefeed. ResumeChangefeed() error // SetChangefeedFinished set the changefeed to state finished. SetChangefeedFinished() error // SetChangefeedRemoved set the changefeed to state removed. SetChangefeedRemoved() error // SetChangefeedFailed set the changefeed to state failed. SetChangefeedFailed(err *model.RunningError) error // SetChangefeedWarning set the changefeed to state warning. SetChangefeedWarning(warn *model.RunningError) error // SetChangefeedPending sets the changefeed to state pending. SetChangefeedPending(err *model.RunningError) error }
OwnerObservation is for observing and updating running status of a changefeed.
All intrefaces are thread-safe and shares one same Context.
type Querier ¶
type Querier interface { // GetChangefeeds queries some or all changefeeds. GetChangefeed(...ChangefeedUUID) ([]*ChangefeedInfo, error) // GetChangefeedState queries some or all changefeed states. GetChangefeedState(...ChangefeedUUID) ([]*ChangefeedState, error) // GetChangefeedProgress queries some or all changefeed progresses. GetChangefeedProgress(...ChangefeedUUID) (map[ChangefeedUUID]ChangefeedProgress, error) }
Querier is used to query information from metadata storage.
type SchedState ¶
type SchedState int
SchedState is the type of state to schedule owners and processors.
const ( // SchedInvalid should never be used. SchedInvalid SchedState = SchedState(0) // SchedRemoved means the owner or processor is removed. SchedRemoved SchedState = SchedState(1) // SchedLaunched means the owner or processor is launched. SchedLaunched SchedState = SchedState(2) // SchedRemoving means the owner or processor is in removing. SchedRemoving SchedState = SchedState(3) )
func (*SchedState) Scan ¶
func (s *SchedState) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
func (SchedState) String ¶
func (s SchedState) String() string
String implements the fmt.Stringer interface.
type ScheduleError ¶
type ScheduleError struct {
Msg string
}
ScheduleError is for role state transformation.
func NewBadScheduleError ¶
func NewBadScheduleError(origin ScheduledChangefeed, target ScheduledChangefeed) ScheduleError
NewBadScheduleError creates a schedule error with detail information.
func NewScheduleError ¶
func NewScheduleError(msg string) ScheduleError
NewScheduleError creates an error.
func (ScheduleError) Error ¶
func (e ScheduleError) Error() string
Error implements error interface.
type ScheduledChangefeed ¶
type ScheduledChangefeed struct { ChangefeedUUID ChangefeedUUID `gorm:"column:changefeed_uuid;type:bigint(20) unsigned;primaryKey" json:"changefeed_uuid"` Owner *model.CaptureID `gorm:"column:owner;type:varchar(128)" json:"owner"` OwnerState SchedState `gorm:"column:owner_state;type:text;not null" json:"owner_state"` // Processors is always equal to the owner in the current implementation. Processors *model.CaptureID `gorm:"column:processors;type:text" json:"processors"` // TaskPosition is used to initialize changefeed owner on the capture. TaskPosition ChangefeedProgress `gorm:"column:task_position;type:text;not null" json:"task_position"` }
ScheduledChangefeed is for owner and processor schedule.
func DiffScheduledChangefeeds ¶
func DiffScheduledChangefeeds( origin, target []ScheduledChangefeed, sortedBy func(a, b ScheduledChangefeed) int, ) ([]ScheduledChangefeed, error)
DiffScheduledChangefeeds gets difference between origin and target.
Both origin and target should be sorted by the given rule.