service

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialog

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

func (*Dialog) Create

func (g *Dialog) Create(ctx context.Context, obj dto.DialogCreate) (entity.Dialog, error)

func (*Dialog) GetByID

func (g *Dialog) GetByID(ctx context.Context, id int) (entity.Dialog, error)

func (*Dialog) List

func (g *Dialog) List(ctx context.Context) ([]entity.Dialog, error)

func (*Dialog) Update

func (g *Dialog) Update(ctx context.Context, obj dto.DialogUpdate) error

type DialogParticipantEventProducer

type DialogParticipantEventProducer interface {
	Produce(ctx context.Context, event entity.ParticipantEvent) error
}

type DialogRepository

type DialogRepository interface {
	List(ctx context.Context) ([]entity.Dialog, error)
	Create(ctx context.Context, dialog *entity.Dialog) error
	GetByID(ctx context.Context, id int) (entity.Dialog, error)
	Update(ctx context.Context, dialog *entity.Dialog) error
}

type Group

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

func (*Group) Create

func (g *Group) Create(ctx context.Context, obj dto.GroupCreate) (entity.Group, error)

func (*Group) Delete

func (g *Group) Delete(ctx context.Context, id int) error

func (*Group) GetByID

func (g *Group) GetByID(ctx context.Context, id int) (entity.Group, error)

func (*Group) List

func (g *Group) List(ctx context.Context) ([]entity.Group, error)

func (*Group) Update

func (g *Group) Update(ctx context.Context, obj dto.GroupUpdate) (entity.Group, error)

type GroupParticipant

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

func NewGroupParticipant

func NewGroupParticipant(conf GroupParticipantConfig) *GroupParticipant

func (*GroupParticipant) Get

func (p *GroupParticipant) Get(ctx context.Context, groupID, userID int) (entity.GroupParticipant, error)

func (*GroupParticipant) Invite

func (p *GroupParticipant) Invite(ctx context.Context, groupID, userID int) (entity.GroupParticipant, error)

func (*GroupParticipant) List

func (p *GroupParticipant) List(ctx context.Context, groupID int) ([]entity.GroupParticipant, error)

func (*GroupParticipant) UpdateStatus

func (p *GroupParticipant) UpdateStatus(ctx context.Context, groupID, userID int, status entity.GroupParticipantStatus) error

type GroupParticipantConfig

type GroupParticipantConfig struct {
	TxManager     TransactionManager
	Repository    GroupParticipantRepository
	EventProducer GroupParticipantEventProducer
}

type GroupParticipantEventProducer

type GroupParticipantEventProducer interface {
	Produce(ctx context.Context, event entity.ParticipantEvent) error
}

type GroupParticipantFunc

type GroupParticipantFunc func(p *entity.GroupParticipant) error

type GroupParticipantRepository

type GroupParticipantRepository interface {
	List(ctx context.Context, groupID int) ([]entity.GroupParticipant, error)
	Get(ctx context.Context, groupID, userID int, withLock bool) (entity.GroupParticipant, error)
	Create(ctx context.Context, p *entity.GroupParticipant) error
	Update(ctx context.Context, p *entity.GroupParticipant) error
}

type GroupRepository

type GroupRepository interface {
	List(ctx context.Context) ([]entity.Group, error)
	Create(ctx context.Context, group *entity.Group) error
	GetByID(ctx context.Context, id int) (entity.Group, error)
	Update(ctx context.Context, group *entity.Group) error
	Delete(ctx context.Context, id int) error
}

type InChatChecker

type InChatChecker interface {
	Check(ctx context.Context, chatID entity.ChatID, userID int) error
}

type Message

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

func NewMessage

func NewMessage(repo MessageRepository, publisher MessagePublisher, checker InChatChecker) *Message

func (*Message) Create

func (s *Message) Create(ctx context.Context, obj dto.MessageCreate) (entity.Message, error)

func (*Message) List

func (s *Message) List(ctx context.Context, obj dto.MessageList) ([]entity.Message, error)

type MessageConsumer

type MessageConsumer interface {
	BeginConsume(ctx context.Context) (<-chan entity.Message, <-chan error)
	Subscribe(ctx context.Context, chatIDs ...entity.ChatID) error
	Unsubscribe(ctx context.Context, chatIDs ...entity.ChatID) error
	Close() error
}

type MessagePublisher

type MessagePublisher interface {
	Publish(ctx context.Context, message entity.Message) error
}

type MessageRepository

type MessageRepository interface {
	List(ctx context.Context, obj dto.MessageList) ([]entity.Message, error)
	Create(ctx context.Context, message *entity.Message) error
}

type MessageServeManager

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

func (*MessageServeManager) BeginServe

func (sm *MessageServeManager) BeginServe(ctx context.Context, inCh <-chan dto.MessageCreate) (<-chan entity.Message, <-chan error, error)

type MessageServeManagerConfig

type MessageServeManagerConfig struct {
	Service          *Message
	EventConsumer    ParticipantEventConsumer
	Subscriber       MessageSubscriber
	GroupRepository  GroupRepository
	DialogRepository DialogRepository
}

type MessageSubscriber

type MessageSubscriber interface {
	Subscribe(ctx context.Context, chatIDs ...entity.ChatID) MessageConsumer
}

type ParticipantEventConsumer

type ParticipantEventConsumer interface {
	BeginConsume(ctx context.Context, userID int) (<-chan entity.ParticipantEvent, <-chan error)
}

type SessionRepository

type SessionRepository interface {
	DeleteAllByUserID(ctx context.Context, id string) error
}

type StatusMatrix

type StatusMatrix interface {
	IsCorrectTransit(from, to entity.GroupParticipantStatus) bool
}

type TransactionManager

type TransactionManager interface {
	Do(ctx context.Context, fn func(ctx context.Context) error) error
}

type User

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

func NewUser

func NewUser(conf UserConfig) *User

func (*User) CheckPassword

func (u *User) CheckPassword(ctx context.Context, username, password string) (userID string, ok bool, err error)

func (*User) Create

func (u *User) Create(ctx context.Context, obj dto.UserCreate) (entity.User, error)

func (*User) Delete

func (u *User) Delete(ctx context.Context, id int) error

func (*User) GetByID

func (u *User) GetByID(ctx context.Context, id int) (entity.User, error)

func (*User) List

func (u *User) List(ctx context.Context) ([]entity.User, error)

func (*User) Update

func (u *User) Update(ctx context.Context, obj dto.UserUpdate) (entity.User, error)

func (*User) UpdatePassword

func (u *User) UpdatePassword(ctx context.Context, obj dto.UserUpdatePassword) error

type UserConfig

type UserConfig struct {
	UserRepository    UserRepository
	SessionRepository SessionRepository
}

type UserRepository

type UserRepository interface {
	List(ctx context.Context) ([]entity.User, error)
	Create(ctx context.Context, user *entity.User) error
	GetByID(ctx context.Context, id int) (entity.User, error)
	GetByUsername(ctx context.Context, username string) (entity.User, error)
	Update(ctx context.Context, user *entity.User) error
	UpdatePassword(ctx context.Context, userID int, pwdHash string) error
	Delete(ctx context.Context, id int) error
}

Jump to

Keyboard shortcuts

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