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 ¶
func (r *EsConsumer) Consume(sess sarama.ConsumerGroupSession, msg *sarama.ConsumerMessage)
Consume 处理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 结构体表示用户的数据结构
Click to show internal directories.
Click to hide internal directories.