sequence

This paper mainly studies the position of Canal-Go

Position

Canal – go – v1.0.7 / protocol/Position/Position. Go

package position

type Position interface {
}
Copy the code
  • Position.go defines a Position interface

MetaqPosition

Canal – go – v1.0.7 / protocol/Position/metaq_position. Go

package position

type MetaqPosition struct {
	Topic    string
	MsgNewId string
	Offset   int64
}
Copy the code
  • MetaqPosition defines the Topic, MsgNewId, and Offset properties

TimePosition

Canal – go – v1.0.7 / protocol/Position/time_position. Go

package position

type TimePosition struct {
	Timestamp int64
}

func NewTimePosition(timestamp int64) *TimePosition {
	tstamp := &TimePosition{Timestamp: timestamp}
	return tstamp
}
Copy the code
  • TimePosition defines the Timestamp property, and the NewTimePosition method instantiates TimePosition

EntryPosition

Canal – go – v1.0.7 / protocol/Position/entry_position. Go

package position

const (
	EVENTIDENTITY_SEGMENT = 3
	EVENTIDENTITY_SPLIT   = 5
)

type EntryPosition struct {
	TimePosition
	Included    bool
	JournalName string
	Position    int64
	ServerId    int64
}

func NewEntryPosition(journalName string, position int64, timestamp int64, serverId int64, Included bool) *EntryPosition {
	entryPosition := &EntryPosition{TimePosition{timestamp}, false, journalName, position, serverId}
	return entryPosition
}
Copy the code
  • EntryPosition defines the TimePosition, Included, JournalName, Position, and ServerId attributes. The NewEntryPosition method instantiates an EntryPosition

LogPosition

Go – the projects/canal – go – v1.0.7 / protocol/Position/log_position. Go

package position

type LogPosition struct {
	Identity LogIdentity
	Postion  EntryPosition
}
Copy the code
  • LogPosition defines the LogIdentity and EntryPosition attributes

summary

Canal-go defines Position, MetaqPosition, TimePosition, EntryPosition, and LogPosition

doc

  • Position