entities

package
v0.0.0-...-f894a38 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chat

type Chat struct {
	Id        primitive.ObjectID `bson:"_id,omitempty" json:"id"`
	Users     []int              `bson:"users" json:"users"`
	Unread    int                `bson:"-" json:"unread"`
	CreatedAt int64              `bson:"ts" json:"createdAt"`
}

func (*Chat) BeforeSave

func (c *Chat) BeforeSave()

func (*Chat) HasUser

func (c *Chat) HasUser(uid int) bool

func (*Chat) UsersExceptOne

func (c *Chat) UsersExceptOne(uid int) []int

func (*Chat) Validate

func (c *Chat) Validate() error

type ConsulAgent

type ConsulAgent interface {
	Register() error
	Unregister() error
}

type KernelError

type KernelError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

func NewError

func NewError(code string, message string) *KernelError

func (KernelError) Error

func (r KernelError) Error() string

type Message

type Message struct {
	Id        primitive.ObjectID `bson:"_id,omitempty" json:"id"`
	ChatId    primitive.ObjectID `bson:"cid" json:"cid"`
	UserId    int                `bson:"aid" json:"uid"`
	CreatedAt int64              `bson:"ts" json:"createdAt"`
	Text      string             `bson:"txt" json:"text"`
	Read      bool               `bson:"rdn" json:"-"`
}

func (*Message) BeforeSave

func (m *Message) BeforeSave()

func (*Message) Validate

func (m *Message) Validate() error

type RedisClient

type RedisClient interface {
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd
	Get(ctx context.Context, key string) *redis.StringCmd
	Del(ctx context.Context, keys ...string) *redis.IntCmd
	Close() error
}

type Saga

type Saga struct {
	Id          string               `json:"-"`
	MessagesIds []string             `json:"ids,omitempty"`
	Command     string               `json:"cmd,omitempty"`
	ChatId      string               `json:"cid,omitempty"`
	UserId      int                  `json:"uid,omitempty"`
	Num         uint                 `json:"num,omitempty"`
	Compensate  func(sg *Saga) error `json:"-"`
}

type SagaOrchestrator

type SagaOrchestrator interface {
	IsActive() bool
	ExecuteSaga(ctx context.Context, saga *Saga) error
}

type Server

type Server interface {
	Serve()
	MountRoutes(pattern string, router *chi.Mux)
}

Jump to

Keyboard shortcuts

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