es

package
v0.0.0-...-2e88929 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_FLUSH_TIMEOUT = 1 * time.Second
	DEFAULT_BULK_SIZE     = 1000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeEvent

type ChangeEvent struct {
	Payload struct {
		Before map[string]interface{} `json:"before"`
		After  map[string]interface{} `json:"after"`
		Source struct {
			Connector string      `json:"connector"` //创建链接器的对象即被备份的数据库
			Name      string      `json:"name"`      //自定义topic前缀
			Snapshot  string      `json:"snapshot"`  //是否是快照
			Db        string      `json:"db"`        //数据库名
			Table     string      `json:"table"`     //表名
			Gtid      interface{} `json:"gtid"`
			File      string      `json:"file"` //从哪个binlog日志中取得数据的
			Pos       int         `json:"pos"`  //偏移量
		} `json:"source"`
		Op string `json:"op"` //指令类型(c:INSERT u:UPDATE d:DELETE
	} `json:"payload"`
}

Event 结构体表示Kafka消息的事件数据

type Comment

type Comment struct {
	ID        int64  `mapstructure:"id"`
	UserID    int64  `mapstructure:"user_id"`
	Biz       string `mapstructure:"biz"`
	BizID     int64  `mapstructure:"biz_id"`
	Content   string `mapstructure:"content"`
	PostID    int64  `mapstructure:"post_id"`
	RootID    int64  `mapstructure:"root_id"`
	PID       int64  `mapstructure:"pid"`
	CreatedAt int64  `mapstructure:"created_at"`
	UpdatedAt int64  `mapstructure:"updated_at"`
	Status    uint8  `mapstructure:"status"`
}

Comment 结构体表示评论的数据结构

type EsConsumer

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

EsConsumer 结构体用于消费Kafka消息并将数据同步到Elasticsearch

func NewEsConsumer

func NewEsConsumer(client sarama.Client, l *zap.Logger, rs repository.SearchRepository) *EsConsumer

NewEsConsumer 创建并返回一个新的EsConsumer实例

func (*EsConsumer) Consume

Consume 处理Kafka消息,根据不同的表名执行不同的操作

func (*EsConsumer) Start

func (r *EsConsumer) Start(ctx context.Context) error

Start 启动Kafka消费者,监听消息并进行处理

type FlushPost

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

func NewFlushPost

func NewFlushPost(esConsumer *EsConsumer) *FlushPost

func (*FlushPost) Close

func (f *FlushPost) Close()

type FlushUser

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

func NewFlushUser

func NewFlushUser(esConsumer *EsConsumer) *FlushUser

func (*FlushUser) Close

func (f *FlushUser) Close()

type Post

type Post struct {
	ID           uint         `mapstructure:"id"`
	Title        string       `mapstructure:"title"`
	Content      string       `mapstructure:"content"`
	CreatedAt    time.Time    `mapstructure:"created_at"`
	UpdatedAt    time.Time    `mapstructure:"updated_at"`
	DeletedAt    sql.NullTime `mapstructure:"deleted_at"`
	AuthorID     int64        `mapstructure:"author_id"`
	Status       uint8        `mapstructure:"status"`
	PlateID      int64        `mapstructure:"plate_id"`
	Slug         string       `mapstructure:"slug"`
	CategoryID   int64        `mapstructure:"category_id"`
	Tags         string       `mapstructure:"tags"`
	CommentCount int64        `mapstructure:"comment_count"`

	IsSubmit int8 `mapstructure:"is_submit"`
	// contains filtered or unexported fields
}

Post 结构体表示文章的数据结构

type User

type User struct {
	Id           int64     `mapstructure:"id"`
	CreatedAt    int64     `mapstructure:"created_at"`
	UpdatedAt    int64     `mapstructure:"updated_at"`
	DeletedAt    int64     `mapstructure:"deleted_at"`
	NickName     string    `mapstructure:"nick_name"`
	PasswordHash string    `mapstructure:"password_hash"`
	Birthday     time.Time `mapstructure:"birthday"`
	Deleted      int8      `mapstructure:"deleted"`
	Email        string    `mapstructure:"email"`
	Phone        string    `mapstructure:"phone"`
	About        string    `mapstructure:"about"`
}

User 结构体表示用户的数据结构

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址