es

package
v0.0.0-...-1b0a6d5 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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, tc *elasticsearch.TypedClient) *EsConsumer

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

func (*EsConsumer) Consume

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

func (*EsConsumer) Start

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

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

type Event

type Event struct {
	Type     string                   `json:"type"`
	Database string                   `json:"database"`
	Table    string                   `json:"table"`
	Data     []map[string]interface{} `json:"data"`
}

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

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"`
}

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

type User

type User struct {
	ID        int64   `mapstructure:"id"`
	Username  string  `mapstructure:"username"`
	Phone     *string `mapstructure:"phone"`
	Email     string  `mapstructure:"email"`
	Password  string  `mapstructure:"password"`
	CreatedAt int64   `mapstructure:"created_at"`
	UpdatedAt int64   `mapstructure:"updated_at"`
	Deleted   bool    `mapstructure:"deleted"`
}

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

Jump to

Keyboard shortcuts

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