Инструменты пользователя

Инструменты сайта


open:tech:dev:ticket_lifetime

Common Ticket Lifetime

  1. One or several tickets might be created as a result of system events. Ticket is an instance in the database.
  2. Ticket creator - a man or a system whose moves results in the ticket appearance.
  3. Ticket can’t be automatically assigned to anybody. Tickets could be assigned to a group role so anyone in this group will get an acceptance notification (it might be repeated few times by service bots). If nobody accept a ticket then after period of time ticket creator got timeout out of service message.
  4. Each ticket has its lifetime. Any step got monitored by a bots-services that can change the step (change ticket status and send notification to next step bot) or proceed an order the other way. Each service may result in adding new tickets with their own lifetime. Everything should be done by service bots using platform Web API, Metaservice Web API or other APIs.
  5. The Idea for the bot-services moves is to make all the tickets done as soon as possible.
  6. Each Metaservice has a standard set of bot-services connected to an order. Service settings (like waiting time, etc) could be adjusted in the Metaservice settings (Service settings inside administration panel - 2 parameters for each ticket type - lifetime and notification frequency).

How status codes could be stored:

[[1,2],[2,3],[3,4,5]]

First number is current state, others is possible next states for a ticket, second number - normal positive solution. Each state is written as a code. Codes descriptions stored in a table for Web API use.

Normally service should provide a bot that transfers ticket from current state to the next normal one. If that’s not possible it tries to process to another state if available. If that can’t be done - it keeps the current state and makes an error ticket to the group that is responsible for that process to proceed manually. Usually that means that the code running and the database doesn’t match (e.g. because of the update).

After ticket got closed, it’s stored the time specified in the service settings, then deleted or archieved.

Each bot-service operates the following way:

  1. Periodically checks tickets it is responsible for. Each period of time sends notifications for unclosed ones. Executes ticket process for for missed ones.
  2. Listens for notifications for the new tickets send by other bot-services. Executes base ticket process for all incoming tickets.
  3. After a specified period of time creates an error message is the ticket remains in its list.
  4. Listens to all the events for the current ticket state.
  5. Changes the state for a ticket if needed. Sends notification for the next bot-service.

Each bot-service is named the following name:

$metaservice-$ticket_type_name-$state_code-$state_name

Names needed to make code readable for programmers.

All bot-services should be running on the server all the time and restarted if needed. There should be a process that checks if all the bots-services are running using data from the database. Zabbix should monitor this process.

After restart process bot does 1 step before any other operations.

All bot-services should be multithreaded.

Common functions for bot-services

  1. proceed_ticket(ticket_number) - name of the main function of the bot-service. For different types of tickets and services could consist of different operations. In the end function add_ticket_to_proceeded_list should be called.
  2. add_ticket_to_proceeded_list(ticket_number) - adds current ticket to proceeded_list after all the operations according to the state.
  3. create_ticket(current_ticket_number) - creates a ticket as a result of current one’s state
  4. send_ticket(ticket_number) - send ticket to the next state.
  5. get_current_ticket_list - get ticket list from the DB that needs to be proceeded by current bot-service. The result is current_ticket_list
  6. check_ticket_list - compares tickets in current_ticket_list and proceeded_list. Tickets that appears in the current_ticket_list but not in proceeded_list should be added using proceed_ticket.
  7. ticket_timeout(ticket_number) - function to proceed tickets that gets timeout. That is the only one function to get read of the stucked tickets. Normally tickets should be sent to the next step for proceeding. The last step accumulates tickets and clears it after some period of time using this function.
  8. send_bot_notification (current_ticket, bot, text) - function for sending notifications during tickets processing.
  9. send_user_notification (current_ticket, user, text) - function for sending notifications during tickets processing.
  10. parse_notification(notification) - parse notifications got by bot-service in order to choose the function to proceed.

What could be done in proceed_ticket function (in addition to the functions that was mentioned before):

  1. get_assigned_user(ticket_number) - a call to the database to get UID for notifications;
  2. set_assigned_user(ticket_number, user) - changes info about assignment (should contain checks);
  3. wait(ticket_number, time) - return to the process after some period of time
  4. wait_until_time(ticket_number, date) - return to the process after the time specified;
  5. wait_until_ticket(current_ticket_number, ticket_to_wait) - return to the process after another ticket got closed.

There might be other functions for ticket processing that is not mentioned above.

open/tech/dev/ticket_lifetime.txt · Последнее изменение: 2022/09/11 22:37 — sharixadmin

© 2022 ShariX