Skip to content

[WTEL-10383]feature(broker): add creating system online skill on new - #502

Open
suifri wants to merge 1 commit into
mainfrom
feature/WTEL-10383-default-system-online-skill-creation-on-domain-init
Open

[WTEL-10383]feature(broker): add creating system online skill on new#502
suifri wants to merge 1 commit into
mainfrom
feature/WTEL-10383-default-system-online-skill-creation-on-domain-init

Conversation

@suifri

@suifri suifri commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

domain event

  • add creation of simple topic broker queue
  • add queue configuration object
  • add new domain created handler

@suifri
suifri requested a review from navrotskyj September 10, 2026 09:02
@webitel-review

webitel-review Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

🤖 Webitel Code Review

Цей пулреквест додає обробник подій створення домену для автоматичного створення системних навичок (online skills) для нових доменів. Для цього реалізовано новий загальний споживач черг RabbitMQ (BrokerQueue) з підтримкою повторного підключення та конкурентної обробки.

📋 Walkthrough (10 файл(и/ів))
Файл Зміни
app/app.go Ініціалізує слухача подій домену перед запуском черги повідомлень.
app/online_skills.go Додає обробник події створення домену, який створює системні навички для нового домену.
model/domain.go Додає структуру DomainEvent та парсинг ID домену з routing key.
mq/layered_mq.go Додає метод SetDomainsEventHandler та оновлює сигнатуру SendStartFlow.
mq/mq.go Додає тип DomainEventHandler та метод SetDomainsEventHandler до інтерфейсу MQ.
mq/rabbit/broker_queue.go Реалізує новий допоміжний компонент BrokerQueue для надійної роботи з чергами RabbitMQ.
mq/rabbit/client.go Інтегрує споживання подій створення доменів через новий BrokerQueue.
mq/rabbit/config.go Додає конфігураційні структури та опції для черг та їх прив'язок.
store/sqlstore/online_skills.go Реалізує метод CreateSystem для створення дефолтної системної навички в БД.
store/store.go Додає метод CreateSystem до інтерфейсу OnlineSkillsStore.

Знахідки

  • [blocker] mq/rabbit/broker_queue.go:290 — Метод b.channel.IsClosed() викличе помилку компіляції, оскільки тип *amqp.Channel з пакету github.com/rabbitmq/amqp091-go не має методу IsClosed(). Потрібно просто перевірити b.channel != nil та викликати Cancel і Close, ігноруючи помилки.
  • [medium] mq/rabbit/broker_queue.go:213 — У разі помилки обробника повідомлення відхиляється за допомогою d.Nack(false, false), що означає requeue = false. Якщо помилка є тимчасовою (наприклад, збій підключення до БД при створенні системних навичок), подія буде втрачена назавжди, і системні навички для домену не будуть створені. Варто розрізняти помилки валідації (які не треба перечитувати) та тимчасові помилки інфраструктури, або використовувати requeue/DLQ з політикою повторів.
🔸 Дрібниці / nitpicks (1)
  • [nit] model/domain.go:19 — Друкарська помилка в тексті помилки: "roting key" замість "routing key".
🔗 Cross-repo callers змінених символів (14)
  • Bindim-delivery-service/internal/handler/amqp/router.go:84
  • Bindmcp_webitel/main.go:536
  • Bindwebitel.go/app/server.go:237
  • NewQueueConfigstorage/broker/rabbit/rabbitmq.go:68
  • NewQueueConfigwebitel-kb/internal/relay/broker.go:78
  • SendStartFlowengine/app/cc_member.go:11
  • SendStartFlowengine/mq/layered_mq.go:73
  • Tablecases/internal/store/postgres/case.go:2126
  • Tableim-providers-service/internal/core/pubsub/channel.go:143
  • Tableweb-meeting-backend/infra/pubsub/channel.go:143
  • Tablewebitel-fts/infra/pubsub/channel.go:143
  • Tablewebitel.go/postgres/catalog/contact_create.go:199
  • Tablewebitel.go/postgres/catalog/contact_update.go:481
  • WithQueueDurablestorage/broker/rabbit/rabbitmq.go:68

Index-grounded review across the Webitel codebase. Знахідки можуть бути неточними — перевіряйте перед застосуванням.

@webitel-review webitel-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Webitel Code Review — пропозиції змін

Comment thread model/domain.go Outdated
)

type DomainEvent struct {
ID int

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Використовуйте int64 для ID домену для узгодженості з рештою кодової бази.

Suggested change
ID int
ID int64

Comment thread model/domain.go Outdated

const domainIdIndex = 2

parsedDomainId, err := strconv.Atoi(splitted[domainIdIndex])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Парсинг ID домену як int64.

Suggested change
parsedDomainId, err := strconv.Atoi(splitted[domainIdIndex])
parsedDomainId, err := strconv.ParseInt(splitted[domainIdIndex], 10, 64)

Comment thread mq/rabbit/broker_queue.go Outdated
ch, err := b.getChannel()
if err != nil {
b.log.Error("getting AMQP channel", wlog.Err(err))
if !b.sleep() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Передавайте контекст у метод sleep для швидкого реагування на скасування.

Suggested change
if !b.sleep() {
if !b.sleep(ctx) {

Comment thread mq/rabbit/broker_queue.go Outdated

if err := b.setup(ch); err != nil {
b.log.Error("setup queue", wlog.Err(err))
if !b.sleep() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Передавайте контекст у метод sleep.

Suggested change
if !b.sleep() {
if !b.sleep(ctx) {

Comment thread mq/rabbit/broker_queue.go Outdated

if err != nil {
b.log.Error("consuming queue deliveries", wlog.Err(err))
if !b.sleep() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Передавайте контекст у метод sleep.

Suggested change
if !b.sleep() {
if !b.sleep(ctx) {

Comment thread store/store.go Outdated
Delete(ctx context.Context, deleteCmd *model.DeleteSkillPresetCmd) model.AppError
Search(ctx context.Context, search *model.SearchOnlineSkillsQuery) ([]*model.OnlineSkills, model.AppError)
Get(ctx context.Context, search *model.GetSkillPresetQuery) (*model.OnlineSkills, model.AppError)
CreateSystem(cxt context.Context, domainID int) model.AppError

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Виправлення типу domainID на int64 та імені контексту на ctx.

Suggested change
CreateSystem(cxt context.Context, domainID int) model.AppError
CreateSystem(ctx context.Context, domainID int64) model.AppError

Comment thread store/sqlstore/online_skills.go Outdated
return result, nil
}

func (s *SqlOnlineSkillsStore) CreateSystem(ctx context.Context, domainID int) model.AppError {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зміна типу domainID на int64.

Suggested change
func (s *SqlOnlineSkillsStore) CreateSystem(ctx context.Context, domainID int) model.AppError {
func (s *SqlOnlineSkillsStore) CreateSystem(ctx context.Context, domainID int64) model.AppError {

@suifri
suifri force-pushed the feature/WTEL-10383-default-system-online-skill-creation-on-domain-init branch from f1e0a34 to fc11f74 Compare September 10, 2026 09:15

@webitel-review webitel-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Webitel Code Review — пропозиції змін

Comment thread app/app.go Outdated
Comment on lines +203 to +204
app.MessageQueue.Start()
app.initDomainEventListener()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ініціалізуйте слухач подій доменів перед запуском черги повідомлень, щоб уникнути втрати подій, які вже є в черзі на момент старту.

Suggested change
app.MessageQueue.Start()
app.initDomainEventListener()
app.initDomainEventListener()
app.MessageQueue.Start()

@suifri
suifri force-pushed the feature/WTEL-10383-default-system-online-skill-creation-on-domain-init branch 2 times, most recently from 45108e6 to 1b685ca Compare September 10, 2026 09:51
domain event

- add creation of simple topic broker queue
- add queue configuration object
- add new domain created handler
@suifri
suifri force-pushed the feature/WTEL-10383-default-system-online-skill-creation-on-domain-init branch from 1b685ca to 3ffdcb7 Compare September 10, 2026 12:45

@webitel-review webitel-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Webitel Code Review — пропозиції змін

Comment thread model/domain.go
if len(splitted) < 3 {
return nil, NewBadRequestError(
"model.domain.new_domain_event.invalid_rk_len",
"received roting key with len less than 3",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Виправлення друкарської помилки

Suggested change
"received roting key with len less than 3",
"received routing key with len less than 3",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant