database

package
v0.0.0-...-69995ca Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDb

func InitDb(driver string, dsn string) (*gorm.DB, error)

InitMysqlDb init mysql database

func InitFailoverRedis

func InitFailoverRedis(masterName string, sentinelAddrs []string, password string, timeout time.Duration) (*redis.Client, error)

InitFailoverRedis init redis with sentinels

func InitRedis

func InitRedis(addr string, pass string) (*redis.Client, error)

InitRedis return a redis instance

func KeyMessageAckIndex

func KeyMessageAckIndex(account string) string

KeyMessageAckIndex return a redis key of the read index

Types

type Group

type Group struct {
	Model
	Group        string `gorm:"uniqueIndex;size:30"`
	App          string `gorm:"size:30"`
	Name         string `gorm:"size:50"`
	Owner        string `gorm:"size:60"`
	Avatar       string `gorm:"size:200"`
	Introduction string `gorm:"size:300"`
}

type GroupMember

type GroupMember struct {
	Model
	Account string `gorm:"uniqueIndex:uni_gp_acc;size:60"`
	Group   string `gorm:"uniqueIndex:uni_gp_acc;index;size:30"`
	Alias   string `gorm:"size:30"`
}

GroupMember GroupMember

type IDGenerator

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

IDGenerator generate unique id

func NewIDGenerator

func NewIDGenerator(nodeID int64) (*IDGenerator, error)

NewIDGenerator NewIDGenerator

func (*IDGenerator) Next

func (g *IDGenerator) Next() snowflake.ID

Next Generate a new id

func (*IDGenerator) Parse

func (g *IDGenerator) Parse(id int64) snowflake.ID

func (*IDGenerator) ParseBase36

func (g *IDGenerator) ParseBase36(id string) (snowflake.ID, error)

ParseBase36 ParseBase36

type MessageContent

type MessageContent struct {
	ID       int64  `gorm:"primarykey"`
	Type     byte   `gorm:"default:0"`
	Body     string `gorm:"size:5000;not null"`
	Extra    string `gorm:"size:500"`
	SendTime int64  `gorm:"index"`
}

type MessageIndex

type MessageIndex struct {
	ID        int64  `gorm:"primarykey"`
	AccountA  string `gorm:"index;size:60;not null;comment:队列唯一标识"`
	AccountB  string `gorm:"size:60;not null;comment:另一方"`
	Direction byte   `gorm:"default:0;not null;comment:1表示AccountA为发送者"`
	MessageID int64  `gorm:"not null;comment:关联消息内容表中的ID"`
	Group     string `gorm:"size:30;comment:群ID,单聊情况为空"`
	SendTime  int64  `gorm:"index;not null;comment:消息发送时间"`
}

type Model

type Model struct {
	ID        int64 `gorm:"primarykey"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

type User

type User struct {
	Model
	App      string `gorm:"size:30"`
	Account  string `gorm:"uniqueIndex;size:60"`
	Password string `gorm:"size:30"`
	Avatar   string `gorm:"size:200"`
	Nickname string `gorm:"size:20"`
}

Jump to

Keyboard shortcuts

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