CN115920371A - Game service request processing method, device, computer equipment and storage medium - Google Patents
Game service request processing method, device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN115920371A CN115920371A CN202211632392.4A CN202211632392A CN115920371A CN 115920371 A CN115920371 A CN 115920371A CN 202211632392 A CN202211632392 A CN 202211632392A CN 115920371 A CN115920371 A CN 115920371A
- Authority
- CN
- China
- Prior art keywords
- service
- message
- account
- request
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Landscapes
- Information Transfer Between Computers (AREA)
Abstract
Description
技术领域technical field
本公开涉及计算机技术领域,特别涉及一种游戏业务请求的处理方法、装置、计算机设备及存储介质。The present disclosure relates to the field of computer technology, and in particular to a method, device, computer equipment and storage medium for processing game service requests.
背景技术Background technique
随着计算机技术的发展和移动终端的普及,手机游戏逐渐成为一种较为盛行的游戏类型。在目前的游戏后端开发技术中,采用整体式结构来设计游戏的业务主逻辑,比如,射线检测、伤害计算、游戏聊天、游戏邮件收取等业务都由游戏服务器后端的主逻辑进程来提供支持。With the development of computer technology and the popularization of mobile terminals, mobile games have gradually become a relatively popular game type. In the current game back-end development technology, an integral structure is adopted to design the main logic of the game’s business. For example, services such as ray detection, damage calculation, game chat, and game email collection are all supported by the main logic process at the back-end of the game server. .
然而,在涉及到多用户间频繁通信的联机游戏场景下,随着业务迭代和版本更新,代码量会不断累加,在整体式架构中修改或新增业务时,其开发复杂度越来越高,且当某项业务功能阻塞时,可能会导致整个主逻辑进程不可用,因此,整体式架构的游戏开发效率低、游戏可用性低。However, in an online game scenario that involves frequent communication between multiple users, the amount of code will continue to accumulate with business iterations and version updates. When modifying or adding new services in the overall architecture, the development complexity will become higher and higher. , and when a certain business function is blocked, the entire main logic process may be unavailable. Therefore, the game development efficiency and game availability of the overall architecture are low.
发明内容Contents of the invention
本公开提供一种游戏业务请求的处理方法、装置、计算机设备及存储介质,以至少提升游戏开发效率和游戏可用性。本公开的技术方案如下:The present disclosure provides a game service request processing method, device, computer equipment, and storage medium, so as to at least improve game development efficiency and game usability. The disclosed technical scheme is as follows:
根据本公开实施例的一方面,提供一种游戏业务请求的处理方法,包括:According to an aspect of an embodiment of the present disclosure, a method for processing a game service request is provided, including:
响应于账号的游戏业务请求,确定所述游戏业务请求的业务类型,所述业务类型指示所述游戏业务请求所关联的游戏业务的时效属性;Responding to the game service request of the account, determining the service type of the game service request, the service type indicating the timeliness attribute of the game service associated with the game service request;
在所述业务类型指示所述游戏业务为非实时业务的情况下,确定所述非实时业务相匹配的服务接口;When the service type indicates that the game service is a non-real-time service, determine a service interface that matches the non-real-time service;
从服务注册中心中查询用于提供所述服务接口的业务服务器的地址,所述服务注册中心用于记录各类接口的业务服务器的地址;Query the address of the service server for providing the service interface from the service registration center, and the service registration center is used to record the addresses of the service servers of various interfaces;
基于所述服务接口,向所述地址发送远程过程调用RPC请求,所述RPC请求用于指示所述业务服务器向所述账号提供对所述游戏业务的响应。Sending a remote procedure call (RPC) request to the address based on the service interface, where the RPC request is used to instruct the service server to provide the account with a response to the game service.
在一些实施例中,所述从服务注册中心中查询用于提供所述服务接口的业务服务器的地址包括:In some embodiments, the querying the address of the service server for providing the service interface from the service registry includes:
从所述服务注册中心中,查询用于提供所述服务接口的地址集合;From the service registration center, query the set of addresses used to provide the service interface;
从所述地址集合中,查询与所述账号地理距离最近的业务服务器的地址。From the address set, query the address of the service server with the closest geographic distance to the account.
在一些实施例中,所述方法还包括:In some embodiments, the method also includes:
通过所述业务服务器响应于所述RPC请求,创建所述非实时业务的协程;Create a coroutine of the non-real-time service through the service server in response to the RPC request;
通过所述协程发起所述非实时业务的数据库操作;Initiating the database operation of the non-real-time service through the coroutine;
在获取到对所述数据库操作的操作结果前,阻塞并挂起所述协程;Before obtaining the operation result of the operation on the database, block and suspend the coroutine;
在获取到对所述数据库操作的操作结果后,返回基于所述操作结果生成的响应。After the operation result of the database operation is acquired, a response generated based on the operation result is returned.
在一些实施例中,所述游戏业务请求为邮件列表拉取请求;所述通过所述协程发起所述非实时业务的数据库操作包括:In some embodiments, the game service request is a mailing list pull request; the database operation of initiating the non-real-time service through the coroutine includes:
通过所述协程,从所述邮件列表拉取请求中,获取所述账号的已拉取邮件中的最大个人邮件序列号和最大系统邮件序列号;Obtain the maximum personal email serial number and the largest system email serial number in the pulled emails of the account from the mailing list pull request through the coroutine;
基于所述最大个人邮件序列号,向数据库中所述账号的个人邮件集合发起对个人邮件的批量读取操作,所述批量读取操作用于读取邮件序列号大于所述最大个人邮件序列号的多封个人邮件;Based on the maximum personal mail serial number, initiate a batch read operation of personal mail to the personal mail collection of the account in the database, and the batch read operation is used to read mail whose serial number is greater than the maximum personal mail serial number multiple personal emails from
基于所述最大系统邮件序列号,向数据库的系统邮件集合发起对系统邮件的批量读取操作,所述批量读取操作用于读取邮件序列号大于所述最大系统邮件序列号的多封系统邮件。Based on the maximum system mail serial number, a batch read operation of system mail is initiated to the system mail collection of the database, and the batch read operation is used to read multiple system mails whose serial number is greater than the maximum system mail serial number mail.
在一些实施例中,所述游戏业务请求为邮件列表拉取请求;所述通过所述协程发起所述非实时业务的数据库操作包括:In some embodiments, the game service request is a mailing list pull request; the database operation of initiating the non-real-time service through the coroutine includes:
通过所述协程获取所述邮件列表拉取请求中携带的所述账号的已拉取邮件中的最大邮件序列号;Obtaining the maximum mail sequence number among the pulled mails of the account carried in the mailing list pull request through the coroutine;
基于所述最大邮件序列号,向数据库的系统邮件集合发起对系统邮件的批量读取操作,所述批量读取操作用于读取邮件序列号大于所述最大邮件序列号的多封系统邮件;Based on the maximum mail sequence number, initiate a batch read operation of system mail to the system mail collection of the database, the batch read operation is used to read multiple system mails whose mail sequence numbers are greater than the maximum mail sequence number;
将所述多封系统邮件存入所述数据库中所述账号的个人邮件集合;storing the plurality of system emails into the personal email collection of the account in the database;
基于所述最大邮件序列号,向所述个人邮件集合发起对邮件的批量读取操作,所述批量读取操作用于读取邮件序列号大于所述最大邮件序列号的多封邮件。Based on the maximum mail sequence number, a batch read operation of mails is initiated to the personal mail collection, and the batch read operation is used to read a plurality of mails whose mail sequence numbers are greater than the maximum mail sequence number.
在一些实施例中,所述方法还包括:In some embodiments, the method also includes:
基于所述批量读取操作的操作结果所返回的多封邮件,确定邮件未读数量;Determine the number of unread emails based on the plurality of emails returned by the operation result of the batch read operation;
提取所述多封邮件的信息摘要,所述信息摘要用于提供以下至少一项:邮件类型、邮件标题、发件人信息、邮件时间戳以及是否含有附件;extracting information summaries of the plurality of emails, where the information summaries are used to provide at least one of the following: email type, email title, sender information, email timestamp and whether it contains attachments;
生成携带所述信息摘要和所述邮件未读数量的响应。A response carrying the message digest and the number of unread emails is generated.
在一些实施例中,所述方法还包括:In some embodiments, the method also includes:
在同一时间段内累计接收到的多个邮件列表拉取请求的数量超过请求量阈值的情况下,通过所述业务服务器缓存所述多个邮件列表拉取请求关联的多个RPC请求到消息队列中;In the case where the number of multiple mailing list pull requests received in the same time period exceeds the request volume threshold, multiple RPC requests associated with the multiple mailing list pull requests are cached by the business server and sent to the message queue middle;
在所述消息队列中,合并同一发起账号多次发送的相同邮件列表拉取请求关联的RPC请求,对所述发起账号配置请求次数变量;In the message queue, merge the RPC requests associated with the same mailing list pull request sent by the same initiating account multiple times, and configure the request times variable for the initiating account;
基于所述请求次数变量,对所述消息队列中的各个RPC请求进行重排序;Reordering each RPC request in the message queue based on the request times variable;
每间隔目标时长,分批处理重排序后的消息队列中处于当前批次的至少一个RPC请求。At least one RPC request in the current batch in the reordered message queue is processed in batches at each target time interval.
在一些实施例中,所述游戏业务请求为邮件详情拉取请求;所述通过所述协程发起所述非实时业务的数据库操作包括:In some embodiments, the game service request is a pull request for email details; the database operation of initiating the non-real-time service through the coroutine includes:
通过所述协程确定所述邮件详情拉取请求所请求拉取的邮件类型和邮件序列号;Determine the email type and email serial number requested by the email details pull request through the coroutine;
向数据库中所述邮件类型所指示的邮件集合,发起对所述邮件序列号所指示的邮件的读取操作,所述读取操作用于读取所述邮件的邮件正文,并在所述邮件携带附件的情况下还读取所述附件。To the mail set indicated by the mail type in the database, initiate a read operation on the mail indicated by the mail sequence number, the read operation is used to read the mail body of the mail, and The attachment is also read if it is carried.
在一些实施例中,所述游戏业务请求为邮件发送请求;所述通过所述协程发起所述非实时业务的数据库操作包括:In some embodiments, the game service request is an email sending request; the database operation of initiating the non-real-time service through the coroutine includes:
通过所述协程确定所述邮件发送请求所指示的待发送邮件的邮件类型;determining the mail type of the mail to be sent indicated by the mail sending request through the coroutine;
在所述邮件类型为个人邮件的情况下,向数据库中所述账号的个人邮件集合发起对所述待发送邮件的写入操作;In the case that the email type is personal email, initiate a write operation of the email to be sent to the personal email collection of the account in the database;
在所述邮件类型为系统邮件的情况下,向数据库的系统邮件集合发起对所述待发送邮件的写入操作。In the case that the email type is a system email, a write operation of the email to be sent is initiated to the system email collection of the database.
在一些实施例中,所述方法还包括:In some embodiments, the method also includes:
基于所述写入操作的操作结果,为所述待发送邮件分配邮件序列号;assigning a mail serial number to the mail to be sent based on the operation result of the writing operation;
在所述待发送邮件的收件人账号处于游戏离线状态的情况下,生成向所述账号通知邮件发送成功的响应;When the recipient account of the email to be sent is offline in the game, generate a response to notify the account that the email is sent successfully;
在所述待发送邮件的收件人账号处于游戏在线状态的情况下,生成向所述账号通知邮件发送成功的响应;以及,生成向所述收件人账号推送所述待发送邮件的响应。When the recipient account of the email to be sent is online in the game, generate a response to notify the account that the email is successfully sent; and generate a response to push the email to the recipient account.
在一些实施例中,所述游戏业务请求为未读消息拉取请求;所述通过所述协程发起所述非实时业务的数据库操作包括:In some embodiments, the game service request is an unread message pull request; the database operation of initiating the non-real-time service through the coroutine includes:
通过所述协程,从所述未读消息拉取请求中,获取待查询账号以及最大消息标识,所述最大消息标识指示所述账号和所述待查询账号的会话中的最新已读消息;Obtain an account to be queried and a maximum message identifier from the unread message pull request through the coroutine, where the maximum message identifier indicates the latest read message in a conversation between the account and the account to be queried;
基于所述最大消息标识,向数据库中所述账号和所述待查询账号的消息集合发起对未读消息的批量读取操作,所述批量读取操作用于读取消息标识大于所述最大消息标识的多条消息。Based on the maximum message identifier, initiate a batch read operation of unread messages to the message set of the account and the account to be queried in the database, and the batch read operation is used to read a message whose identifier is greater than the maximum message Multiple messages identified.
在一些实施例中,所述方法还包括:In some embodiments, the method also includes:
基于所述批量读取操作的操作结果所返回的多条消息,确定未读消息数量;determining the number of unread messages based on the multiple messages returned by the operation result of the batch read operation;
生成携带所述多条未读消息和所述未读消息数量的响应。A response carrying the plurality of unread messages and the number of unread messages is generated.
在一些实施例中,所述游戏业务请求为消息发送请求;所述通过所述协程发起所述非实时业务的数据库操作包括:In some embodiments, the game service request is a message sending request; the database operation of initiating the non-real-time service through the coroutine includes:
通过所述协程确定所述消息发送请求所指示的待发送消息的消息类型;determining the message type of the message to be sent indicated by the message sending request through the coroutine;
在所述消息类型为个人消息的情况下,向数据库中所述账号和消息接收账号的消息集合发起对所述待发送消息的写入操作;In the case that the message type is a personal message, initiate a write operation on the message to be sent to the message set of the account and message receiving account in the database;
在所述消息类型为群组消息的情况下,向数据库中消息接收群组的消息集合发起对所述待发送消息的写入操作。In the case that the message type is a group message, a write operation of the message to be sent is initiated to the message set of the message receiving group in the database.
在一些实施例中,所述方法还包括:In some embodiments, the method also includes:
基于所述写入操作的操作结果,为所述待发送消息分配消息标识,生成向所述账号通知消息发送成功的响应;Based on the operation result of the write operation, assign a message identifier to the message to be sent, and generate a response to notify the account that the message is successfully sent;
对于所述个人消息,仅在所述消息接收账号处于游戏在线状态的情况下,生成向所述消息接收账号推送所述待发送消息的响应;For the personal message, generate a response to push the message to be sent to the message receiving account only when the message receiving account is in the online state of the game;
对于所述群组消息,拉取所述消息接收群组的最新成员列表;仅对所述最新成员列表中的在线成员账号,生成向所述在线成员账号推送所述待发送消息的响应。For the group message, pull the latest member list of the message receiving group; only for the online member accounts in the latest member list, generate a response to push the message to be sent to the online member account.
在一些实施例中,所述游戏业务请求为账号添加请求,所述账号添加请求用于申请将目标账号添加到所述账号的账号关系链上;所述通过所述协程发起所述非实时业务的数据库操作包括:In some embodiments, the game service request is an account addition request, and the account addition request is used to apply for adding the target account to the account relationship chain of the account; Business database operations include:
通过所述协程,对所述账号进行权限验证;Perform authority verification on the account through the coroutine;
在验证通过后,向数据库发起写入由所述账号向所述目标账号的账号添加记录的数据库操作;After the verification is passed, initiate a database operation of writing the account addition record of the account to the target account to the database;
所述在获取到对所述数据库操作的操作结果后,返回基于所述操作结果生成的响应包括:After obtaining the operation result of the database operation, returning a response generated based on the operation result includes:
在所述操作结果指示对所述账号添加记录写入完毕的情况下,生成对所述目标账号的账号添加通知响应。When the operation result indicates that writing of the account addition record is completed, an account addition notification response to the target account is generated.
根据本公开实施例的另一方面,提供一种游戏业务请求的处理装置,包括:According to another aspect of the embodiments of the present disclosure, an apparatus for processing game service requests is provided, including:
确定单元,被配置为执行响应于账号的游戏业务请求,确定所述游戏业务请求的业务类型,所述业务类型指示所述游戏业务请求所关联的游戏业务的时效属性;The determining unit is configured to execute a game service request in response to an account, determine a service type of the game service request, and the service type indicates the timeliness attribute of the game service associated with the game service request;
所述确定单元,还被配置为执行在所述业务类型指示所述游戏业务为非实时业务的情况下,确定所述非实时业务相匹配的服务接口;The determining unit is further configured to determine a service interface matching the non-real-time service when the service type indicates that the game service is a non-real-time service;
查询单元,被配置为执行从服务注册中心中查询用于提供所述服务接口的业务服务器的地址,所述服务注册中心用于记录各类接口的业务服务器的地址;The query unit is configured to query the address of the service server for providing the service interface from the service registration center, and the service registration center is used to record the addresses of the service servers of various interfaces;
发送单元,被配置为执行基于所述服务接口,向所述地址发送远程过程调用RPC请求,所述RPC请求用于指示所述业务服务器向所述账号提供对所述游戏业务的响应。The sending unit is configured to send a remote procedure call (RPC) request to the address based on the service interface, and the RPC request is used to instruct the service server to provide the account with a response to the game service.
在一些实施例中,所述查询单元被配置为执行:In some embodiments, the query unit is configured to perform:
从所述服务注册中心中,查询用于提供所述服务接口的地址集合;From the service registration center, query the set of addresses used to provide the service interface;
从所述地址集合中,查询与所述账号地理距离最近的业务服务器的地址。From the address set, query the address of the service server with the closest geographic distance to the account.
在一些实施例中,所述装置还包括:In some embodiments, the device also includes:
创建单元,被配置为执行通过所述业务服务器响应于所述RPC请求,创建所述非实时业务的协程;a creation unit configured to execute a coroutine for creating the non-real-time service in response to the RPC request through the service server;
发起单元,被配置为执行通过所述协程发起所述非实时业务的数据库操作;an initiating unit configured to execute the database operation of initiating the non-real-time service through the coroutine;
阻塞单元,被配置为执行在获取到对所述数据库操作的操作结果前,阻塞并挂起所述协程;A blocking unit configured to block and suspend the coroutine before obtaining the operation result of the database operation;
返回单元,被配置为执行在获取到对所述数据库操作的操作结果后,返回基于所述操作结果生成的响应。The returning unit is configured to, after obtaining the operation result of the database operation, return a response generated based on the operation result.
在一些实施例中,所述游戏业务请求为邮件列表拉取请求;所述发起单元被配置为执行:In some embodiments, the game service request is a mailing list pull request; the initiating unit is configured to perform:
通过所述协程,从所述邮件列表拉取请求中,获取所述账号的已拉取邮件中的最大个人邮件序列号和最大系统邮件序列号;Obtain the maximum personal email serial number and the largest system email serial number in the pulled emails of the account from the mailing list pull request through the coroutine;
基于所述最大个人邮件序列号,向数据库中所述账号的个人邮件集合发起对个人邮件的批量读取操作,所述批量读取操作用于读取邮件序列号大于所述最大个人邮件序列号的多封个人邮件;Based on the maximum personal mail serial number, initiate a batch read operation of personal mail to the personal mail collection of the account in the database, and the batch read operation is used to read mail whose serial number is greater than the maximum personal mail serial number multiple personal emails from
基于所述最大系统邮件序列号,向数据库的系统邮件集合发起对系统邮件的批量读取操作,所述批量读取操作用于读取邮件序列号大于所述最大系统邮件序列号的多封系统邮件。Based on the maximum system mail serial number, a batch read operation of system mail is initiated to the system mail collection of the database, and the batch read operation is used to read multiple system mails whose serial number is greater than the maximum system mail serial number mail.
在一些实施例中,所述游戏业务请求为邮件列表拉取请求;所述发起单元被配置为执行:In some embodiments, the game service request is a mailing list pull request; the initiating unit is configured to perform:
通过所述协程获取所述邮件列表拉取请求中携带的所述账号的已拉取邮件中的最大邮件序列号;Obtaining the maximum mail sequence number among the pulled mails of the account carried in the mailing list pull request through the coroutine;
基于所述最大邮件序列号,向数据库的系统邮件集合发起对系统邮件的批量读取操作,所述批量读取操作用于读取邮件序列号大于所述最大邮件序列号的多封系统邮件;Based on the maximum mail sequence number, initiate a batch read operation of system mail to the system mail collection of the database, the batch read operation is used to read multiple system mails whose mail sequence numbers are greater than the maximum mail sequence number;
将所述多封系统邮件存入所述数据库中所述账号的个人邮件集合;storing the plurality of system emails into the personal email collection of the account in the database;
基于所述最大邮件序列号,向所述个人邮件集合发起对邮件的批量读取操作,所述批量读取操作用于读取邮件序列号大于所述最大邮件序列号的多封邮件。Based on the maximum mail sequence number, a batch read operation of mails is initiated to the personal mail collection, and the batch read operation is used to read a plurality of mails whose mail sequence numbers are greater than the maximum mail sequence number.
在一些实施例中,所述装置还包括生成单元,被配置为执行:In some embodiments, the apparatus further includes a generating unit configured to:
基于所述批量读取操作的操作结果所返回的多封邮件,确定邮件未读数量;Determine the number of unread emails based on the plurality of emails returned by the operation result of the batch read operation;
提取所述多封邮件的信息摘要,所述信息摘要用于提供以下至少一项:邮件类型、邮件标题、发件人信息、邮件时间戳以及是否含有附件;extracting information summaries of the plurality of emails, where the information summaries are used to provide at least one of the following: email type, email title, sender information, email timestamp and whether it contains attachments;
生成携带所述信息摘要和所述邮件未读数量的响应。A response carrying the message digest and the number of unread emails is generated.
在一些实施例中,所述装置还包括分批处理单元,被配置为执行:In some embodiments, the apparatus further comprises a batch processing unit configured to perform:
在同一时间段内累计接收到的多个邮件列表拉取请求的数量超过请求量阈值的情况下,通过所述业务服务器缓存所述多个邮件列表拉取请求关联的多个RPC请求到消息队列中;In the case where the number of multiple mailing list pull requests received in the same time period exceeds the request volume threshold, multiple RPC requests associated with the multiple mailing list pull requests are cached by the business server and sent to the message queue middle;
在所述消息队列中,合并同一发起账号多次发送的相同邮件列表拉取请求关联的RPC请求,对所述发起账号配置请求次数变量;In the message queue, merge the RPC requests associated with the same mailing list pull request sent by the same initiating account multiple times, and configure the request times variable for the initiating account;
基于所述请求次数变量,对所述消息队列中的各个RPC请求进行重排序;Reordering each RPC request in the message queue based on the request times variable;
每间隔目标时长,分批处理重排序后的消息队列中处于当前批次的至少一个RPC请求。At least one RPC request in the current batch in the reordered message queue is processed in batches at each target time interval.
在一些实施例中,所述游戏业务请求为邮件详情拉取请求;所述发起单元被配置为执行:In some embodiments, the game service request is a pull request for email details; the initiating unit is configured to perform:
通过所述协程确定所述邮件详情拉取请求所请求拉取的邮件类型和邮件序列号;Determine the email type and email serial number requested by the email details pull request through the coroutine;
向数据库中所述邮件类型所指示的邮件集合,发起对所述邮件序列号所指示的邮件的读取操作,所述读取操作用于读取所述邮件的邮件正文,并在所述邮件携带附件的情况下还读取所述附件。To the mail set indicated by the mail type in the database, initiate a read operation on the mail indicated by the mail sequence number, the read operation is used to read the mail body of the mail, and The attachment is also read if it is carried.
在一些实施例中,所述游戏业务请求为邮件发送请求;所述发起单元被配置为执行:In some embodiments, the game service request is an email sending request; the initiating unit is configured to perform:
通过所述协程确定所述邮件发送请求所指示的待发送邮件的邮件类型;determining the mail type of the mail to be sent indicated by the mail sending request through the coroutine;
在所述邮件类型为个人邮件的情况下,向数据库中所述账号的个人邮件集合发起对所述待发送邮件的写入操作;In the case that the email type is personal email, initiate a write operation of the email to be sent to the personal email collection of the account in the database;
在所述邮件类型为系统邮件的情况下,向数据库的系统邮件集合发起对所述待发送邮件的写入操作。In the case that the email type is a system email, a write operation of the email to be sent is initiated to the system email collection of the database.
在一些实施例中,所述装置还包括生成单元,被配置为执行:In some embodiments, the apparatus further includes a generating unit configured to:
基于所述写入操作的操作结果,为所述待发送邮件分配邮件序列号;assigning a mail serial number to the mail to be sent based on the operation result of the writing operation;
在所述待发送邮件的收件人账号处于游戏离线状态的情况下,生成向所述账号通知邮件发送成功的响应;When the recipient account of the email to be sent is offline in the game, generate a response to notify the account that the email is sent successfully;
在所述待发送邮件的收件人账号处于游戏在线状态的情况下,生成向所述账号通知邮件发送成功的响应;以及,生成向所述收件人账号推送所述待发送邮件的响应。When the recipient account of the email to be sent is online in the game, generate a response to notify the account that the email is successfully sent; and generate a response to push the email to the recipient account.
在一些实施例中,所述游戏业务请求为未读消息拉取请求;所述发起单元被配置为执行:In some embodiments, the game service request is an unread message pull request; the initiating unit is configured to perform:
通过所述协程,从所述未读消息拉取请求中,获取待查询账号以及最大消息标识,所述最大消息标识指示所述账号和所述待查询账号的会话中的最新已读消息;Obtain an account to be queried and a maximum message identifier from the unread message pull request through the coroutine, where the maximum message identifier indicates the latest read message in a conversation between the account and the account to be queried;
基于所述最大消息标识,向数据库中所述账号和所述待查询账号的消息集合发起对未读消息的批量读取操作,所述批量读取操作用于读取消息标识大于所述最大消息标识的多条消息。Based on the maximum message identifier, initiate a batch read operation of unread messages to the message set of the account and the account to be queried in the database, and the batch read operation is used to read a message whose identifier is greater than the maximum message Multiple messages identified.
在一些实施例中,所述装置还包括生成单元,被配置为执行:In some embodiments, the apparatus further includes a generating unit configured to:
基于所述批量读取操作的操作结果所返回的多条消息,确定未读消息数量;Determine the number of unread messages based on the multiple messages returned by the operation result of the batch read operation;
生成携带所述多条未读消息和所述未读消息数量的响应。A response carrying the plurality of unread messages and the number of unread messages is generated.
在一些实施例中,所述游戏业务请求为消息发送请求;所述发起单元被配置为执行:In some embodiments, the game service request is a message sending request; the initiating unit is configured to perform:
通过所述协程确定所述消息发送请求所指示的待发送消息的消息类型;determining the message type of the message to be sent indicated by the message sending request through the coroutine;
在所述消息类型为个人消息的情况下,向数据库中所述账号和消息接收账号的消息集合发起对所述待发送消息的写入操作;In the case that the message type is a personal message, initiate a write operation of the message to be sent to the message set of the account and message receiving account in the database;
在所述消息类型为群组消息的情况下,向数据库中消息接收群组的消息集合发起对所述待发送消息的写入操作。In the case that the message type is a group message, a write operation of the message to be sent is initiated to the message set of the message receiving group in the database.
在一些实施例中,所述装置还包括生成单元,被配置为执行:In some embodiments, the apparatus further includes a generating unit configured to:
基于所述写入操作的操作结果,为所述待发送消息分配消息标识,生成向所述账号通知消息发送成功的响应;Based on the operation result of the write operation, assign a message identifier to the message to be sent, and generate a response to notify the account that the message is successfully sent;
对于所述个人消息,仅在所述消息接收账号处于游戏在线状态的情况下,生成向所述消息接收账号推送所述待发送消息的响应;For the personal message, generate a response to push the message to be sent to the message receiving account only when the message receiving account is in the online state of the game;
对于所述群组消息,拉取所述消息接收群组的最新成员列表;仅对所述最新成员列表中的在线成员账号,生成向所述在线成员账号推送所述待发送消息的响应。For the group message, pull the latest member list of the message receiving group; only for the online member accounts in the latest member list, generate a response to push the message to be sent to the online member account.
在一些实施例中,所述游戏业务请求为账号添加请求,所述账号添加请求用于申请将目标账号添加到所述账号的账号关系链上;所述发起单元被配置为执行:In some embodiments, the game service request is an account addition request, and the account addition request is used to apply for adding the target account to the account relationship chain of the account; the initiating unit is configured to execute:
通过所述协程,对所述账号进行权限验证;Perform authority verification on the account through the coroutine;
在验证通过后,向数据库发起写入由所述账号向所述目标账号的账号添加记录的数据库操作;After the verification is passed, initiate a database operation of writing the account addition record of the account to the target account to the database;
所述装置还包括生成单元,被配置为执行:The apparatus also includes a generating unit configured to perform:
在所述操作结果指示对所述账号添加记录写入完毕的情况下,生成对所述目标账号的账号添加通知响应。When the operation result indicates that writing of the account addition record is completed, an account addition notification response to the target account is generated.
根据本公开实施例的另一方面,提供一种计算机设备,包括:According to another aspect of an embodiment of the present disclosure, there is provided a computer device, including:
一个或多个处理器;one or more processors;
用于存储所述一个或多个处理器可执行指令的一个或多个存储器;one or more memories for storing said one or more processor-executable instructions;
其中,所述一个或多个处理器被配置为执行上述一方面的任一种可能实施方式中的游戏业务请求的处理方法。Wherein, the one or more processors are configured to execute the method for processing game service requests in any possible implementation manner of the above aspect.
根据本公开实施例的另一方面,提供一种计算机可读存储介质,当所述计算机可读存储介质中的至少一条指令由计算机设备的一个或多个处理器执行时,使得所述计算机设备能够执行上述一方面的任一种可能实施方式中的游戏业务请求的处理方法。According to another aspect of the embodiments of the present disclosure, there is provided a computer-readable storage medium. When at least one instruction in the computer-readable storage medium is executed by one or more processors of a computer device, the computer device The method for processing game service requests in any possible implementation manner of the above aspect can be implemented.
根据本公开实施例的另一方面,提供一种计算机程序产品,包括一条或多条指令,所述一条或多条指令可以由计算机设备的一个或多个处理器执行,使得所述计算机设备能够执行上述一方面的任一种可能实施方式中的游戏业务请求的处理方法。According to another aspect of an embodiment of the present disclosure, there is provided a computer program product including one or more instructions executable by one or more processors of a computer device, so that the computer device can Execute the method for processing game service requests in any possible implementation manner of the above aspect.
本公开的实施例提供的技术方案至少带来以下有益效果:The technical solutions provided by the embodiments of the present disclosure bring at least the following beneficial effects:
通过对于请求非实时业务的游戏业务请求,由于实时性要求不高,无需游戏服务器本地进行实时处理,由此在服务注册中心中查询到专用于处理该非实时业务的服务API,再通过该服务API对远程的业务服务器进行RPC远程调用,这样能够将涉及到非实时业务的用户负载从游戏服务器迁移到业务服务器中,优化了游戏服务器的资源配置,且由于针对非实时业务的迭代和更新仅需要修改业务服务器中的代码逻辑,必要时修改服务API,不涉及到对游戏的主业务逻辑打补丁,降低了开发复杂度、提升了游戏开发效率,并且不同类型的非实时业务可单独部署在不同业务服务器中,使得某些业务功能阻塞时,不会影响到其他业务功能的正常使用,且也不会影响到游戏的主业务逻辑,极大提升了游戏可用性。For game service requests that request non-real-time services, since the real-time requirements are not high, there is no need for real-time processing on the game server locally, so the service API dedicated to processing the non-real-time services can be found in the service registration center, and then through the service The API makes RPC remote calls to the remote business server, which can migrate the user load related to non-real-time business from the game server to the business server, optimize the resource configuration of the game server, and because the iteration and update for non-real-time business only It is necessary to modify the code logic in the business server, and modify the service API if necessary, which does not involve patching the main business logic of the game, reduces development complexity, improves game development efficiency, and different types of non-real-time business can be deployed separately on In different business servers, when some business functions are blocked, it will not affect the normal use of other business functions, and will not affect the main business logic of the game, which greatly improves the usability of the game.
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本公开。It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure.
附图说明Description of drawings
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本公开的实施例,并与说明书一起用于解释本公开的原理,并不构成对本公开的不当限定。The accompanying drawings here are incorporated into the specification and constitute a part of the specification, show embodiments consistent with the disclosure, and are used together with the description to explain the principle of the disclosure, and do not constitute an improper limitation of the disclosure.
图1是根据本公开实施例示出的一种游戏业务请求的处理方法的实施环境示意图;FIG. 1 is a schematic diagram of an implementation environment of a method for processing a game service request according to an embodiment of the present disclosure;
图2是根据本公开实施例示出的一种游戏业务请求的处理方法的流程图;Fig. 2 is a flowchart of a method for processing a game service request according to an embodiment of the present disclosure;
图3是根据本公开实施例示出的一种游戏业务请求的处理方法的交互流程图;Fig. 3 is an interactive flowchart of a method for processing a game service request according to an embodiment of the present disclosure;
图4是本公开实施例提供的一种邮件列表拉取业务的处理流程图;Fig. 4 is a processing flowchart of a mailing list pulling service provided by an embodiment of the present disclosure;
图5是本公开实施例提供的一种业务服务器中邮件数据库的逻辑结构图;FIG. 5 is a logical structure diagram of a mail database in a service server provided by an embodiment of the present disclosure;
图6是本公开实施例提供的一种分帧处理邮件列表拉取请求的方法流程图;FIG. 6 is a flow chart of a method for processing mailing list pull requests in frames according to an embodiment of the present disclosure;
图7是本公开实施例提供的一种邮件详情拉取业务的处理流程图;Fig. 7 is a processing flow chart of an email details pulling service provided by an embodiment of the present disclosure;
图8是本公开实施例提供的一种邮件发送业务的处理流程图;Fig. 8 is a processing flowchart of an email sending service provided by an embodiment of the present disclosure;
图9是本公开实施例提供的一种邮件发送业务的处理流程;FIG. 9 is a processing flow of an email sending service provided by an embodiment of the present disclosure;
图10是本公开实施例提供的一种未读消息拉取业务的处理流程图;Fig. 10 is a processing flowchart of an unread message pulling service provided by an embodiment of the present disclosure;
图11是本公开实施例提供的一种未读消息拉取业务的交互流程图;Fig. 11 is an interactive flowchart of an unread message pulling service provided by an embodiment of the present disclosure;
图12是本公开实施例提供的一种红点数据拉取业务的交互流程图;Fig. 12 is an interactive flowchart of a red dot data pulling service provided by an embodiment of the present disclosure;
图13是本公开实施例提供的一种消息发送业务的处理流程图;Fig. 13 is a processing flowchart of a message sending service provided by an embodiment of the present disclosure;
图14是本公开实施例提供的一种消息发送业务的交互流程图;Fig. 14 is an interaction flowchart of a message sending service provided by an embodiment of the present disclosure;
图15是本公开实施例提供的一种消息发送业务的交互流程图;Fig. 15 is an interaction flowchart of a message sending service provided by an embodiment of the present disclosure;
图16是本公开实施例提供的一种账号添加业务的处理流程图;Fig. 16 is a flow chart of processing an account addition service provided by an embodiment of the present disclosure;
图17是本公开实施例提供的一种账号添加业务的交互流程图;Fig. 17 is an interaction flowchart of an account adding service provided by an embodiment of the present disclosure;
图18是本公开实施例提供的一种群组服务系统的业务流程图;Fig. 18 is a business flow chart of a group service system provided by an embodiment of the present disclosure;
图19是根据本公开实施例示出的一种游戏业务请求的处理装置的逻辑结构框图;Fig. 19 is a logical structural block diagram of an apparatus for processing game service requests according to an embodiment of the present disclosure;
图20是本公开实施例提供的一种计算机设备的结构示意图。Fig. 20 is a schematic structural diagram of a computer device provided by an embodiment of the present disclosure.
具体实施方式Detailed ways
为了使本领域普通人员更好地理解本公开的技术方案,下面将结合附图,对本公开实施例中的技术方案进行清楚、完整地描述。In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
需要说明的是,本公开的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本公开的实施例能够以除了在这里图示或描述的那些以外的顺序实施。以下示例性实施例中所描述的实施方式并不代表与本公开相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本公开的一些方面相一致的装置和方法的例子。It should be noted that the terms "first" and "second" in the specification and claims of the present disclosure and the above drawings are used to distinguish similar objects, but not necessarily used to describe a specific sequence or sequence. It is to be understood that the data so used are interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein can be practiced in sequences other than those illustrated or described herein. The implementations described in the following exemplary examples do not represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatuses and methods consistent with aspects of the present disclosure as recited in the appended claims.
需要说明的是,本公开所涉及的用户信息(包括但不限于用户设备信息、用户个人信息等)、数据(包括但不限于用于分析的数据、存储的数据、展示的数据等)以及信号,均为经用户授权或者经过各方充分授权的,且相关数据的收集、使用和处理需要遵守相关国家和地区的相关法律法规和标准。例如,本公开中涉及到的游戏业务请求中携带的信息都是在充分授权的情况下获取的。It should be noted that user information (including but not limited to user equipment information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this disclosure , are authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of the relevant countries and regions. For example, the information carried in the game service request involved in this disclosure is obtained under the condition of sufficient authorization.
在一些实施例中,A和/或B的含义包括:A和B,A,B这三种情况。In some embodiments, the meaning of A and/or B includes: A and B, A, B these three situations.
以下,对本公开实施例涉及的术语进行说明。Hereinafter, terms related to the embodiments of the present disclosure will be described.
API(Application Program Interface,应用程序接口):简称为接口,API被定义为应用可用以与计算机操作系统交换信息和命令的标准集。一个标准的API为用户或软件开发商提供一个通用编程环境,以编写可交互运行于不同厂商计算机的应用。API (Application Program Interface, application program interface): referred to as interface for short, API is defined as a set of standards that applications can use to exchange information and commands with the computer operating system. A standard API provides a common programming environment for users or software developers to write applications that can run interactively on computers from different manufacturers.
服务(Service):服务指在计算机设备中,需要各种服务以支持各种功能,也可以手动开启或关闭某些服务以达到管理相应的功能的目的。Service (Service): Service refers to the computer equipment that requires various services to support various functions, and some services can also be manually turned on or off to achieve the purpose of managing the corresponding functions.
微服务(Micro-Service):一种软件开发技术,是SOA(Service-OrientedArchitecture,面向服务的结构)架构样式的一种变体,它提倡将单一应用划分成一组小的服务,服务之间互相协调、互相配合,为用户提供最终价值。每个服务运行在其独立的进程中,服务与服务间采用轻量级的通信机制互相沟通,通信机制可以是RPC(RemoteProcedure Call,远程过程调用)或者HTTP(Hyper Text Transfer Protocol,超文本传输协议)提供的RESTful API等。每个服务都围绕着具体业务进行构建,并且能够独立地部署到生产环境、类生产环境等。另外,应尽量避免统一的、集中式的服务管理机制,对具体的一个服务而言,应根据上下文,选择合适的语言、工具对其进行构建。Micro-Service (Micro-Service): A software development technology, which is a variant of the SOA (Service-Oriented Architecture, service-oriented structure) architecture style. It advocates dividing a single application into a set of small services, and the services interact with each other. Coordinate and cooperate with each other to provide users with ultimate value. Each service runs in its own independent process, and the services communicate with each other using a lightweight communication mechanism. The communication mechanism can be RPC (Remote Procedure Call, remote procedure call) or HTTP (Hyper Text Transfer Protocol, hypertext transfer protocol) ) provides RESTful API, etc. Each service is built around a specific business and can be independently deployed to production environments, production-like environments, etc. In addition, a unified and centralized service management mechanism should be avoided as much as possible. For a specific service, an appropriate language and tool should be selected to build it according to the context.
远程过程调用(Remote Procedure Call,RPC):类似于三层构架的C/S(Client/Server,客户端/服务端)系统,游戏服务器通过网络向远程的业务服务器请求服务,游戏业务中通常由游戏服务器中的游戏引擎来提供。在本公开实施例中,业务服务器对游戏服务器提供API,游戏服务器针对不同游戏业务,调用游戏业务相匹配的API,以远程调用该API所指示的业务服务器内部的标准或自定义函数,获得函数返回的数据进行处理后显示或打印。Remote Procedure Call (Remote Procedure Call, RPC): similar to the C/S (Client/Server, client/server) system of the three-tier architecture, the game server requests services from the remote business server through the network, and the game business is usually performed by Provided by the game engine in the game server. In the embodiment of the present disclosure, the service server provides an API to the game server, and the game server calls the API that matches the game service for different game services to remotely call the internal standard or custom function of the service server indicated by the API to obtain the function The returned data is processed and displayed or printed.
协程(Coroutine):协程与子例程一样,也是一种程序组件。相对子例程而言,协程更为一般和灵活,协程源自Simula和Modula-2语言,但也有其他语言支持。Coroutine: Like a subroutine, a coroutine is also a program component. Compared with subroutines, coroutines are more general and flexible. Coroutines are derived from Simula and Modula-2 languages, but are also supported by other languages.
以下,对本公开实施例涉及的系统架构进行说明。In the following, the system architecture involved in the embodiments of the present disclosure will be described.
图1是根据本公开实施例示出的一种游戏业务请求的处理方法的实施环境示意图,参见图1,在该实施环境中包括终端110和服务器集群120,服务器集群120中至少包括游戏服务器121和一个或多个业务服务器122,这里以邮件业务服务器122a、消息业务服务器122b和群组业务服务器122c为例进行说明。Fig. 1 is a schematic diagram of an implementation environment of a game service request processing method according to an embodiment of the present disclosure. Referring to Fig. 1 , the implementation environment includes a terminal 110 and a server cluster 120, and the server cluster 120 includes at least a
终端110上安装和运行有支持各类游戏业务的游戏应用,该游戏可以为移动端游戏或PC(Personal Computer,个人计算机)端游戏,该游戏业务涉及实时业务和非实时业务,如游戏内玩家控制虚拟对象位移时的射线检测、玩家控制虚拟对象互动时的伤害判定等均属于实时性要求较高的实时业务,如游戏内玩家互相发送的IM(Instant Messaging,即时通讯)消息、玩家拉取未读邮件列表等均属于实时性要求较低的非实时业务。There are game applications supporting various game services installed and running on the
可选地,上述游戏应用可以是终端110原生内置在操作系统中的应用,可以是终端110独立安装的第三方应用,还可以是嵌入到其他应用中的嵌入式游戏程序,本公开实施例对游戏应用的实施方式不进行具体限定。在一个示例中,游戏应用还为云游戏应用。Optionally, the above-mentioned game application may be an application natively built into the operating system of the terminal 110, a third-party application independently installed on the terminal 110, or an embedded game program embedded in other applications. The implementation of the game application is not specifically limited. In an example, the game application is also a cloud game application.
可选地,游戏应用所提供的游戏类型包括:FPS(First-Person Shooting,第一人称射击)游戏、TPS(Third-Personal Shooting,第三人称射击)游戏、MOBA(MultiplayerOnline Battle Arena,多人在线战术竞技)游戏、生存建造类游戏、开放世界游戏、经营建设类游戏、探索类游戏、沙盒游戏、虚拟现实应用程序、三维地图程序或者多人器械类生存游戏等,本公开实施例对此不进行具体限定。Optionally, the game types provided by the game application include: FPS (First-Person Shooting, first-person shooter) games, TPS (Third-Personal Shooting, third-person shooter) games, MOBA (MultiplayerOnline Battle Arena, multiplayer online tactical arena) ) games, survival and construction games, open world games, management and construction games, exploration games, sandbox games, virtual reality applications, 3D map programs or multiplayer survival games, etc. Specific limits.
在一些实施例中,用户在终端110上启动游戏应用,并随着用户在游戏应用中的操作,触发终端110向服务器集群120发送游戏业务请求,服务器集群120中的游戏服务器121率先接收到游戏业务请求,并基于游戏业务请求所指示的业务类型,判断是否要将游戏业务请求路由到业务服务器122。In some embodiments, the user starts the game application on the terminal 110, and as the user operates in the game application, the terminal 110 is triggered to send a game service request to the server cluster 120, and the
终端110通过有线或无线通信方式与服务器集群120进行直接或间接地连接,本公开实施例对此不进行限定。The terminal 110 is directly or indirectly connected to the server cluster 120 through wired or wireless communication, which is not limited in this embodiment of the present disclosure.
服务器集群120用于向终端110上运行的游戏应用提供后台服务,服务器集群120包括多台服务器、云计算平台或者虚拟化中心中的至少一项。可选地,服务器集群120承担主要计算工作,终端110承担次要计算工作;或者,服务器集群120承担次要计算工作,终端110承担主要计算工作;或者,服务器集群120和终端110之间采用分布式计算架构进行协同计算。The server cluster 120 is used to provide background services for game applications running on the terminal 110, and the server cluster 120 includes at least one of multiple servers, cloud computing platforms, or virtualization centers. Optionally, the server cluster 120 undertakes the main calculation work, and the terminal 110 undertakes the secondary calculation work; or, the server cluster 120 undertakes the secondary calculation work, and the terminal 110 undertakes the main calculation work; or, the server cluster 120 and the terminal 110 adopt distributed Computing architecture for collaborative computing.
服务器集群120涉及到游戏服务器121和业务服务器122。其中,游戏服务器121用于维护游戏的主业务逻辑,例如,游戏服务器121中创建GameSvr进程来提供游戏的基本玩法逻辑,来自外部的各个游戏业务请求都会先发送到游戏服务器121的GameSvr进程,并由GameSvr进程决策是否要转发到业务服务器122中。其中,业务服务器122可采用微服务组织架构进行开发部署,比如,将原本紧密耦合在游戏服务器121中主业务逻辑的各项非实时业务,分解成若干个独立的小型服务,每个服务单独处理特定的业务需求,通过请求/响应模式能够确保这些小型服务的无状态性,微服务架构能够方便地针对各项服务进行更新、扩展,且能够避免紧耦合模式下的可用性风险。The server cluster 120 involves a
可选地,将从主业务逻辑中拆分出来的不同的非实时业务,分布式部署在不同的业务服务器中,比如,将邮件业务拆分并部署到邮件业务服务器122a,将消息业务拆分并部署到消息业务服务器122b,将群组业务拆分并部署到群组业务服务器122c。Optionally, the different non-real-time services split from the main business logic are distributed and deployed in different service servers, for example, the mail service is split and deployed to the
在一些实施例中,服务器集群120中的游戏服务器121率先接收到来自外部的各个游戏业务请求。对每个游戏业务请求,基于游戏业务请求所指示的业务类型,判断是否要将游戏业务请求路由到业务服务器122。比如,若游戏业务请求所关联的游戏业务为实时业务,则由游戏服务器121自身来对该游戏业务请求进行实时响应,若游戏业务请求所关联的游戏业务为非实时业务,则由游戏服务器121查询与该游戏业务最匹配的业务服务器,如,若游戏业务为邮件业务,则将游戏业务请求路由到邮件业务服务器122a进行处理,若游戏业务为消息业务,则将游戏业务请求路由到消息业务服务器122b进行处理。In some embodiments, the
在一些实施例中,服务器集群120中还配置有群组业务服务器122c,若游戏业务涉及到群发邮件,或消息业务涉及到群发消息时,邮件业务服务器122a或消息业务服务器122b可通过与群组业务服务器122c进行信息消息,以拉取到指定群组的最新成员列表,以保证群组成员更新的时效性,避免向已经退出群组的成员推送错误的消息,也避免向新加入群组的成员漏推送消息。In some embodiments, a
在一些实施例中,终端110的设备类型包括:智能手机、平板电脑、电子书阅读器、MP3(Moving Picture Experts Group Audio Layer III,动态影像专家压缩标准音频层面3)播放器、MP4(Moving Picture Experts Group Audio Layer IV,动态影像专家压缩标准音频层面4)播放器、膝上型便携计算机或者台式计算机中的至少一种。例如,终端110是智能手机,或者其他手持便携式电子设备。以下实施例,以终端110包括智能手机来举例说明。In some embodiments, the device types of the terminal 110 include: smart phones, tablet computers, e-book readers, MP3 (Moving Picture Experts Group Audio Layer III, moving picture experts compression standard audio layer 3) players, MP4 (Moving Picture Experts Group Audio Layer IV, motion picture expert compression standard audio layer 4) At least one of player, laptop computer or desktop computer. For example, the terminal 110 is a smart phone, or other handheld portable electronic devices. In the following embodiments, the terminal 110 includes a smart phone as an example for illustration.
本领域技术人员可以知晓,上述终端110的数量可以更多或更少。比如上述终端110仅为一个,或者上述终端110为几十个或几百个,或者更多数量。本公开实施例对终端110的数量和设备类型不加以限定。Those skilled in the art may know that the number of the foregoing
图2是根据本公开实施例示出的一种游戏业务请求的处理方法的流程图,参见图2,该游戏业务请求的处理方法由计算机设备执行,下面以计算机设备为游戏服务器为例进行说明。Fig. 2 is a flow chart of a method for processing a game service request according to an embodiment of the present disclosure. Referring to Fig. 2 , the method for processing a game service request is executed by a computer device. The computer device is used as a game server as an example for illustration.
在步骤201中,游戏服务器响应于账号的游戏业务请求,确定该游戏业务请求的业务类型,该业务类型指示该游戏业务请求所关联的游戏业务的时效属性。In
本公开实施例涉及的游戏业务请求,是指用户在终端的游戏应用上登录账号以后,基于用户在终端侧的操作所触发生成的游戏业务请求,该游戏业务请求中至少携带所请求的游戏业务的业务标识(Identification,ID)以及该游戏业务相匹配的业务参数,可选地,该游戏业务请求中还可携带游戏业务的业务类型。其中,业务ID用于指示游戏业务具体是哪种业务,业务类型用于指示游戏业务在时效性方面的时效属性为实时业务还是非实时业务,业务参数则是终端侧请求游戏业务所必要注入的相关参数。The game service request involved in the embodiments of the present disclosure refers to the game service request triggered by the user’s operation on the terminal side after the user logs in the account on the terminal game application, and the game service request carries at least the requested game service The service identification (Identification, ID) of the game service and the service parameters matched by the game service. Optionally, the service type of the game service may also be carried in the game service request. Among them, the service ID is used to indicate what kind of service the game service is, the service type is used to indicate whether the timeliness of the game service is real-time service or non-real-time service, and the service parameter is the necessary input for the terminal side to request the game service Related parameters.
在一些实施例中,游戏服务器创建GameSvr进程来提供游戏的基本玩法逻辑,来自外部的各个游戏业务请求都会先发送到GameSvr进程,GameSvr进程解析该游戏业务请求,如解析该游戏业务请求的头字段,得到头字段中记录的业务ID,解析该游戏业务请求的数据字段,得到数据字段中记录的业务参数,接着,查询业务ID所属的业务类型,若该业务类型为实时业务,则由GameSvr进程处理该游戏业务请求,若该业务类型为非实时业务,则进入下述步骤202。In some embodiments, the game server creates a GameSvr process to provide the basic gameplay logic of the game, and each game service request from the outside will first be sent to the GameSvr process, and the GameSvr process parses the game service request, such as parsing the header field of the game service request , get the business ID recorded in the header field, parse the data field of the game business request, get the business parameters recorded in the data field, then query the business type to which the business ID belongs, if the business type is a real-time business, then the GameSvr process To process the game service request, if the service type is non-real-time service, enter the
在另一些实施例中,业务类型是直接携带在若该业务类型为实时业务中的,例如,业务类型被封装到游戏业务请求的头字段中,游戏服务器的GameSvr进程解析头字段,得到头字段中记录的业务ID和业务类型,接着,若该业务类型为实时业务,则由GameSvr进程处理该游戏业务请求,若该业务类型为非实时业务,则进入下述步骤202。在一些实施例中,业务类型也可被封装到游戏业务请求的数据字段,本公开实施例对此不进行具体限定。In some other embodiments, the business type is directly carried in the real-time business if the business type is, for example, the business type is encapsulated into the header field of the game service request, and the GameSvr process of the game server parses the header field to obtain the header field Then, if the service type is a real-time service, the game service request is processed by the GameSvr process, and if the service type is a non-real-time service, then enter the
在步骤202中,在该业务类型指示该游戏业务为非实时业务的情况下,游戏服务器确定该非实时业务相匹配的服务接口。In
在一些实施例中,在游戏业务所属的业务类型为非实时业务的情况下,无需GameSvr进程花费资源来对该游戏业务请求进行实时处理,游戏服务器可将该游戏业务请求路由到单独支持该游戏业务的业务服务器中进行处理,这样能够节约游戏服务器的处理资源,优化游戏服务器的资源配置。In some embodiments, when the service type of the game service is a non-real-time service, there is no need for the GameSvr process to spend resources to process the game service request in real time, and the game server can route the game service request to a separate support for the game Processing in the business server of the business can save the processing resources of the game server and optimize the resource allocation of the game server.
在一些实施例中,在将非实时业务从游戏服务器中解耦,并独立部署到各自所属的业务服务器的架构下,这时每个非实时业务都会配置一一对应的服务API,这一服务API可经由GameSvr进程的调用,将非实时业务的业务参数注入到RPC请求中,并向该服务API所指示的业务服务器发送该RPC请求。In some embodiments, under the framework of decoupling non-real-time services from game servers and independently deploying them to their own service servers, each non-real-time service will be configured with a one-to-one corresponding service API. The API can inject the service parameters of the non-real-time service into the RPC request through the invocation of the GameSvr process, and send the RPC request to the service server indicated by the service API.
在一些实施例中,游戏服务器基于该非实时业务的业务ID,查询与该非实时业务的业务ID相关联的服务API。或者,游戏服务器基于该非实时业务的业务名称,查询与该非实时业务的业务名称相关联的服务API,本公开实施例对服务API是与业务名称还是业务ID对应存储不进行具体限定。In some embodiments, the game server queries the service API associated with the service ID of the non-real-time service based on the service ID of the non-real-time service. Or, based on the business name of the non-real-time business, the game server queries the service API associated with the business name of the non-real-time business. The embodiment of the present disclosure does not specifically limit whether the service API is stored corresponding to the business name or business ID.
在步骤203中,游戏服务器从服务注册中心中查询用于提供该服务接口的业务服务器的地址,该服务注册中心用于记录各类接口的业务服务器的地址。In
在一些实施例中,每当将一项非实时业务从游戏服务器中解耦拆分之后,都会将这一非实时业务的服务API和对应业务服务器的地址在服务注册中心中进行注册,即,在服务注册中心中会记录每一对服务API和业务服务器的地址之间的映射关系。可选地,上述映射关系以哈希表、链表、动态数组、Key-Value(键值对)数据结构等方式存储,在此不做赘述。In some embodiments, whenever a non-real-time business is decoupled from the game server, the service API of the non-real-time business and the address of the corresponding business server will be registered in the service registration center, that is, The mapping relationship between each pair of service API and the address of the business server will be recorded in the service registry. Optionally, the above-mentioned mapping relationship is stored in a hash table, linked list, dynamic array, Key-Value (key-value pair) data structure, etc., which will not be described in detail here.
在一些实施例中,游戏服务器在基于步骤202查询到当前游戏业务的服务API以后,查询服务注册中心中的映射关系,即可得到用于提供该服务API的业务服务器的地址,可选地,该地址包括IP(Internet Protocol,网际互连协议)地址和通信端口。In some embodiments, after the game server queries the service API of the current game business based on
在步骤204中,游戏服务器基于该服务接口,向该地址发送RPC请求,该RPC请求用于指示该业务服务器向该账号提供对该游戏业务的响应。In
在一些实施例中,游戏服务器调用该服务API,向该服务API中注入游戏业务请求中解析出来的业务参数,接着,由该服务API基于注入的业务参数封装RPC请求,并将RPC请求转发到步骤203中查询所得的地址,实现基于RPC框架向服务发起游戏业务请求的方案。In some embodiments, the game server invokes the service API, injects the service parameters parsed from the game service request into the service API, then, the service API encapsulates the RPC request based on the injected service parameters, and forwards the RPC request to The address obtained by querying in
在一些实施例中,在微服务框架下,对每个非实时业务的服务API(可视为是微服务接口),都为其单独配置一个业务服务器,不同业务服务器之间的数据库集群是相互独立、环境隔离的,保证一项非实时业务的数据库操作不会影响到其他非实时业务,保证不同服务之间相互独立、不再紧密耦合,避免了在紧耦合情况下由于某项服务故障导致的故障级联问题,在此类微服务框架下,即使某项服务故障也仅会导致单项服务不可用,并不影响其他服务的正常功能,极大提升了服务总体的可用性。In some embodiments, under the microservice framework, for each non-real-time business service API (which can be regarded as a microservice interface), a separate service server is configured for it, and the database clusters between different service servers are mutually Independent and environment-isolated, ensuring that the database operation of a non-real-time business will not affect other non-real-time businesses, ensuring that different services are independent of each other and no longer tightly coupled, and avoiding the failure of a certain service in the case of tight coupling. The cascading problem of faults, under this type of microservice framework, even if a service fails, only a single service will be unavailable, and it will not affect the normal functions of other services, which greatly improves the overall availability of services.
本公开实施例提供的方法,通过对于请求非实时业务的游戏业务请求,由于实时性要求不高,无需游戏服务器本地进行实时处理,由此在服务注册中心中查询到专用于处理该非实时业务的服务API,再通过该服务API对远程的业务服务器进行RPC远程调用,这样能够将涉及到非实时业务的用户负载从游戏服务器迁移到业务服务器中,优化了游戏服务器的资源配置,且由于针对非实时业务的迭代和更新仅需要修改业务服务器中的代码逻辑,必要时修改服务API,不涉及到对游戏的主业务逻辑打补丁,降低了开发复杂度、提升了游戏开发效率,并且不同类型的非实时业务可单独部署在不同业务服务器中,使得某些业务功能阻塞时,不会影响到其他业务功能的正常使用,且也不会影响到游戏的主业务逻辑,极大提升了游戏可用性。In the method provided by the embodiment of the present disclosure, for the game service request requesting non-real-time service, since the real-time requirement is not high, there is no need for the game server to perform real-time processing locally, so that the service registration center can be found that is dedicated to processing the non-real-time service. service API, and then make RPC remote call to the remote business server through the service API, so that the user load related to non-real-time business can be migrated from the game server to the business server, and the resource configuration of the game server is optimized. The iteration and update of non-real-time business only needs to modify the code logic in the business server, and modify the service API if necessary, which does not involve patching the main business logic of the game, which reduces the development complexity and improves the game development efficiency. The non-real-time business can be deployed separately in different business servers, so that when some business functions are blocked, it will not affect the normal use of other business functions, and will not affect the main business logic of the game, which greatly improves the usability of the game .
在一些实施例中,从服务注册中心中查询用于提供该服务接口的业务服务器的地址包括:In some embodiments, querying the address of the service server for providing the service interface from the service registry includes:
从该服务注册中心中,查询用于提供该服务接口的地址集合;From the service registry, query the set of addresses used to provide the service interface;
从该地址集合中,查询与该账号地理距离最近的业务服务器的地址。From the address set, query the address of the business server with the closest geographic distance to the account.
在一些实施例中,该方法还包括:In some embodiments, the method also includes:
通过该业务服务器响应于该RPC请求,创建该非实时业务的协程;Create a coroutine for the non-real-time business in response to the RPC request through the business server;
通过该协程发起该非实时业务的数据库操作;Initiate the database operation of the non-real-time business through the coroutine;
在获取到对该数据库操作的操作结果前,阻塞并挂起该协程;Before obtaining the operation result of the database operation, block and suspend the coroutine;
在获取到对该数据库操作的操作结果后,返回基于该操作结果生成的响应。After the operation result of the database operation is obtained, a response generated based on the operation result is returned.
在一些实施例中,该游戏业务请求为邮件列表拉取请求;通过该协程发起该非实时业务的数据库操作包括:In some embodiments, the game service request is a mailing list pull request; initiating the database operation of the non-real-time service through the coroutine includes:
通过该协程,从该邮件列表拉取请求中,获取该账号的已拉取邮件中的最大个人邮件序列号和最大系统邮件序列号;Through this coroutine, obtain the maximum personal email sequence number and the maximum system email sequence number in the pulled emails of the account from the mailing list pull request;
基于该最大个人邮件序列号,向数据库中该账号的个人邮件集合发起对个人邮件的批量读取操作,该批量读取操作用于读取邮件序列号大于该最大个人邮件序列号的多封个人邮件;Based on the maximum personal email serial number, initiate a batch read operation of personal emails to the personal email collection of the account in the database. The batch read operation is used to read multiple personal emails whose email serial numbers are greater than the maximum personal email serial number mail;
基于该最大系统邮件序列号,向数据库的系统邮件集合发起对系统邮件的批量读取操作,该批量读取操作用于读取邮件序列号大于该最大系统邮件序列号的多封系统邮件。Based on the maximum system mail serial number, a batch read operation of system mail is initiated to the system mail collection of the database, and the batch read operation is used to read multiple system mails whose mail serial numbers are greater than the maximum system mail serial number.
在一些实施例中,该游戏业务请求为邮件列表拉取请求;通过该协程发起该非实时业务的数据库操作包括:In some embodiments, the game service request is a mailing list pull request; initiating the database operation of the non-real-time service through the coroutine includes:
通过该协程获取该邮件列表拉取请求中携带的该账号的已拉取邮件中的最大邮件序列号;Use this coroutine to obtain the maximum email sequence number in the pulled emails of the account carried in the mailing list pull request;
基于该最大邮件序列号,向数据库的系统邮件集合发起对系统邮件的批量读取操作,该批量读取操作用于读取邮件序列号大于该最大邮件序列号的多封系统邮件;Based on the maximum mail sequence number, a batch read operation of system mail is initiated to the system mail collection of the database, and the batch read operation is used to read multiple system mails whose mail sequence numbers are greater than the maximum mail sequence number;
将该多封系统邮件存入该数据库中该账号的个人邮件集合;storing the plurality of system emails in the personal email collection of the account in the database;
基于该最大邮件序列号,向该个人邮件集合发起对邮件的批量读取操作,该批量读取操作用于读取邮件序列号大于该最大邮件序列号的多封邮件。Based on the maximum mail sequence number, a batch read operation of mails is initiated to the personal mail collection, and the batch read operation is used to read a plurality of mails whose mail sequence numbers are greater than the maximum mail sequence number.
在一些实施例中,该方法还包括:In some embodiments, the method also includes:
基于该批量读取操作的操作结果所返回的多封邮件,确定邮件未读数量;Determine the number of unread emails based on the multiple emails returned by the operation result of the batch read operation;
提取该多封邮件的信息摘要,该信息摘要用于提供以下至少一项:邮件类型、邮件标题、发件人信息、邮件时间戳以及是否含有附件;Extracting information summaries of the plurality of emails, where the information summaries are used to provide at least one of the following: email type, email title, sender information, email timestamp and whether it contains attachments;
生成携带该信息摘要和该邮件未读数量的响应。A response is generated with a digest of the message and an unread count for the message.
在一些实施例中,该方法还包括:In some embodiments, the method also includes:
在同一时间段内累计接收到的多个邮件列表拉取请求的数量超过请求量阈值的情况下,通过该业务服务器缓存该多个邮件列表拉取请求关联的多个RPC请求到消息队列中;When the number of multiple mailing list pull requests received in the same time period exceeds the request volume threshold, the service server caches multiple RPC requests associated with the multiple mailing list pull requests into the message queue;
在该消息队列中,合并同一发起账号多次发送的相同邮件列表拉取请求关联的RPC请求,对该发起账号配置请求次数变量;In the message queue, merge the RPC requests associated with the same mailing list pull request sent multiple times by the same initiating account, and configure the request times variable for the initiating account;
基于该请求次数变量,对该消息队列中的各个RPC请求进行重排序;Reordering each RPC request in the message queue based on the request times variable;
每间隔目标时长,分批处理重排序后的消息队列中处于当前批次的至少一个RPC请求。At least one RPC request in the current batch in the reordered message queue is processed in batches at each target time interval.
在一些实施例中,该游戏业务请求为邮件详情拉取请求;通过该协程发起该非实时业务的数据库操作包括:In some embodiments, the game service request is a pull request for email details; initiating the database operation of the non-real-time service through the coroutine includes:
通过该协程确定该邮件详情拉取请求所请求拉取的邮件类型和邮件序列号;Determine the email type and email serial number requested by the email details pull request through this coroutine;
向数据库中该邮件类型所指示的邮件集合,发起对该邮件序列号所指示的邮件的读取操作,该读取操作用于读取该邮件的邮件正文,并在该邮件携带附件的情况下还读取该附件。Initiate a read operation of the mail indicated by the serial number of the mail to the mail set indicated by the mail type in the database, the read operation is used to read the mail body of the mail, and if the mail carries an attachment Also read the attachment.
在一些实施例中,该游戏业务请求为邮件发送请求;通过该协程发起该非实时业务的数据库操作包括:In some embodiments, the game service request is an email sending request; initiating the database operation of the non-real-time service through the coroutine includes:
通过该协程确定该邮件发送请求所指示的待发送邮件的邮件类型;Determine the mail type of the mail to be sent indicated by the mail sending request through the coroutine;
在该邮件类型为个人邮件的情况下,向数据库中该账号的个人邮件集合发起对该待发送邮件的写入操作;In the case that the email type is a personal email, initiate a write operation to the email to be sent to the personal email collection of the account in the database;
在该邮件类型为系统邮件的情况下,向数据库的系统邮件集合发起对该待发送邮件的写入操作。In the case that the mail type is a system mail, a write operation of the mail to be sent is initiated to the system mail collection of the database.
在一些实施例中,该方法还包括:In some embodiments, the method also includes:
基于该写入操作的操作结果,为该待发送邮件分配邮件序列号;Based on the operation result of the write operation, assign a mail serial number to the mail to be sent;
在该待发送邮件的收件人账号处于游戏离线状态的情况下,生成向该账号通知邮件发送成功的响应;When the recipient account of the email to be sent is offline in the game, generate a response to notify the account that the email is sent successfully;
在该待发送邮件的收件人账号处于游戏在线状态的情况下,生成向该账号通知邮件发送成功的响应;以及,生成向该收件人账号推送该待发送邮件的响应。When the recipient account of the email to be sent is in the game online state, generate a response to notify the account that the email is successfully sent; and generate a response to push the email to the recipient account.
在一些实施例中,该游戏业务请求为未读消息拉取请求;通过该协程发起该非实时业务的数据库操作包括:In some embodiments, the game service request is an unread message pull request; initiating the database operation of the non-real-time service through the coroutine includes:
通过该协程,从该未读消息拉取请求中获取待查询账号以及最大消息标识,该最大消息标识指示该账号和该待查询账号的会话中的最新已读消息;Through the coroutine, the account to be queried and the maximum message ID are obtained from the unread message pull request, and the maximum message ID indicates the latest read message in the session between the account and the account to be queried;
基于该最大消息标识,向数据库中该账号和该待查询账号的消息集合发起对未读消息的批量读取操作,该批量读取操作用于读取消息标识大于该最大消息标识的多条消息。Based on the maximum message ID, initiate a batch read operation of unread messages to the message set of the account and the account to be queried in the database, and the batch read operation is used to read multiple messages whose message ID is greater than the maximum message ID .
在一些实施例中,该方法还包括:In some embodiments, the method also includes:
基于该批量读取操作的操作结果所返回的多条消息,确定未读消息数量;Determine the number of unread messages based on the multiple messages returned by the operation result of the batch read operation;
生成携带该多条未读消息和该未读消息数量的响应。A response carrying the plurality of unread messages and the number of unread messages is generated.
在一些实施例中,该游戏业务请求为消息发送请求;通过该协程发起该非实时业务的数据库操作包括:In some embodiments, the game service request is a message sending request; initiating the database operation of the non-real-time service through the coroutine includes:
通过该协程确定该消息发送请求所指示的待发送消息的消息类型;Determine the message type of the message to be sent indicated by the message sending request through the coroutine;
在该消息类型为个人消息的情况下,向数据库中该账号和消息接收账号的消息集合发起对该待发送消息的写入操作;In the case that the message type is a personal message, initiate a write operation of the message to be sent to the message set of the account and message receiving account in the database;
在该消息类型为群组消息的情况下,向数据库中消息接收群组的消息集合发起对该待发送消息的写入操作。In the case that the message type is a group message, a write operation of the message to be sent is initiated to the message collection of the message receiving group in the database.
在一些实施例中,该方法还包括:In some embodiments, the method also includes:
基于该写入操作的操作结果,为该待发送消息分配消息标识,生成向该账号通知消息发送成功的响应;Based on the operation result of the write operation, assign a message identifier to the message to be sent, and generate a response to notify the account that the message is successfully sent;
对于该个人消息,仅在该消息接收账号处于游戏在线状态的情况下,生成向该消息接收账号推送该待发送消息的响应;For the personal message, only when the message receiving account is in the online state of the game, generate a response to push the message to be sent to the message receiving account;
对于该群组消息,拉取该消息接收群组的最新成员列表;仅对该最新成员列表中的在线成员账号,生成向该在线成员账号推送该待发送消息的响应。For the group message, the latest member list of the message receiving group is pulled; only for the online member account in the latest member list, a response of pushing the message to be sent to the online member account is generated.
在一些实施例中,该游戏业务请求为账号添加请求,该账号添加请求用于申请将目标账号添加到该账号的账号关系链上;通过该协程发起该非实时业务的数据库操作包括:In some embodiments, the game service request is an account addition request, and the account addition request is used to apply for adding the target account to the account relationship chain of the account; the database operation of initiating the non-real-time service through the coroutine includes:
通过该协程,对该账号进行权限验证;Through this coroutine, verify the authority of the account;
在验证通过后,向数据库发起写入由该账号向该目标账号的账号添加记录的数据库操作;After the verification is passed, initiate a database operation to write the record added by the account to the account of the target account to the database;
在获取到对该数据库操作的操作结果后,返回基于该操作结果生成的响应包括:After obtaining the operation result of the database operation, the response generated based on the operation result includes:
在该操作结果指示对该账号添加记录写入完毕的情况下,生成对该目标账号的账号添加通知响应。When the operation result indicates that the account addition record has been written, an account addition notification response to the target account is generated.
上述所有可选技术方案,可以采用任意结合形成本公开的可选实施例,在此不再一一赘述。All the above optional technical solutions may be combined in any way to form optional embodiments of the present disclosure, which will not be repeated here.
图3是根据本公开实施例示出的一种游戏业务请求的处理方法的交互流程图,如图3所示,游戏业务请求的处理方法由游戏服务器与业务服务器交互实施,游戏服务器和业务服务器可构成对外提供游戏业务的服务器集群,且游戏服务器和业务服务器均为计算机设备的示例性说明,该实施例包括以下步骤。Fig. 3 is an interactive flow chart of a method for processing a game service request according to an embodiment of the present disclosure. Constituting a server cluster for externally providing game services, and both the game server and the service server are exemplary illustrations of computer equipment, this embodiment includes the following steps.
在步骤301中,游戏服务器响应于账号的游戏业务请求,确定该游戏业务请求的业务类型。In step 301, the game server determines the service type of the game service request in response to the game service request of the account.
其中,该业务类型指示该游戏业务请求所关联的游戏业务的时效属性。Wherein, the service type indicates the timeliness attribute of the game service associated with the game service request.
在一些实施例中,游戏服务器创建GameSvr进程来提供游戏的基本玩法逻辑,来自外部的各个游戏业务请求都会先发送到GameSvr进程,GameSvr进程解析该游戏业务请求。In some embodiments, the game server creates a GameSvr process to provide the basic gameplay logic of the game, and each game service request from the outside will first be sent to the GameSvr process, and the GameSvr process parses the game service request.
可选地,游戏业务请求中携带业务ID和业务参数,GameSvr进程解析该游戏业务请求的头字段,得到头字段中记录的业务ID,解析该游戏业务请求的数据字段,得到数据字段中记录的业务参数。Optionally, the game service request carries a service ID and service parameters, and the GameSvr process parses the header field of the game service request to obtain the service ID recorded in the header field, parses the data field of the game service request, and obtains the data field recorded in the data field. business parameters.
在这种情况下,游戏服务器侧可以记录有业务ID与业务类型的映射关系,映射关系以哈希表、链表、动态数组、Key-Value数据结构等方式存储,在此不做赘述。在从头字段中解析到业务ID以后,查询上述业务ID与业务类型的映射关系,得到该业务ID所属的业务类型。其中,该业务类型用于指示业务ID所指示的游戏业务在时效方面的时效属性,如业务类型包括实时业务和非实时业务。In this case, the game server side can record the mapping relationship between business ID and business type, and the mapping relationship is stored in the form of hash table, linked list, dynamic array, Key-Value data structure, etc., which will not be described here. After parsing the business ID from the header field, query the mapping relationship between the above business ID and business type to obtain the business type to which the business ID belongs. Wherein, the service type is used to indicate the timeliness attribute of the game service indicated by the service ID in terms of timeliness, for example, the service type includes real-time service and non-real-time service.
可选地,游戏业务请求中携带业务ID、业务类型和业务参数,GameSvr进程解析该游戏业务请求的头字段,得到头字段中记录的业务ID和业务类型,解析该游戏业务请求的数据字段,得到数据字段中记录的业务参数;或者,GameSvr进程解析该游戏业务请求的头字段,得到头字段中记录的业务ID,解析该游戏业务请求的数据字段,得到数据字段中记录的业务类型和业务参数。Optionally, the game service request carries service ID, service type and service parameters, and the GameSvr process parses the header field of the game service request, obtains the service ID and service type recorded in the header field, and parses the data field of the game service request, Obtain the business parameters recorded in the data field; or, the GameSvr process parses the header field of the game business request, obtains the business ID recorded in the header field, parses the data field of the game business request, and obtains the business type and business recorded in the data field parameter.
在一个示例中,游戏业务请求的头字段或数据字段中携带Real-Time(实时)变量,Real-Time变量用于指示游戏业务的业务类型,可选地,Real-Time变量为二值变量,若Real-Time变量取值为0代表为非实时业务,若Real-Time变量取值为1代表为实时业务,若Real-Time变量缺省可视为取默认值,该默认值为0或者1,由技术人员在游戏服务器侧预先配置。或者,Real-Time变量为布尔型变量,若Real-Time变量取值为False代表为非实时业务,若Real-Time变量取值为True代表为实时业务,若Real-Time变量缺省可视为取默认值,该默认值为False或者True,由技术人员在游戏服务器侧预先配置。In an example, the header field or data field of the game service request carries a Real-Time (real-time) variable, and the Real-Time variable is used to indicate the service type of the game service. Optionally, the Real-Time variable is a binary variable, If the value of the Real-Time variable is 0, it means that it is a non-real-time service. If the value of the Real-Time variable is 1, it means that it is a real-time service. If the value of the Real-Time variable is default, it can be regarded as the default value. , which is pre-configured on the game server side by technicians. Or, the Real-Time variable is a Boolean variable. If the value of the Real-Time variable is False, it means that it is a non-real-time service. If the value of the Real-Time variable is True, it means that it is a real-time service. The default value is False or True, which is pre-configured by the technician on the game server side.
在另一个实施例中,在游戏业务请求的头字段或数据字段中设置Real-Time字段,或者,在头字段和数据字段中间设置Real-Time字段,Real-Time字段用于记录业务类型,这样解析Real-Time字段即可获取到业务类型,比如,Real-Time字段中记录的业务类型为字符串变量,字符串变量取值为“Real-Time”时指示实时业务,字符串变量取值为“Non-Real-Time”时指示非实时业务,或者,Real-Time字段中记录的业务类型为上述二值变量、布尔型变量,本公开实施例对此不进行具体限定。In another embodiment, the Real-Time field is set in the header field or data field of the game service request, or the Real-Time field is set between the header field and the data field, and the Real-Time field is used to record the business type, so The business type can be obtained by parsing the Real-Time field. For example, the business type recorded in the Real-Time field is a string variable. When the value of the string variable is "Real-Time", it indicates a real-time service. "Non-Real-Time" indicates a non-real-time service, or the service type recorded in the Real-Time field is the above-mentioned binary variable or Boolean variable, which is not specifically limited in this embodiment of the present disclosure.
在一些实施例中,若游戏服务器获取到的业务类型为实时业务,则由GameSvr进程处理该游戏业务请求,若该业务类型为非实时业务,则进入下述步骤302。In some embodiments, if the service type obtained by the game server is a real-time service, the game service request is processed by the GameSvr process; if the service type is a non-real-time service, then enter the following step 302 .
在步骤302中,在该业务类型指示该游戏业务为非实时业务的情况下,游戏服务器确定该非实时业务相匹配的服务接口。In step 302, when the service type indicates that the game service is a non-real-time service, the game server determines a service interface matching the non-real-time service.
在一些实施例中,在游戏业务所属的业务类型为非实时业务的情况下,无需GameSvr进程花费资源来对该游戏业务请求进行实时处理,游戏服务器可将该游戏业务请求路由到单独支持该游戏业务的业务服务器中进行处理,这样能够节约游戏服务器的处理资源,优化游戏服务器的资源配置。In some embodiments, when the service type of the game service is a non-real-time service, there is no need for the GameSvr process to spend resources to process the game service request in real time, and the game server can route the game service request to a separate support for the game Processing in the business server of the business can save the processing resources of the game server and optimize the resource allocation of the game server.
在一些实施例中,在将非实时业务从游戏服务器中解耦,并独立部署到各自所属的业务服务器的架构下,这时每个非实时业务都会配置一一对应的服务API,这一服务API可经由GameSvr进程的调用,将非实时业务的业务参数注入到RPC请求中,并向该服务API所指示的业务服务器发送该RPC请求。In some embodiments, under the framework of decoupling non-real-time services from game servers and independently deploying them to their own service servers, each non-real-time service will be configured with a one-to-one corresponding service API. The API can inject the service parameters of the non-real-time service into the RPC request through the invocation of the GameSvr process, and send the RPC request to the service server indicated by the service API.
在一些实施例中,游戏服务器基于该非实时业务的业务ID,查询与该非实时业务的业务ID相关联的服务API。或者,游戏服务器基于该非实时业务的业务名称,查询与该非实时业务的业务名称相关联的服务API,本公开实施例对服务API是与业务名称还是业务ID对应存储不进行具体限定。In some embodiments, the game server queries the service API associated with the service ID of the non-real-time service based on the service ID of the non-real-time service. Or, based on the business name of the non-real-time business, the game server queries the service API associated with the business name of the non-real-time business. The embodiment of the present disclosure does not specifically limit whether the service API is stored corresponding to the business name or business ID.
在步骤303中,游戏服务器从服务注册中心中查询用于提供该服务接口的业务服务器的地址。In step 303, the game server queries the address of the service server for providing the service interface from the service registration center.
其中,该服务注册中心用于记录各类接口的业务服务器的地址。Wherein, the service registration center is used to record the addresses of service servers of various interfaces.
在一些实施例中,每当将一项非实时业务从游戏服务器中解耦拆分之后,都会将这一非实时业务的服务API和对应业务服务器的地址在服务注册中心中进行注册,即,在服务注册中心中会记录每一对服务API和业务服务器的地址之间的映射关系。可选地,上述服务API和业务服务器的地址之间的映射关系以哈希表、链表、动态数组、Key-Value数据结构等方式存储,在此不做赘述。In some embodiments, whenever a non-real-time business is decoupled from the game server, the service API of the non-real-time business and the address of the corresponding business server will be registered in the service registration center, that is, The mapping relationship between each pair of service API and the address of the business server will be recorded in the service registry. Optionally, the above-mentioned mapping relationship between the service API and the address of the business server is stored in a hash table, linked list, dynamic array, Key-Value data structure, etc., which will not be described here.
在一些实施例中,游戏服务器在基于步骤302查询到当前游戏业务的服务API以后,查询服务注册中心中的映射关系,即可得到用于提供该服务API的业务服务器的地址,可选地,该地址包括IP(Internet Protocol,网际互连协议)地址和通信端口。In some embodiments, after the game server queries the service API of the current game business based on step 302, it queries the mapping relationship in the service registration center to obtain the address of the service server for providing the service API. Optionally, The address includes an IP (Internet Protocol, Internet Protocol) address and communication port.
在一些实施例中,针对同一非实时业务部署的业务服务器并非是单独的一台服务器,而是采用CDN(Content Delivery Network,内容分发网络)架构部署在各地的多台服务器,在这种情况,每个服务API在上述服务注册中心中进行注册时,记录的是每个服务API与一组业务服务器各自的地址所构成的地址集合。在此基础上,游戏服务器从该服务注册中心的映射关系中,查询得到用于提供该服务API的地址集合,接着,由于地址集合中记录的是一组业务服务器各自的地址,游戏服务器可以从该地址集合中,查询与该账号地理距离最近的业务服务器的地址,比如,在得到用户充分授权的情况下,判断该账号的IP属地,并在地址集合中找到同一IP属地的业务服务器的地址,若存在多个同一IP属地的业务服务器的地址,则挑选地理距离最近的业务服务器的地址;若地址集合中没有找到同一IP属地的业务服务器的地址,则扩大搜寻范围,从相邻IP属地的业务服务器的地址中找到地理距离最近的业务服务器的地址,本公开实施例对此不进行具体限定。In some embodiments, the service server deployed for the same non-real-time service is not a single server, but a plurality of servers deployed in various places using a CDN (Content Delivery Network, content distribution network) architecture. In this case, When each service API is registered in the above-mentioned service registration center, it records the address set formed by each service API and a group of respective addresses of the business servers. On this basis, the game server queries the address set used to provide the service API from the mapping relationship of the service registry, and then, since the address set records the respective addresses of a group of business servers, the game server can obtain from In this address set, query the address of the business server with the closest geographical distance to the account. For example, if the user is fully authorized, determine the IP region of the account and find the address of the business server with the same IP region in the address set. , if there are multiple addresses of business servers in the same IP domain, select the address of the business server with the closest geographical distance; The address of the service server with the closest geographic distance is found from the addresses of the service servers of the given service server, which is not specifically limited in this embodiment of the present disclosure.
可选地,仅针对部分较为繁忙的非实时业务采用CDN架构分布式部署业务服务器,对于剩余较为空闲的非实时业务则采用一台业务服务器独立部署,或者,对全部非实时业务都采用CDN架构分布式部署业务服务器,或者,对全部非实时业务都采用一台业务服务器独立部署,本公开实施例对业务服务器的部署方式不进行具体限定。Optionally, CDN architecture is used for distributed deployment of service servers only for some relatively busy non-real-time services, and a service server is used for independent deployment of the remaining relatively idle non-real-time services, or CDN architecture is used for all non-real-time services Distributed deployment of service servers, or all non-real-time services are independently deployed by a service server, and the embodiment of the present disclosure does not specifically limit the deployment mode of the service server.
在上述过程中,通过对部分或全部非实时业务采用CDN架构分布式部署,使得每个账号的游戏业务请求都能够从游戏服务器,按照就近原则路由到地理距离最近的业务服务器,由地理距离最近的业务服务器来提供该非实时业务,极大加快对非实时业务的处理效率和响应速度。In the above process, through the distributed deployment of CDN architecture for some or all non-real-time services, the game service request of each account can be routed from the game server to the business server with the closest geographical distance according to the principle of proximity, and the closest geographical distance The business server provides the non-real-time business, greatly speeding up the processing efficiency and response speed of the non-real-time business.
在步骤304中,游戏服务器基于该服务接口,向该业务服务器的地址发送RPC请求。In step 304, the game server sends an RPC request to the address of the business server based on the service interface.
其中,该RPC请求用于指示该业务服务器向该账号提供对该游戏业务的响应。Wherein, the RPC request is used to instruct the service server to provide the account with a response to the game service.
在一些实施例中,游戏服务器调用该服务API,向该服务API中注入游戏业务请求中解析出来的业务参数,接着,由该服务API基于注入的业务参数封装RPC请求,并将RPC请求转发到步骤303中查询所得的地址,实现基于RPC框架向服务发起游戏业务请求的方案。In some embodiments, the game server invokes the service API, injects the service parameters parsed from the game service request into the service API, then, the service API encapsulates the RPC request based on the injected service parameters, and forwards the RPC request to The address obtained by querying in step 303 implements a scheme of initiating a game service request to the service based on the RPC framework.
在一些实施例中,在微服务框架下,对每个非实时业务的服务API(可视为是微服务接口),都为其单独配置一个业务服务器,不同业务服务器之间的数据库集群是相互独立、环境隔离的,保证一项非实时业务的数据库操作不会影响到其他非实时业务,保证不同服务之间相互独立、不再紧密耦合,避免了在紧耦合情况下由于某项服务故障导致的故障级联问题,在此类微服务框架下,即使某项服务故障也仅会导致单项服务不可用,并不影响其他服务的正常功能,极大提升了服务总体的可用性。In some embodiments, under the microservice framework, for each non-real-time business service API (which can be regarded as a microservice interface), a separate service server is configured for it, and the database clusters between different service servers are mutually Independent and environment-isolated, ensuring that the database operation of a non-real-time business will not affect other non-real-time businesses, ensuring that different services are independent of each other and no longer tightly coupled, and avoiding the failure of a certain service in the case of tight coupling. The cascading problem of faults, under this type of microservice framework, even if a service fails, only a single service will be unavailable, and it will not affect the normal functions of other services, which greatly improves the overall availability of services.
进一步的,服务注册中心和RPC框架都能够由游戏服务器中原生的游戏引擎直接支持,而服务API通过对RPC请求进行封装,能够将非实时业务的无状态RPC请求与实时业务的有状态游戏业务请求进行隔离,这里有状态和无状态是指是否需要在业务处理过程中维护状态机(State Machine)。Furthermore, both the service registry and the RPC framework can be directly supported by the original game engine in the game server, and the service API can combine stateless RPC requests for non-real-time services with stateful game services for real-time services by encapsulating RPC requests. Requests are isolated. Here, stateful and stateless refer to whether a state machine (State Machine) needs to be maintained during business processing.
举例来说,针对实时性要求较高的实时业务,如实时的技能施法、伤害统计、射线检测、游戏内连麦等,对这类实时业务需要维护一条玩家客户端-游戏服务器-玩家客户端之间的链路,因此需要维护状态机以处理有状态的游戏业务请求,这类实时业务由游戏服务器的GameSvr进程进行处理和响应;针对实时性要求较低的非实时业务,如非实时的邮件业务、消息业务、好友业务、排行榜业务等,终端每次在需要访问非实时业务时,将非实时业务的业务参数封装到游戏业务请求,并将游戏业务请求发送到游戏服务器后,终端即可继续执行其他操作,等待业务服务器直接返回响应,或者业务服务器生成响应后回调通知游戏服务器,再由游戏服务器向终端返回响应,这样相当于非实时业务不会阻塞终端侧的游戏线程,也不会阻塞游戏服务器侧的GameSvr进程,而是将非实时业务从整体式架构中拆分出来,通过微服务的架构实现,能够优化服务器集群的资源配置,且提升游戏业务的可用性。以下的步骤305-308中,将对业务服务器侧的处理流程进行详细说明。For example, for real-time services with high real-time requirements, such as real-time skill casting, damage statistics, ray detection, in-game microphone connection, etc., it is necessary to maintain a player client-game server-player client for such real-time services Therefore, it is necessary to maintain a state machine to handle stateful game service requests. This type of real-time service is processed and responded by the GameSvr process of the game server; for non-real-time services with low real-time requirements, such as non-real-time Mail service, message service, friend service, leaderboard service, etc., each time the terminal needs to access non-real-time services, it encapsulates the service parameters of the non-real-time service into the game service request, and after sending the game service request to the game server, the terminal You can continue to perform other operations and wait for the business server to return a response directly, or the business server will call back to notify the game server after generating a response, and then the game server will return a response to the terminal, which means that non-real-time services will not block the game thread on the terminal side. It does not block the GameSvr process on the game server side, but splits the non-real-time business from the overall architecture. Through the implementation of the micro-service architecture, it can optimize the resource allocation of the server cluster and improve the availability of the game business. In the following steps 305-308, the processing flow at the service server side will be described in detail.
在步骤305中,业务服务器响应于该RPC请求,创建该非实时业务的协程。In step 305, the service server creates a coroutine for the non-real-time service in response to the RPC request.
在一些实施例中,在业务服务器侧采用协程式开发,在协程式开发中,业务服务器对每个RPC请求都新建一个协程,再RPC请求关联的非实时业务涉及到数据库操作(如读取操作,或写入操作)时,触发阻塞当前协程,这样当前协程的阻塞不会影响到业务服务器上主线程的运行,在同一时刻若有多个协程涉及到数据库操作并进入阻塞状态的情况下,主线程在当前已有的若干协程中选择其中一个执行,而被阻塞的协程将被挂起,直到主线程选择自身作为执行单位后,获取到数据库操作的执行结果。In some embodiments, a coroutine is developed on the business server side. In the coroutine development, the business server creates a new coroutine for each RPC request, and the non-real-time business associated with the RPC request involves database operations (such as reading operation, or write operation), triggers to block the current coroutine, so that the blocking of the current coroutine will not affect the operation of the main thread on the business server. If there are multiple coroutines involved in database operations at the same time and enter the blocking state In the case of , the main thread selects one of the existing coroutines to execute, and the blocked coroutine will be suspended until the main thread selects itself as the execution unit and obtains the execution result of the database operation.
在上述过程中,通过采用协程式开发,使得控制CPU(Central Processing Unit,中央处理器)调度数据库资源时,协程的开销比线程更小,能够节约业务服务器的处理资源。In the above process, through the development of coroutines, when controlling the CPU (Central Processing Unit, central processing unit) to schedule database resources, the overhead of coroutines is smaller than that of threads, which can save the processing resources of business servers.
在一些实施例中,业务服务器上维护有主线程,主线程响应于步骤304中服务API传来的该RPC请求,解析该RPC请求,得到非实时业务的业务参数,并判断该非实时业务是否涉及到数据库操作,在该非实时业务涉及到数据库操作的情况下,对该非实时业务新建一个协程。In some embodiments, a main thread is maintained on the service server, and the main thread responds to the RPC request sent by the service API in step 304, parses the RPC request, obtains the service parameters of the non-real-time service, and judges whether the non-real-time service Involving database operations, if the non-real-time business involves database operations, create a coroutine for the non-real-time business.
可选地,在创建协程时,基于python的第三方协程库gevent来创建gevent协程,由于gevent协程能够自带事件循环,并在主线程执行到阻塞当前协程的函数时去寻找其他可执行的协程,能够简化开发难度,或者,也可采取其他方式来创建其他类型的协程,这里对创建的协程类型不进行具体限定。Optionally, when creating a coroutine, create a gevent coroutine based on python's third-party coroutine library gevent, because the gevent coroutine can have its own event loop, and when the main thread executes to the function that blocks the current coroutine, it will find Other executable coroutines can simplify the difficulty of development, or other methods can also be used to create other types of coroutines, and the type of coroutines created is not specifically limited here.
在步骤306中,业务服务器通过该协程发起该非实时业务的数据库操作。In
在一些实施例中,在该非实时业务涉及到数据库操作的情况下,业务服务器通过主线程或协程,基于该非实时业务的业务参数进行SQL(Structured Query Language,结构化查询语言)解析,得到事务的SQL语句,上述事务是指为了实现非实时业务所涉及的数据库操作而创建的事务,这里的数据库操作涉及到读取操作和写入操作两种类型。在获取到事务的SQL语句后,视为已经发起了对该非实时业务的数据库操作,但由于主线程可能在同一时间内会存在多个协程都等待处理,在保证数据库的一致性,通常需要对当前唤醒的协程所操作的每条数据记录都添加锁,若添加的锁为共享锁,则可并行处理其他申请共享锁的协程,若添加的锁为排他锁,则只能等待当前协程处理完毕、释放锁后,才能唤醒其他申请这条数据记录的锁的协程。因此,在生成事务的SQL语句后,协程缓存事务的SQL语句,阻塞当前事务,挂起协程,等待主线程唤醒协程。In some embodiments, when the non-real-time business involves database operations, the business server performs SQL (Structured Query Language, Structured Query Language) analysis based on the business parameters of the non-real-time business through the main thread or coroutine, The SQL statement of the transaction is obtained. The above-mentioned transaction refers to the transaction created to realize the database operation involved in the non-real-time business. The database operation here involves two types of read operation and write operation. After obtaining the SQL statement of the transaction, it is considered that the database operation of the non-real-time business has been initiated, but since the main thread may have multiple coroutines waiting to be processed at the same time, to ensure the consistency of the database, usually It is necessary to add a lock to each data record operated by the currently awakened coroutine. If the added lock is a shared lock, other coroutines that apply for a shared lock can be processed in parallel. If the added lock is an exclusive lock, you can only wait After the current coroutine is processed and the lock is released, other coroutines that apply for the lock of this data record can be woken up. Therefore, after generating the SQL statement of the transaction, the coroutine caches the SQL statement of the transaction, blocks the current transaction, suspends the coroutine, and waits for the main thread to wake up the coroutine.
在步骤307中,业务服务器在获取到对该数据库操作的操作结果前,阻塞并挂起该协程。In
在一些实施例中,在业务服务器的主线程唤醒当前协程以前,协程将一直处于挂起状态,并需要阻塞事务,直到主线程唤醒当前协程时,由协程或者主线程基于该事务的SQL语句,对SQL语句在底层数据库中涉及操作的数据记录执行数据库操作,并等待底层数据库返回对数据库操作的操作结果。可选地,底层数据库为Mango数据库、Redis存储集群或者其他架构的数据库,本公开实施例对此不进行具体限定。In some embodiments, before the main thread of the business server wakes up the current coroutine, the coroutine will always be in a suspended state, and needs to block the transaction. The SQL statement executes the database operation on the data records involved in the operation of the SQL statement in the underlying database, and waits for the underlying database to return the operation result of the database operation. Optionally, the underlying database is a Mango database, a Redis storage cluster, or a database of other architectures, which is not specifically limited in this embodiment of the present disclosure.
在步骤308中,业务服务器在获取到对该数据库操作的操作结果后,返回基于该操作结果生成的响应。In step 308, after obtaining the operation result of the database operation, the service server returns a response generated based on the operation result.
在一些实施例中,底层数据库对数据库操作的操作结果包括:事务提交或者事务回滚,若操作结果为事务提交,代表数据库操作执行完毕且已经落盘,需要返回对非实时业务的操作成功响应,并在需要返回业务数据的情况下,基于SQL语句读取或写入的数据,进一步获取业务数据,将业务数据封装到上述操作成功响应中,在不需要返回业务数据情况下,操作成功响应可实施为一个ACK(Acknowledge Character,确认字符)消息;若操作结果为事务回滚,代表数据库操作执行失败导致事务回滚,需要返回对非实时业务的操作失败响应,比如,操作失败响应被提供为一串错误码,或者携带操作失败标识的一条指令,本公开实施例对此不进行具体限定。In some embodiments, the operation result of the underlying database on the database operation includes: transaction commit or transaction rollback. If the operation result is transaction commit, it means that the database operation has been completed and has been placed on the disk, and a successful response to the operation of the non-real-time business needs to be returned. , and in the case of needing to return business data, further obtain business data based on the data read or written by the SQL statement, encapsulate the business data into the above operation success response, and return the operation success response if there is no need to return business data It can be implemented as an ACK (Acknowledge Character) message; if the operation result is a transaction rollback, it means that the database operation fails to execute and the transaction rolls back, and the operation failure response to the non-real-time business needs to be returned. For example, the operation failure response is provided It is a string of error codes, or an instruction carrying an operation failure flag, which is not specifically limited in this embodiment of the present disclosure.
在一些实施例中,业务服务器在生成上述对非实时业务的响应(操作成功响应或操作失败响应)后,由业务服务器直接向终端返回上述响应,可节约通信开销,或者,业务服务器通过服务API,向游戏服务器回传上述响应,以使游戏服务器将上述响应发送给终端,这样能够降低终端的感知性,保证终端对业务服务器无感知,微服务框架对用户侧透明。In some embodiments, after the service server generates the above-mentioned response to the non-real-time service (operation success response or operation failure response), the service server directly returns the above-mentioned response to the terminal, which can save communication overhead, or, the service server uses the service API , return the above response to the game server, so that the game server sends the above response to the terminal, which can reduce the perception of the terminal, ensure that the terminal is not aware of the business server, and the microservice framework is transparent to the user side.
本公开实施例提供的方法,通过对于请求非实时业务的游戏业务请求,由于实时性要求不高,无需游戏服务器本地进行实时处理,由此在服务注册中心中查询到专用于处理该非实时业务的服务API,再通过该服务API对远程的业务服务器进行RPC远程调用,这样能够将涉及到非实时业务的用户负载从游戏服务器迁移到业务服务器中,优化了游戏服务器的资源配置,且由于针对非实时业务的迭代和更新仅需要修改业务服务器中的代码逻辑,必要时修改服务API,不涉及到对游戏的主业务逻辑打补丁,降低了开发复杂度、提升了游戏开发效率,并且不同类型的非实时业务可单独部署在不同业务服务器中,使得某些业务功能阻塞时,不会影响到其他业务功能的正常使用,且也不会影响到游戏的主业务逻辑,极大提升了游戏可用性。In the method provided by the embodiment of the present disclosure, for the game service request requesting non-real-time service, since the real-time requirement is not high, there is no need for the game server to perform real-time processing locally, so that the service registration center can be found that is dedicated to processing the non-real-time service. service API, and then make RPC remote call to the remote business server through the service API, so that the user load related to non-real-time business can be migrated from the game server to the business server, and the resource configuration of the game server is optimized. The iteration and update of non-real-time business only needs to modify the code logic in the business server, and modify the service API if necessary, which does not involve patching the main business logic of the game, which reduces the development complexity and improves the game development efficiency. The non-real-time business can be deployed separately in different business servers, so that when some business functions are blocked, it will not affect the normal use of other business functions, and will not affect the main business logic of the game, which greatly improves the usability of the game .
上述所有可选技术方案,可以采用任意结合形成本公开的可选实施例,在此不再一一赘述。All the above optional technical solutions may be combined in any way to form optional embodiments of the present disclosure, which will not be repeated here.
在上一实施例中,简单介绍了游戏服务器和业务服务器如何通过交互,来将非实时业务的游戏业务请求迁移到业务服务器上进行处理,以缓解游戏服务器的负载压力,并且还改善了单个非实时业务导致的故障级联问题。在以下的几个实施例中,将分别以邮件业务场景、聊天业务场景这两类具体的业务场景为例,介绍业务服务器的处理流程的细节,下面进行说明。In the previous embodiment, it is briefly introduced how the game server and the business server interact to migrate the game business request of the non-real-time business to the business server for processing, so as to alleviate the load pressure of the game server and improve the performance of a single non-real-time service. Fault cascading problems caused by real-time services. In the following several embodiments, the details of the processing flow of the service server will be introduced by taking two specific service scenarios of email service scene and chat service scene as examples, which will be described below.
(一)邮件列表拉取业务(1) Mailing list pull business
图4是本公开实施例提供的一种邮件列表拉取业务的处理流程图,如图4所示,以终端侧账号发起的游戏业务请求为邮件列表拉取请求为例,邮件列表拉取请求的处理方法由业务服务器执行,业务服务器可以是一台集成式处理各类非实时业务的服务器,或者是单独部署的邮件业务服务器,其中,业务服务器为计算机设备的示例性说明。Fig. 4 is a processing flowchart of a mailing list pulling service provided by an embodiment of the present disclosure. The processing method is executed by a business server, and the business server may be an integrated server for processing various non-real-time businesses, or a separately deployed mail business server, wherein the business server is an exemplary description of computer equipment.
需要说明的是,这里仅对游戏服务器将邮件列表拉取请求对应的RPC请求发送到业务服务器,业务服务器创建协程以后的处理流程进行说明,即,本公开实施例的方案是在上一实施例中步骤305以后实现的,关于RPC请求如何从游戏服务器发送到业务服务器,以及业务服务器如何创建协程的方式,请参考上一实施例的描述,不再赘述。It should be noted that here only the game server sends the RPC request corresponding to the mailing list pull request to the business server, and the processing flow after the business server creates the coroutine is described, that is, the solution of the embodiment of the present disclosure is based on the previous implementation For the realization after step 305 in the example, how to send the RPC request from the game server to the business server, and how the business server creates a coroutine, please refer to the description of the previous embodiment, and will not go into details.
在一些实施例中,由于游戏中涉及到两类邮件:个人邮件和系统邮件,个人邮件是指玩家向玩家(即游戏账号向游戏账号)发送的邮件,系统邮件则是由游戏系统或游戏管理员向全服玩家下发的邮件,可选地,业务服务器侧对个人邮件和系统邮件分配不同的邮件序列号,并保持每种邮件序列号都呈递增,或者,业务服务器侧对个人邮件和系统邮件采取统一编码的邮件系列号,并保持邮件序列号递增,对于这两种不同的邮件序列号的分配方式,业务服务器侧的邮件列表拉取流程也不尽相同,下面将分别进行说明。In some embodiments, there are two types of emails involved in the game: personal emails and system emails. Personal emails refer to emails sent from players to players (ie, game account to game account), and system emails are sent by the game system or game management. Optionally, the business server assigns different mail serial numbers to personal mail and system mail, and keeps the serial numbers of each mail in increments, or, the business server side assigns personal mail and system mail The system mail adopts uniformly coded mail serial numbers and keeps the mail serial numbers incremented. For these two different mail serial number distribution methods, the mailing list pulling process on the business server side is also different, and the following will explain them separately.
情况一、个人邮件和系统邮件分开编码Situation 1: Individual emails and system emails are coded separately
在个人邮件和系统邮件分开编码的情况下,每封个人邮件都具有唯一标识的个人邮件序列号,每封系统邮件也具有唯一标识的系统邮件序列号,个人邮件序列号和系统邮件序列号可基于相同或不同的编码方式进行分配,且,个人邮件序列号和系统邮件序列号均保持递增。In the case of separate encoding of personal mail and system mail, each personal mail has a uniquely identified personal mail serial number, and each system mail also has a uniquely identified system mail serial number. The personal mail serial number and the system mail serial number can be Allocation is based on the same or different encoding methods, and the serial number of personal mail and the serial number of system mail keep increasing.
在步骤306-A1中,业务服务器通过协程获取邮件列表拉取请求中携带的账号的已拉取邮件中的最大个人邮件序列号和最大系统邮件序列号。In step 306-A1, the business server obtains the maximum personal email sequence number and the maximum system email sequence number in the pulled emails of the account carried in the email list pull request through the coroutine.
在一些实施例中,在个人邮件和系统邮件分开编码的情况下,终端侧在发起邮件列表拉取请求时,会确定当前登录游戏应用的账号的已拉取邮件中的最大个人邮件序列号和最大系统邮件序列号,比如,将上述最大个人邮件序列号和最大系统邮件序列号作为业务参数封装到邮件列表拉取请求中,游戏服务器在解析到上述业务参数后,将上述业务参数注入到邮件服务API,由邮件服务API对业务服务器发起RPC请求,RPC请求中携带上述邮件服务API中被注入的业务参数,使得业务服务器在创建协程后,该协程能够通过邮件服务API提供的业务参数,获取到最大个人邮件序列号和最大系统邮件序列号。In some embodiments, when personal emails and system emails are coded separately, when the terminal side initiates a mailing list pull request, it will determine the maximum personal email serial number and The maximum system email serial number, for example, encapsulate the above-mentioned maximum personal email serial number and maximum system email serial number as business parameters into the mailing list pull request, and after the game server parses the above business parameters, inject the above business parameters into the email Service API, the mail service API initiates an RPC request to the business server, and the RPC request carries the business parameters injected in the above mail service API, so that after the business server creates a coroutine, the coroutine can pass the business parameters provided by the mail service API , get the maximum personal mail sequence number and the maximum system mail sequence number.
在上述过程中,由于终端侧会在邮件列表拉取请求中提供两类已拉取邮件各自的最大邮件序列号,这样业务服务器能够可直接读取邮件服务API中传入的最大个人邮件序列号和最大系统邮件序列号,无需业务服务器对邮件列表拉取请求进行二次解析,能够节约业务服务器的处理资源。In the above process, since the terminal side will provide the maximum serial numbers of the two types of emails that have been pulled in the mailing list pull request, the business server can directly read the maximum serial number of personal emails passed in the mail service API and the maximum system email serial number, the business server does not need to perform secondary analysis on the mailing list pull request, which can save the processing resources of the business server.
在步骤306-A2中,业务服务器基于该最大个人邮件序列号,向数据库中该账号的个人邮件集合发起对个人邮件的批量读取操作,得到邮件序列号大于该最大个人邮件序列号的多封个人邮件。In step 306-A2, based on the maximum personal mail serial number, the business server initiates a batch read operation of personal mail to the personal mail collection of the account in the database, and obtains multiple mails whose serial number is greater than the maximum personal mail serial number personal mail.
其中,该批量读取操作用于读取邮件序列号大于该最大个人邮件序列号的多封个人邮件。Wherein, the batch read operation is used to read multiple personal emails whose serial numbers are greater than the maximum serial number of personal emails.
在一些实施例中,本公开实施例涉及的数据库是指邮件数据库,邮件数据库可以是Mango数据库、SQL数据库或其他类型的数据库,这里对数据库类型不进行具体限定。可选地,邮件数据库中维护有一个全局的系统邮件集合,用于存储所有的系统邮件,同时对每个账号还维护有自身的个人邮件集合,用于存储该账号所有的个人邮件。In some embodiments, the database involved in the embodiments of the present disclosure refers to a mail database, and the mail database may be a Mango database, an SQL database or other types of databases, and the database type is not specifically limited here. Optionally, a global system mail collection is maintained in the mail database for storing all system mails, and each account also maintains its own personal mail collection for storing all personal mails of the account.
在一些实施例中,在业务服务器侧单独维护有邮件数据库的情况下,在通过步骤306-A1获取到最大个人邮件序列号以后,以该账号的账号ID为索引,查询到该账号的个人邮件集合,个人邮件集合中的个人邮件按照邮件序列号从小到大的顺序依次排列,然后,从该最大个人邮件序列号所指示的最新已读个人邮件的下一封个人邮件开始依次向后读取,直到没有新的可读取的个人邮件,即可得到邮件序列号大于该最大个人邮件序列号的全部个人邮件。In some embodiments, in the case where the mail database is maintained separately on the service server side, after the maximum personal mail serial number is obtained through step 306-A1, the personal mail of the account is queried using the account ID of the account as an index. Collection, the personal mails in the personal mail collection are arranged in descending order of the mail serial number, and then read backwards from the personal mail next to the latest read personal mail indicated by the largest personal mail serial number , until there is no new personal mail that can be read, all personal mails with mail serial numbers greater than the maximum personal mail serial number can be obtained.
在步骤306-A3中,业务服务器基于该最大系统邮件序列号,向数据库的系统邮件集合发起对系统邮件的批量读取操作,得到邮件序列号大于该最大系统邮件序列号的多封系统邮件。In step 306-A3, based on the maximum system mail serial number, the business server initiates a batch read operation of system mails to the system mail collection in the database, and obtains multiple system mails whose mail serial numbers are greater than the maximum system mail serial number.
其中,该批量读取操作用于读取邮件序列号大于该最大系统邮件序列号的多封系统邮件。Wherein, the batch read operation is used to read multiple system mails whose mail serial numbers are greater than the maximum system mail serial number.
在一些实施例中,在业务服务器侧单独维护有邮件数据库的情况下,在通过步骤306-A1获取到最大系统邮件序列号以后,查询到邮件数据库中的系统邮件集合,系统邮件集合中的系统邮件按照邮件序列号从小到大的顺序依次排列,然后,从该最大系统邮件序列号所指示的最新已读系统邮件的下一封系统邮件开始依次向后读取,直到没有新的可读取的系统邮件,即可得到邮件序列号大于该最大系统邮件序列号的全部系统邮件。In some embodiments, in the case where the mail database is maintained separately on the service server side, after the maximum system mail serial number is obtained through step 306-A1, the system mail collection in the mail database is queried, and the system mail collection in the system mail collection Mails are arranged in descending order of mail sequence numbers, and then read backwards from the next system mail indicated by the latest read system mail number, until there is no new one to read system mail, you can get all the system mails whose mail sequence number is greater than the maximum system mail sequence number.
在上述过程中,仅邮件列表拉取请求指示业务服务器获取到未拉取的全部个人邮件和全部系统邮件的情况为例进行说明,在一些实施例中,假设账号切换设备后,新切换到的终端可能有很多未拉取的邮件,如果一次性获取全部未拉取的邮件,很可能会响应速度很慢,因此用户可以选择仅拉取最近50封,最近100封,最近200封等,这时可在邮件列表拉取请求中添加邮件拉取数量这一业务参数,在这种情况下可以找到全部未拉取的邮件以后挑选出来最新的符合邮件拉取数量的多封邮件。In the above process, only the case where the mailing list pull request instructs the business server to obtain all personal emails and all system emails that have not been pulled is used as an example. In some embodiments, it is assumed that after the account is switched to the device, the newly switched The terminal may have a lot of emails that have not been fetched. If you get all the emails that have not been fetched at once, the response speed is likely to be very slow. Therefore, the user can choose to fetch only the last 50, the last 100, and the last 200, etc. You can add the business parameter of the number of emails to be pulled in the mailing list pull request. In this case, you can find all the emails that have not been pulled and then select the latest multiple emails that meet the number of emails to be pulled.
在上述步骤306-A1至步骤306-A3中,提供了业务服务器通过协程发起非实时业务的数据库操作的一种可能实施方式,即,在个人邮件和系统邮件分开编码的情况下,分别按照最大个人邮件序列号,从个人邮件集合中发起批量读取操作,以及按照最大系统邮件序列号,从系统邮件集合中发起批量读取操作。In the above step 306-A1 to step 306-A3, a possible implementation mode for the business server to initiate the database operation of the non-real-time business through the coroutine is provided, that is, in the case of separate encoding of the personal mail and the system mail, respectively according to The maximum personal mail sequence number to initiate a batch read operation from the personal mail collection, and initiate a batch read operation from the system mail collection according to the maximum system mail sequence number.
这种个人邮件和系统邮件分开编码的方式,对未拉取的各个系统邮件和未拉取的各个个人邮件都仅需要执行一次读取操作,即,将系统邮件从系统邮件集合中读取出来,将个人邮件从个人邮件集合中读取出来,不涉及到系统邮件的备份(更不涉及备份时的重排序),因此数据库操作的开销小,事务执行效率高,但在业务参数中携带邮件拉取数量的情况下,由于需要比较个人邮件序列号和系统邮件序列号的大小,因此可能会略微增加计算开销。In this way of encoding personal emails and system emails separately, only one read operation is required for each unfetched system email and each unfettered personal email, that is, the system email is read from the system email collection , to read personal emails from the personal email collection, which does not involve the backup of system emails (not to mention the reordering during backup), so the overhead of database operations is small, and the transaction execution efficiency is high, but the emails are carried in the business parameters In the case of pulling the quantity, due to the need to compare the size of the personal message sequence number and the system message sequence number, it may slightly increase the calculation overhead.
情况二、个人邮件和系统邮件统一编码Situation 2: Uniform encoding of personal emails and system emails
在另一些实施例中,还提供对个人邮件和系统邮件统一编码的方式,这样将不再区分个人邮件序列号和系统邮件序列号,每封个人邮件或系统邮件都会分配到唯一的邮件序列号,并保持邮件序列号全局递增。In some other embodiments, it also provides a way to uniformly encode personal emails and system emails, so that the serial numbers of personal emails and system emails will no longer be distinguished, and each personal email or system email will be assigned a unique email serial number , and keep the message sequence number globally incremented.
在步骤306-B1中,业务服务器通过协程获取邮件列表拉取请求中携带的账号的已拉取邮件中的最大邮件序列号。In step 306-B1, the business server obtains the largest email serial number among the pulled emails of the account carried in the email list pull request through the coroutine.
在一些实施例中,在个人邮件和系统邮件统一编码的情况下,终端侧在发起邮件列表拉取请求时,会确定当前登录游戏应用的账号的已拉取邮件中的最大邮件序列号,比如,将上述最大邮件序列号作为业务参数封装到邮件列表拉取请求中,游戏服务器在解析到上述业务参数后,将上述业务参数注入到邮件服务API,由邮件服务API对业务服务器发起RPC请求,RPC请求中携带上述邮件服务API中被注入的业务参数,使得业务服务器在创建协程后,该协程能够通过邮件服务API提供的业务参数,获取到最大邮件序列号。In some embodiments, in the case of uniform encoding of personal emails and system emails, when the terminal side initiates a mailing list pull request, it will determine the largest email sequence number in the pulled emails of the account currently logged into the game application, such as , encapsulate the above maximum email serial number as a business parameter into the mailing list pull request, after the game server parses the above business parameters, inject the above business parameters into the mail service API, and the mail service API initiates an RPC request to the business server, The RPC request carries the business parameters injected in the mail service API above, so that after the business server creates a coroutine, the coroutine can obtain the maximum mail serial number through the business parameters provided by the mail service API.
在上述过程中,由于终端侧会在邮件列表拉取请求中提供全局的最大邮件序列号,这样业务服务器能够可直接读取邮件服务API中传入的最大邮件序列号,无需业务服务器对邮件列表拉取请求进行二次解析,能够节约业务服务器的处理资源。In the above process, since the terminal side will provide the global maximum mail serial number in the mailing list pull request, the business server can directly read the maximum mail serial number incoming in the mail service API, without requiring the business server to update the mailing list. The secondary analysis of the pull request can save the processing resources of the business server.
在步骤306-B2中,业务服务器基于该最大邮件序列号,向数据库的系统邮件集合发起对系统邮件的批量读取操作,得到邮件序列号大于该最大邮件序列号的多封系统邮件。In step 306-B2, the business server initiates a batch read operation of system mails to the system mail collection in the database based on the maximum mail serial number, and obtains multiple system mails whose mail serial numbers are greater than the maximum mail serial number.
其中,该批量读取操作用于读取邮件序列号大于该最大邮件序列号的多封系统邮件。Wherein, the batch read operation is used to read multiple system emails whose email sequence numbers are greater than the maximum email sequence number.
在一些实施例中,本公开实施例涉及的数据库是指邮件数据库,邮件数据库可以是Mango数据库、SQL数据库或其他类型的数据库,这里对数据库类型不进行具体限定。可选地,邮件数据库中维护有一个全局的系统邮件集合,用于存储所有的系统邮件,同时对每个账号还维护有自身的个人邮件集合,用于存储该账号所有的个人邮件。In some embodiments, the database involved in the embodiments of the present disclosure refers to a mail database, and the mail database may be a Mango database, an SQL database or other types of databases, and the database type is not specifically limited here. Optionally, a global system mail collection is maintained in the mail database for storing all system mails, and each account also maintains its own personal mail collection for storing all personal mails of the account.
在一些实施例中,在业务服务器侧单独维护有邮件数据库的情况下,在通过步骤306-B1获取到最大邮件序列号以后,查询到邮件数据库中的系统邮件集合,系统邮件集合中的系统邮件按照邮件序列号从小到大的顺序依次排列,然后,从该最大邮件序列号所指示的最新已读系统邮件的下一封系统邮件开始依次向后读取,直到没有新的可读取的系统邮件,即可得到邮件序列号大于该最大邮件序列号的全部系统邮件。In some embodiments, in the case where the mail database is maintained separately on the service server side, after the maximum mail serial number is obtained through step 306-B1, the system mail collection in the mail database is queried, and the system mail collection in the system mail collection Arranged in descending order of mail sequence numbers, and then read backwards from the next system mail of the latest read system mail indicated by the largest mail sequence number until there is no new readable system mail Mail, you can get all the system mails whose mail serial number is greater than the maximum mail serial number.
在步骤306-B3中,业务服务器将该多封系统邮件存入该数据库中该账号的个人邮件集合。In step 306-B3, the service server stores the multiple system emails into the personal email collection of the account in the database.
在一些实施例中,为了方便进行邮件批量读取,在个人邮件和系统邮件统一编码的情况下,业务服务器基于步骤306-B2读取到邮件序列号大于该最大邮件序列号的全部系统邮件以后,还可以以该账号的账号ID为索引,在邮件数据库中定位到该账号的个人邮件集合,将上述邮件序列号大于该最大邮件序列号的全部系统邮件存入到该账号的个人邮件集合中,这样方便后续在个人邮件集合中一次性扫描到所有的未拉取邮件。In some embodiments, in order to facilitate batch reading of emails, in the case of uniform encoding of personal emails and system emails, the business server reads all system emails with email serial numbers greater than the maximum email serial number based on step 306-B2 , you can also use the account ID of the account as an index to locate the personal mail collection of the account in the mail database, and store all system mails with the serial numbers of the above mails greater than the maximum mail serial number into the personal mail collection of the account , so that it is convenient to scan all the unfetched emails in the personal mail collection at one time.
在一些实施例中,业务服务器在向个人邮件集合中存入全部系统邮件时,需要按照邮件序列号从小到大的顺序来依次存储,即保证在全部系统邮件存入到个人邮件集合中以后,个人邮件集合中的所有邮件仍然保持邮件序列号递增的次序存放(不能乱序)。具体的,在存入每一封系统邮件时,业务服务器都在个人邮件集合中找到邮件序列号与当前系统邮件最接近且不超过的目标邮件,并将当前系统邮件插入到该目标邮件之后(紧挨着目标邮件),即能够保证系统邮件在存放时不会乱序。In some embodiments, when the service server stores all system mails in the personal mail collection, it needs to store them sequentially according to the serial numbers of the mails in ascending order, that is, to ensure that after all system mails are stored in the personal mail collection, All the mails in the personal mail collection are still stored in the increasing order of the mail serial number (not out of order). Specifically, when storing each system mail, the service server finds the target mail whose serial number is the closest to and does not exceed the current system mail in the personal mail collection, and inserts the current system mail after the target mail ( Next to the target mail), that is, it can ensure that the system mail will not be out of order when stored.
在另一些实施例中,业务服务器在向个人邮件集合中存入全部系统邮件后,将个人邮件集合按照邮件序列号从小到大的顺序进行重排序,这样无需在存放时考虑是否乱序,但由于需要对个人邮件集合进行重排序,资源开销较大。In some other embodiments, after storing all system mails in the personal mail collection, the service server reorders the personal mail collection according to the sequence number of the mail from small to large, so that there is no need to consider whether the order is out of order when storing, but Resource overhead due to the need to reorder individual mail collections.
在步骤306-B4中,业务服务器基于该最大邮件序列号,向该个人邮件集合发起对邮件的批量读取操作,得到邮件序列号大于该最大邮件序列号的多封邮件。In step 306-B4, the service server initiates a batch read operation of mails to the personal mail collection based on the maximum mail serial number, and obtains multiple mails with mail serial numbers greater than the maximum mail serial number.
其中,该批量读取操作用于读取邮件序列号大于该最大邮件序列号的多封邮件。Wherein, the batch read operation is used to read a plurality of mails whose serial numbers are greater than the maximum mail serial number.
在一些实施例中,在业务服务器将邮件序列号大于该最大邮件序列号的全部系统邮件存入到该账号的个人邮件集合以后,在个人邮件集合中的所有邮件(个人邮件和系统邮件)都按照邮件序列号从小到大的顺序依次排列的情况下,从该最大邮件序列号所指示的最新已读邮件的下一封邮件开始依次向后读取,直到没有新的可读取的邮件,即可得到邮件序列号大于该最大邮件序列号的全部邮件。In some embodiments, after the service server stores all system emails with email sequence numbers greater than the maximum email sequence number into the account's personal mail collection, all mails (personal mail and system mail) in the personal mail collection are When the mail sequence numbers are arranged in descending order, read backwards from the next mail of the latest read mail indicated by the largest mail serial number until there are no new readable mails. You can get all the mails whose mail serial numbers are greater than the maximum mail serial number.
在上述过程中,仅邮件列表拉取请求指示业务服务器获取到未拉取的全部邮件的情况为例进行说明,在一些实施例中,假设账号切换设备后,新切换到的终端可能有很多未拉取的邮件,如果一次性获取全部未拉取的邮件,很可能会响应速度很慢,因此用户可以选择仅拉取最近50封,最近100封,最近200封等,这时可在邮件列表拉取请求中添加邮件拉取数量这一业务参数,在这种情况下可以找到全部未拉取的邮件以后挑选出来最新的符合邮件拉取数量的多封邮件,或者,直接在将邮件序列号大于该最大邮件序列号的全部系统邮件存入到该账号的个人邮件集合以后,从个人邮件集合中最新邮件(指邮件序列号最大的邮件)开始依次往前读取,直到读到符合邮件拉取数量的多封邮件时停止读取。In the above process, only the case where the email list pull request indicates that the service server has obtained all emails that have not been pulled is taken as an example. In some embodiments, it is assumed that after the account is switched, the newly switched terminal may have many Pulled emails, if you get all the emails that have not been pulled at one time, the response speed is likely to be very slow, so the user can choose to pull only the last 50, last 100, last 200, etc., at this time can be found in the mailing list Add the business parameter of the number of emails to be pulled in the pull request. In this case, you can find all the emails that have not been pulled and select the latest multiple emails that meet the number of emails to be pulled, or directly add the serial number of the email After all system emails with a serial number greater than the maximum email number are stored in the personal mail collection of the account, read from the latest mail in the personal mail collection (referring to the mail with the largest mail serial number) in order, until it reads the mail that matches the pull Stop reading when fetching multiple messages.
在上述步骤306-B1至步骤306-B4中,提供了业务服务器通过协程发起非实时业务的数据库操作的一种可能实施方式,即,在个人邮件和系统邮件统一编码的情况下,先按照最大邮件序列号,从系统邮件集合中找到未拉取的全部系统邮件,将未拉取的全部系统邮件按序存入到个人邮件集合中,再从个人邮件集合中再次进行批量读取操作。In the above step 306-B1 to step 306-B4, a possible implementation mode for the business server to initiate the database operation of the non-real-time business through the coroutine is provided, that is, in the case of uniform encoding of personal mail and system mail, first follow the The maximum email serial number, find all system emails that have not been pulled from the system email collection, store all the system emails that have not been pulled into the personal mail collection in order, and then perform batch read operations from the personal mail collection again.
这种个人邮件和系统邮件统一编码的方式,方便了在业务参数中携带邮件拉取数量的情况下,直接从最新邮件开始逐渐往前读取,能够提升仅获取部分未拉取邮件的效率,但由于需要批量读取未拉取的全部系统邮件再存入个人邮件集合,之后批量读取时又需要在个人邮件集合中重新读取一次备份后的部分或全部系统邮件,导致需要对上述备份后的系统邮件执行两次读取操作,其数据库操作的开销略大。This method of uniform encoding of personal emails and system emails facilitates reading directly from the latest emails in the case of carrying the number of emails pulled in the business parameters, which can improve the efficiency of only obtaining some unpull emails. However, due to the need to batch read all the system emails that have not been pulled and store them in the personal email collection, and then need to re-read some or all of the backed up system emails in the personal email collection when batch reading, it is necessary to perform the above backup The latter system mail performs two read operations, and its database operation is slightly more expensive.
图5是本公开实施例提供的一种业务服务器中邮件数据库的逻辑结构图,如图5所示,在邮件服务(Mail Service)系统500中,配置有邮件数据库510,可选地,邮件数据库510以Mango数据库实现。在邮件数据库510中维护有全局的系统邮件(global_mail)集合511以及每个账号的个人邮件(personal_mail)集合512,每个账号的个人邮件被存放在该账号的个人邮件集合512中,全服发送的系统邮件则被统一存放在系统邮件集合511中。Fig. 5 is the logical structural diagram of the mail database in a kind of business server that the embodiment of the present disclosure provides, as shown in Fig. 5, in the mail service (Mail Service)
在个人邮件和系统邮件分开编码的方式下,个人邮件集合512中各封个人邮件保持有自增的个人邮件序列号personal_mailID,系统邮件集合511中各封系统邮件保持有自增的系统邮件序列号global_mailID,personal_mailID和global_mailID可采取相同或不同的编码方式。在这种情况下,可基于步骤306-A1至步骤306-A3的方式来读取所有未拉取的邮件。In the way that personal emails and system emails are encoded separately, each personal email in the
在个人邮件和系统邮件统一编码的方式下,个人邮件集合512中各封个人邮件和系统邮件集合511中各封系统邮件共同保持有自增的邮件序列号mailID。在这种情况下,可基于步骤306-B1至步骤306-B4的方式来读取所有未拉取的邮件。In the manner of uniform encoding of personal mails and system mails, each personal mail in the
上述两种情况,提供了在不同的邮件序列号的编码方式下,业务服务器通过协程发起非实时业务的数据库操作的两种可能实施方式,通过以上方式,能够发起对邮件数据库的批量读取操作,这时仍然可执行上一实施例中的步骤307,即在未获取到数据库操作的操作结果时阻塞协程,然后,在获取到数据库操作的操作结果时,若操作结果指示事务提交(而非事务回滚),则执行以下步骤401-403:The above two cases provide two possible implementation methods for the business server to initiate non-real-time business database operations through coroutines under different encoding methods of mail serial numbers. Through the above methods, batch reading of mail databases can be initiated At this time,
在步骤401中,业务服务器基于批量读取操作的操作结果所返回的多封邮件,确定邮件未读数量。In
在一些实施例中,业务服务器通过上述任一种可能实施方式,执行完对未拉取邮件的批量读取操作以后,在批量读取操作的操作结果指示事务提交的情况下,能够获取到批量读取到的多封邮件,统计上述批量读取到的多封邮件的数量,得到邮件未读数量。In some embodiments, after the business server executes the batch read operation on the unpulled emails through any of the above possible implementation modes, if the operation result of the batch read operation indicates that the transaction is committed, it can obtain the batch For the multiple emails that have been read, count the number of multiple emails read in batches above to obtain the number of unread emails.
在步骤402中,业务服务器提取该多封邮件的信息摘要,该信息摘要用于提供以下至少一项:邮件类型、邮件标题、发件人信息、邮件时间戳以及是否含有附件。In
其中,邮件类型用于指示邮件为个人邮件还是系统邮件。Wherein, the mail type is used to indicate whether the mail is a personal mail or a system mail.
其中,发件人信息是指邮件发件人的相关信息,如相关信息包括邮件发件人在游戏内的账号昵称、账号ID、账号头像中至少一项。Wherein, the sender information refers to relevant information of the sender of the email, for example, the relevant information includes at least one of the sender's account nickname, account ID, and account profile picture in the game.
其中,邮件时间戳是指邮件发件人发送该邮件的发件时间戳。Wherein, the email timestamp refers to the sending timestamp when the email sender sends the email.
其中,是否含有附件用于指示该邮件中是否包含附件,可以是一个二值变量或布尔型变量,当二值变量取值为1或布尔值变量取值为True时指示邮件含有附件,当二值变量取值为0或布尔值变量取值为False时指示邮件不含有附件。Among them, whether there are attachments is used to indicate whether the mail contains attachments. It can be a binary variable or a Boolean variable. When the value of the binary variable is 1 or the value of the Boolean variable is True, it indicates that the mail contains attachments. A Value variable of 0 or a Boolean variable of False indicates that the message contains no attachments.
在一些实施例中,在批量读取到的多封邮件时,如果一次性向终端返回全部邮件,一方面数据传输的通信开销大、占用带宽多,另一方面数据传输效率低,终端需要等待很久才能收到响应。有鉴于此,业务服务器可以提取上述批量读取到的多封邮件的信息摘要,比如,提取每封邮件的邮件类型、邮件标题、发件人信息、邮件时间戳以及是否含有附件中至少一项,组成这封邮件的信息摘要(mailInfo),在生成针对邮件列表拉取请求的响应时,可以仅携带批量读取到的各封邮件的信息摘要,而不携带具体邮件正文(如果邮件含附件的情况下也不携带附件),这样能够极大节约对上述响应在传输时的通信开销,节约响应传输所占用的带宽,提升数据传输效率以及对邮件列表拉取请求的响应效率。In some embodiments, when multiple emails are read in batches, if all emails are returned to the terminal at one time, on the one hand, the communication overhead of data transmission is large and occupies a lot of bandwidth; on the other hand, the efficiency of data transmission is low, and the terminal needs to wait for a long time to receive a response. In view of this, the business server can extract the information summary of the multiple emails read in batches above, for example, extract the email type, email title, sender information, email timestamp and whether it contains at least one of the attachments of each email , the information summary (mailInfo) that makes up this email, when generating a response to the mailing list pull request, can only carry the information summary of each email read in batches, without carrying the specific email body (if the email contains attachments In this case, no attachments are carried), which can greatly save the communication overhead during transmission of the above responses, save the bandwidth occupied by response transmission, improve data transmission efficiency and response efficiency to mailing list pull requests.
在一些实施例中,在提取每封邮件的信息摘要时,判断该邮件的发件人是否为游戏管理员或游戏系统,则将邮件类型赋值为系统邮件;否则,将邮件类型赋值为个人邮件,并将赋值完毕的邮件类型写入到邮件的信息摘要中。In some embodiments, when extracting the information summary of each email, it is judged whether the sender of the email is a game administrator or a game system, and then the email type is assigned as a system email; otherwise, the email type is assigned as a personal email , and write the assigned mail type into the message summary of the mail.
在一些实施例中,在提取每封邮件的信息摘要时,提取该邮件的邮件标题,并将提取到的邮件标题以字符串的形式写入到邮件的信息摘要中。In some embodiments, when the information summary of each email is extracted, the email title of the email is extracted, and the extracted email title is written into the email information summary in the form of a character string.
在一些实施例中,在提取每封邮件的信息摘要时,提取该邮件的发件人在游戏内的账号昵称、账号ID、账号头像中至少一项,并将提取到的发件人信息写入到邮件的信息摘要中。In some embodiments, when extracting the information summary of each email, extract at least one of the sender's account nickname, account ID, and account avatar in the game, and write the extracted sender information to into the message digest of the email.
在一些实施例中,在提取每封邮件的信息摘要时,提取该邮件发件人发送该邮件的发件时间戳,并将提取到的邮件时间戳写入到邮件的信息摘要中。In some embodiments, when the information summary of each email is extracted, the sending timestamp of the email sent by the sender of the email is extracted, and the extracted email timestamp is written into the information summary of the email.
在一些实施例中,在提取每封邮件的信息摘要时,判断该邮件是否含有附件,如果邮件含有附件,将用于指示是否含有附件的二值变量置为1或将布尔型变量置为True;否则,将用于指示是否含有附件的二值变量置为0或将布尔型变量置为False,并将赋值完毕的变量写入到邮件的信息摘要中。In some embodiments, when extracting the information summary of each email, it is judged whether the email contains attachments, and if the email contains attachments, the binary variable indicating whether the attachment is included is set to 1 or the Boolean variable is set to True ; Otherwise, set the binary variable used to indicate whether there is an attachment to 0 or set the Boolean variable to False, and write the assigned variable to the message summary of the mail.
在一些实施例中,在获取上述一项或者多项信息并生成信息摘要时,可以在初始化一个信息摘要,包括邮件类型、邮件标题、发件人信息、邮件时间戳以及是否含有附件这4个字段,并将对当前邮件实际提取到的信息写入以上4个字段,可选地,信息摘要以列表、哈希表、动态数组、多组Key-Value数据结构、URL(Uniform Resource Locator,统一资源定位符)字符串等数据形式实现,本公开实施例对信息摘要的数据形式不进行具体限定。In some embodiments, when one or more pieces of information above are obtained and an information summary is generated, an information summary may be initialized, including four items: email type, email title, sender information, email timestamp, and whether it contains attachments. field, and write the information actually extracted from the current mail into the above 4 fields. Optionally, the information summary is in the form of a list, hash table, dynamic array, multiple sets of Key-Value data structures, URL (Uniform Resource Locator, unified resource locator) character string and other data forms, the embodiment of the present disclosure does not specifically limit the data form of the information summary.
在一些实施例中,除了上述4个字段以外,还可以根据业务需求灵活增加或删除信息摘要中的字段,比如,增加邮件有效时间字段,来指示邮件的有效时间(比如截止某个时间点以前有效),又比如,增加附件有效时间字段,来指示附件的有效时间(如虚拟道具类的附件限定某个时间点以前领取否则失效),本公开实施例对信息摘要的字段组成不进行具体限定。In some embodiments, in addition to the above four fields, fields in the information summary can be flexibly added or deleted according to business requirements, for example, an email validity time field is added to indicate the validity time of the email (for example, before a certain time point valid), another example is to add an attachment valid time field to indicate the valid time of the attachment (for example, the attachment of virtual props must be received before a certain time point, otherwise it will be invalid), and the embodiment of the present disclosure does not specifically limit the field composition of the information summary .
在步骤403中,业务服务器生成携带该信息摘要和该邮件未读数量的响应。In
在一些实施例中,业务服务器将上述步骤401中获取的邮件未读数量以及上述步骤402中生成的信息摘要封装到响应中,再将响应直接发送给发送邮件列表拉取请求的终端,可降低通信轮次,节约通信开销。In some embodiments, the business server encapsulates the number of unread emails obtained in the
在一些实施例中,业务服务器将上述封装完毕的响应发送给游戏服务器,再由游戏服务器将上述响应发送给终端,这样能够保证终端对后台微服务架构无感知,使得游戏中非实时业务的拆分部署对用户侧透明、无感知。In some embodiments, the business server sends the packaged response to the game server, and then the game server sends the above response to the terminal, which can ensure that the terminal is not aware of the background micro-service architecture, so that the dismantling of non-real-time services in the game The sub-deployment is transparent and imperceptible to the user side.
在上述步骤401-403中,提供了业务服务器生成响应的一种可能实施方式,即,业务服务器侧生成响应,由业务服务器直接向终端返回响应,或由业务服务器将响应发送到游戏服务器再由游戏服务器转发到终端,由于响应中仅携带了未拉取的各封邮件的信息摘要,而不携带每封邮件的邮件正文,这样信息摘要本身就已经支持了在终端侧对邮件列表的正常显示,只有在检测到用户对具体某一封邮件的查看操作时,才会拉取这一封邮件的邮件正文,不但极大节约了通信带宽和通信开销,而且提升了对邮件列表拉取请求的响应效率。In the above steps 401-403, a possible implementation manner of generating the response by the business server is provided, that is, the business server side generates the response, and the business server directly returns the response to the terminal, or the business server sends the response to the game server and then the The game server forwards it to the terminal. Since the response only carries the information summary of each email that has not been pulled, and does not carry the email text of each email, the information summary itself already supports the normal display of the mailing list on the terminal side. , only when it is detected that the user checks a specific email, the email body of this email will be pulled, which not only greatly saves communication bandwidth and communication overhead, but also improves the efficiency of pulling requests from mailing lists. Response efficiency.
在另一些实施例中,业务服务器将上述步骤401中获取的邮件未读数量以及上述步骤402中生成的信息摘要以回调方式通知到游戏服务器侧的邮件服务API,使得游戏服务器能够通过邮件服务API,获取到业务服务器回传的邮件未读数量和信息摘要,接着游戏服务器将邮件未读数量和信息摘要封装到响应中,将响应发送给终端,这样业务服务器无需解析请求也无需封装响应,只需要根据业务参数执行对应数据库操作再返回操作完毕的业务数据(即信息摘要和邮件未读数量)即可,极大节约业务服务器的处理资源。In some other embodiments, the business server notifies the email service API on the game server side of the number of unread emails obtained in the
在上述实施例中,提供了业务服务器侧在邮件序列号的不同编码方式下,如何从邮件数据库中读取终端侧未拉取的邮件,以及如何生成对邮件列表拉取请求的响应。在一些实施例中,如果游戏服务器在同一时间段内涌入过多的邮件列表拉取请求,业务服务器在同一时间段内可能会涌入过多的RPC请求,可能会导致业务服务器繁忙或宕机,为了进一步保证业务服务器的高可用性,可以在游戏服务器侧对同一时间段内涌入的大量邮件列表拉取请求做分帧操作,或者,在业务服务器侧对同一时间段内涌入的大量RPC请求做分帧操作,即,添加一个定时器,定时分批处理同一时间段内涌入的大量邮件列表拉取请求或RPC请求。图6是本公开实施例提供的一种分帧处理邮件列表拉取请求的方法流程图,如图6所示,以在业务服务器侧对同一时间段内涌入的大量RPC请求做分帧操作为例进行说明,该方法可接在以上实施例中的步骤304以后:In the above embodiments, it is provided how the service server side reads the emails not pulled from the terminal side from the email database and how to generate a response to the email list pulling request under different encoding methods of the email serial number on the business server side. In some embodiments, if the game server floods too many mailing list pull requests in the same time period, the business server may flood too many RPC requests in the same time period, which may cause the business server to be busy or go down. machine, in order to further ensure the high availability of the business server, the game server side can be divided into frames for a large number of mailing list pull requests that influx in the same time period, or, on the business server side, a large number of influx in the same time period The RPC request is divided into frames, that is, a timer is added to batch process a large number of mailing list pull requests or RPC requests that influx in the same period of time. Fig. 6 is a flow chart of a method for processing mailing list pull requests in frames according to an embodiment of the present disclosure. As shown in Fig. 6, a large number of RPC requests flooding in at the same time period are performed on the business server side in frames As an example for illustration, this method can be followed after step 304 in the above embodiment:
在步骤601中,在同一时间段内累计接收到的多个邮件列表拉取请求的数量超过请求量阈值的情况下,业务服务器缓存该多个邮件列表拉取请求关联的多个RPC请求到消息队列中。In
在一些实施例中,以上述时间段为当前时刻以前的指定时长到当前时刻所构成的时间段为例进行说明,可由游戏服务器来统计上述时间段内累计接收到的邮件列表拉取请求的数量,并判断该数量是否大于请求量阈值,若该数量大于请求量阈值,代表需要在业务服务器侧开启分帧操作,向业务服务器发送分帧操作开启指令,以使业务服务器将上述时间段内接收到的多个RPC请求缓存到消息队列中。其中,指定时长是由技术人员在后台预先配置的大于0的数值,请求量阈值是由技术人员在后台预先配置的大于0的整数。In some embodiments, the above-mentioned time period is taken as an example to describe the time period formed from the specified time before the current time to the current time, and the game server can count the cumulative number of mailing list pull requests received during the above-mentioned time period , and judge whether the number is greater than the request threshold. If the number is greater than the request threshold, it means that the framing operation needs to be enabled on the business server side, and the framing operation start instruction should be sent to the business server so that the business server will receive within the above time period. Received multiple RPC requests are cached in the message queue. The specified duration is a value greater than 0 pre-configured by the technician in the background, and the request volume threshold is an integer greater than 0 pre-configured by the technician in the background.
在一些实施例中,无需游戏服务器来统计上述时间段内接收的邮件列表拉取请求的数量,而是由业务服务器自行统计上述时间段内接收到的RPC请求的数量,并判断该数量是否大于请求量阈值,若该数量大于请求量阈值,代表业务服务器需要自动开启分帧操作,这样无需游戏服务器来给出指示,且节约了一轮关于分帧操作开启指令的通信开销。In some embodiments, there is no need for the game server to count the number of mailing list pull requests received within the above time period, but the business server counts the number of RPC requests received within the above time period by itself, and judges whether the number is greater than Request volume threshold, if the number is greater than the request volume threshold, it means that the business server needs to automatically enable the frame division operation, so that there is no need for the game server to give instructions, and it saves a round of communication overhead for the frame division operation activation command.
在一些实施例中,业务服务器侧检测到需要开启分帧操作的情况下,创建一个消息队列,接着,将上述时间段内接收到的多个RPC请求统一缓存到消息队列中。In some embodiments, when the business server side detects that the framing operation needs to be enabled, a message queue is created, and then multiple RPC requests received within the above time period are uniformly buffered into the message queue.
在步骤602中,业务服务器在该消息队列中,合并同一发起账号多次发送的相同邮件列表拉取请求关联的RPC请求,对该发起账号配置请求次数变量。In
在一些实施例中,由于用户很可能在短时间内连续多次发送相同的邮件列表拉取请求,因此,业务服务器需要遍历一次消息队列,将消息队列中来自同一个发起账号的RPC请求都进行合并,即,仅保留一个携带请求次数变量的RPC请求,删除其余重复的RPC请求,比如,仅保留时间戳最早的RPC请求,删除后来的新的RPC请求,同时对保留的这一个RPC请求配置一个请求次数变量,并将统计到的消息队列中所有来自该发起账号的RPC请求的数量赋值给上述请求次数变量,需要说明的是,随着时间的推移,如果仍然没有轮到处理该RPC请求,若后续接收到新的重复的RPC请求,业务服务器无需存储新到的重复的RPC请求,只需要将上述请求次数变量自增1即可,这样也能节约业务服务器的存储开销。In some embodiments, since the user is likely to send the same mailing list pull request multiple times in a short period of time, the service server needs to traverse the message queue once to process all the RPC requests from the same originating account in the message queue. Merge, that is, keep only one RPC request with the variable number of requests, and delete the remaining duplicate RPC requests, for example, keep only the RPC request with the earliest timestamp, delete the new RPC request later, and configure the reserved RPC request at the same time A request count variable, and assign the counted number of RPC requests from the originating account in the message queue to the above request count variable. It should be noted that, as time goes by, if it is still not the turn to process the RPC request , if a new repeated RPC request is subsequently received, the business server does not need to store the newly arrived repeated RPC request, but only needs to increment the variable of the number of requests above by 1, which can also save the storage cost of the business server.
在步骤603中,业务服务器基于该请求次数变量,对该消息队列中的各个RPC请求进行重排序。In
在一些实施例中,在经过步骤602中对消息队列中所有RPC请求的遍历以后,消息队列中不再含有来自相同发起账号的重复RPC请求,此后,业务服务器可以基于每个RPC请求的请求次数变量,来对消息队列中的各个RPC请求进行重排序,这样相当于增加了一个请求次数变量作为权重,来衡量RPC请求的加急程度,因为用户侧如果比较着急拉取邮件列表,很可能对短时间内多次触发相同的邮件列表拉取请求,这样的请求是比较需要优先处理的,可适当将这样的请求排在消息队列的靠前位置。In some embodiments, after traversal of all RPC requests in the message queue in
可选地,在重排序过程中,按照请求次数变量从大到小的顺序,对消息队列中的各个RPC请求进行排序,这样的排序逻辑较为简单易于实现,复杂度低。Optionally, in the reordering process, the RPC requests in the message queue are sorted in descending order of the request times variable, such sorting logic is relatively simple and easy to implement, and the complexity is low.
可选地,在重排序过程中,对于请求次数变量大于目标阈值的一个或多个RPC请求,将这些RPC请求置于消息队列中其余RPC请求的前方,并按照请求时间戳从旧到新或者按照请求次数变量从大到小的次序进行重排序,对于消息队列中请求次数变量小于或等于目标阈值的其余RPC请求,则仍然按照原本的请求时间戳从旧到新的次序进行排序,其中,目标阈值是技术人员在后台预先配置的大于0的整数。Optionally, in the reordering process, for one or more RPC requests whose request times variable is greater than the target threshold, these RPC requests are placed in front of the rest of the RPC requests in the message queue, and are ordered from the oldest to the newest according to the request timestamp or Reorder according to the order of the number of requests variable from large to small. For the rest of the RPC requests whose request times variable in the message queue is less than or equal to the target threshold, they are still sorted according to the order of the original request timestamp from old to new. Among them, The target threshold is an integer greater than 0 pre-configured by the technician in the background.
可选地,在重排序过程中,对每个RPC请求,按照请求时间戳和请求次数变量两个因素进行加权,计算得到一个排序权重,再按照排序权重从高到低的顺序,对消息队列中的各个RPC请求进行排序,这样使得排序方式更加精准,而且能够灵活控制请求时间戳和请求次数变量各自对排序权重的贡献度占比,具有更高的可控性。Optionally, in the reordering process, each RPC request is weighted according to the two factors of the request timestamp and the number of requests to calculate a sorting weight, and then the message queue is sorted in order of the sorting weight from high to low Sort each RPC request in , which makes the sorting method more accurate, and can flexibly control the contribution ratio of the request timestamp and request times variables to the sorting weight, which has higher controllability.
在步骤604中,业务服务器每间隔目标时长,分批处理重排序后的消息队列中处于当前批次的至少一个RPC请求。In
在一些实施例中,在基于请求次数变量对消息队列中各个RPC请求进行重排序以后,可以创建一个定时器,该定时器用于每间隔目标时长从消息队列中取出排在消息队列最前的一批次的至少一个RPC请求,并基于以上各个实施例中涉及的处理方式对这一批次的RPC请求进行串行或并行处理。其中,目标时长是由技术人员在后台预先配置的大于0的数值,每一批次最大能够处理的RPC请求容量也是由技术人员在后台预先配置的大于0的数值,这里不对目标时长以及批次容量的取值进行具体限定。In some embodiments, after reordering the individual RPC requests in the message queue based on the request times variable, a timer can be created, which is used to take out a batch of RPC requests at the top of the message queue from the message queue every interval target duration At least one RPC request of a batch, and perform serial or parallel processing on this batch of RPC requests based on the processing manners involved in the above embodiments. Among them, the target duration is a value greater than 0 pre-configured by the technician in the background, and the maximum RPC request capacity that can be processed in each batch is also a value greater than 0 pre-configured by the technician in the background. The target duration and batch are not correct here. The value of the capacity is specifically limited.
在一个示例中,以目标时长为1秒,批次容量为100为例进行说明,业务服务器侧配置一个1秒定时器,每隔1秒从消息队列中取出排序最前的top100个RPC请求进行处理,返回对应响应,重复以上操作直到消息队列中所有RPC请求都被取出。In an example, take the target duration of 1 second and the batch capacity of 100 as an example. A 1-second timer is configured on the business server side, and the top 100 RPC requests sorted are taken out from the message queue every 1 second for processing. , returns the corresponding response, and repeats the above operation until all RPC requests in the message queue are taken out.
在上述过程中,通过提供对同一时间段内涌入的大量RPC请求的分帧操作方式,能够避免由于大量玩家同时拉取邮件列表导致业务服务器的压力过大(甚至可能会过载宕机),进一步提升了业务服务器的可用性。In the above process, by providing a frame-based operation method for a large number of RPC requests pouring in at the same time period, it is possible to avoid excessive pressure on the business server due to a large number of players pulling the mailing list at the same time (it may even be overloaded and downtime), The usability of the business server is further improved.
(二)邮件详情拉取业务(2) Email details pull business
图7是本公开实施例提供的一种邮件详情拉取业务的处理流程图,如图7所示,以终端侧账号发起的游戏业务请求为邮件详情拉取请求为例,邮件详情拉取请求的处理方法由业务服务器执行,业务服务器可以是一台集成式处理各类非实时业务的服务器,或者是单独部署的邮件业务服务器,其中,业务服务器为计算机设备的示例性说明。Fig. 7 is a processing flowchart of an email details pull service provided by an embodiment of the present disclosure. The processing method is executed by a business server, and the business server may be an integrated server for processing various non-real-time businesses, or a separately deployed mail business server, wherein the business server is an exemplary description of computer equipment.
需要说明的是,这里仅对游戏服务器将邮件详情拉取请求对应的RPC请求发送到业务服务器,业务服务器创建协程以后的处理流程进行说明,即,本公开实施例的方案是在前述实施例中步骤305以后实现的,关于RPC请求如何从游戏服务器发送到业务服务器,以及业务服务器如何创建协程的方式,请参考前述实施例的描述,不再赘述。It should be noted that, here, only the game server sends the RPC request corresponding to the mail details pull request to the business server, and the processing flow after the business server creates a coroutine is described. For the implementation after step 305, please refer to the description of the foregoing embodiments for how the RPC request is sent from the game server to the service server, and how the service server creates a coroutine, and details are not repeated here.
在步骤306-C1中,业务服务器通过协程确定邮件详情拉取请求所请求拉取的邮件类型和邮件序列号。In step 306-C1, the business server determines the email type and email sequence number requested by the email details pull request through the coroutine.
在一些实施例中,终端侧在检测到用户对某一封指定的邮件的查看操作时,会发起对该邮件的邮件详情拉取请求,该邮件详情拉取请求中携带该邮件的邮件类型以及邮件序列号。即,上述邮件类型和邮件序列号会作为业务参数被封装到邮件详情拉取请求中,游戏服务器在解析到上述业务参数后,将上述业务参数注入到邮件服务API,由邮件服务API对业务服务器发起RPC请求,RPC请求中携带上述邮件服务API中被注入的业务参数,使得业务服务器在创建协程后,该协程能够通过邮件服务API提供的业务参数,获取到上述邮件类型和邮件序列号。其中,邮件类型和邮件序列号参见上一实施例的描述,不再赘述。In some embodiments, when the terminal side detects the user's view operation on a specified email, it will initiate an email details pull request for the email, and the email details pull request carries the email type of the email and Mail sequence number. That is, the above-mentioned email type and email serial number will be encapsulated into the email details pull request as business parameters. After parsing the above-mentioned business parameters, the game server will inject the above-mentioned business parameters into the mail service API. Initiate an RPC request, and the RPC request carries the business parameters injected in the above-mentioned mail service API, so that after the business server creates a coroutine, the coroutine can obtain the above-mentioned mail type and mail serial number through the business parameters provided by the mail service API . Wherein, for the mail type and mail serial number, refer to the description of the previous embodiment, which will not be repeated here.
在步骤306-C2中,业务服务器向数据库中该邮件类型所指示的邮件集合,发起对该邮件序列号所指示的邮件的读取操作,得到该邮件的邮件正文和邮件附件。In step 306-C2, the service server initiates a read operation of the mail indicated by the mail serial number to the mail set indicated by the mail type in the database, and obtains the mail text and mail attachments of the mail.
其中,该读取操作用于读取该邮件的邮件正文,并在该邮件携带附件的情况下还读取该附件。Wherein, the read operation is used to read the mail body of the mail, and also read the attachment if the mail carries an attachment.
在一些实施例中,在个人邮件和系统邮件分开编码的情况下,若邮件类型为个人邮件,则基于账号的账号ID,在邮件数据库中找到该账号的个人邮件集合,并在个人邮件集合中查询该邮件序列号所命中的邮件,接着读取该邮件的邮件正文,并在该邮件携带附件的情况下还读取该邮件的邮件附件;若邮件类型为系统邮件,则在邮件数据库的系统邮件集合中查询该邮件序列号所命中的邮件,接着读取该邮件的邮件正文,并在该邮件携带附件的情况下还读取该邮件的邮件附件。In some embodiments, in the case that personal emails and system emails are coded separately, if the email type is personal emails, then based on the account ID of the account, the personal email collection of the account is found in the email database, and the personal email collection is stored in the personal email collection. Query the mail hit by the mail serial number, then read the mail text of the mail, and read the mail attachment of the mail if the mail carries attachments; if the mail type is a system mail, then in the mail database system Query the mail that the mail serial number hits in the mail collection, then read the mail body of the mail, and also read the mail attachment of the mail when the mail carries an attachment.
在一些实施例中,在个人邮件和系统邮件统一编码的情况下,由于系统邮件在被终端拉取时会被存入到个人邮件集合中,而用户只能对已经拉取了信息摘要的邮件发起查看操作,说明邮件详情拉取请求所指示的邮件必定是终端已经本地加载了信息摘要但未加载邮件正文(及邮件附件)的,这类邮件不管是个人邮件还是系统邮件都会存入到个人邮件集合中,因此不论邮件类型是系统邮件还是个人邮件,都直接基于账号的账号ID,在邮件数据库中找到该账号的个人邮件集合,并在个人邮件集合中查询该邮件序列号所命中的邮件,接着读取该邮件的邮件正文,并在该邮件携带附件的情况下还读取该邮件的邮件附件。In some embodiments, in the case of unified coding of personal mail and system mail, since the system mail will be stored in the personal mail collection when it is pulled by the terminal, the user can only edit the mail for which the information summary has been pulled. Initiate a view operation, indicating that the email indicated by the email details pull request must be the terminal that has loaded the information summary locally but has not loaded the email body (and email attachments). This type of email will be stored in the personal Therefore, regardless of whether the mail type is system mail or personal mail, it is directly based on the account ID of the account, finds the personal mail collection of the account in the mail database, and queries the mail hit by the serial number of the mail in the personal mail collection. , which then reads the message body of the message and, if the message has attachments, also reads the message's message attachments.
在步骤306-C1至步骤306-C2中,提供了在非实时业务为邮件详情拉取业务的情况下,通过该协程发起该非实时业务的数据库操作的一种可能实施方式,即,对于经过上一实施例中仅提供了信息摘要但未提供邮件正文的任一封邮件,在接收到对该邮件的邮件详情拉取请求时,可通过步骤306-C1至步骤306-C2来从邮件数据库中读取到该邮件的邮件正文(及邮件附件),这样单封邮件读取操作的性能开销很小,对邮件详情拉取请求的响应速率高,而且不需要在拉取邮件列表的阶段来提供邮件正文,对用户侧的影响也几乎是无感知的。In step 306-C1 to step 306-C2, in the case that the non-real-time service is an email detail fetching service, a possible implementation manner of initiating the database operation of the non-real-time service through the coroutine is provided, that is, for After any email in the previous embodiment that only provides a summary of the information but does not provide the email body, when receiving the email details pull request for the email, you can go through steps 306-C1 to 306-C2 to extract the details from the email The email body (and email attachments) of the email is read in the database, so the performance overhead of a single email reading operation is very small, the response rate to the email detail pull request is high, and there is no need to pull the mailing list stage To provide the email body, the impact on the user side is almost imperceptible.
在步骤701中,业务服务器生成携带该邮件正文及该邮件附件的响应。In
在一些实施例中,业务服务器将上述步骤306-C2中获取的邮件正文和邮件附件封装到响应中,再将响应直接发送给发送邮件详情拉取请求的终端,可降低通信轮次,节约通信开销。In some embodiments, the service server encapsulates the email body and email attachments obtained in the above step 306-C2 into a response, and then directly sends the response to the terminal that sends the pull request for email details, which can reduce communication rounds and save communication overhead.
在一些实施例中,业务服务器将上述封装完毕的响应发送给游戏服务器,再由游戏服务器将上述响应发送给终端,这样能够保证终端对后台微服务架构无感知,使得游戏中非实时业务的拆分部署对用户侧透明、无感知。In some embodiments, the business server sends the packaged response to the game server, and then the game server sends the above response to the terminal, which can ensure that the terminal is not aware of the background micro-service architecture, so that the dismantling of non-real-time services in the game The sub-deployment is transparent and imperceptible to the user side.
在上述步骤701中,提供了业务服务器生成响应的一种可能实施方式,即,业务服务器侧生成响应,由业务服务器直接向终端返回响应,或由业务服务器将响应发送到游戏服务器再由游戏服务器转发到终端。In the
在另一些实施例中,业务服务器将上述步骤306-C2中获取的邮件正文和邮件附件以回调方式通知到游戏服务器侧的邮件服务API,使得游戏服务器能够通过邮件服务API,获取到业务服务器回传的邮件正文和邮件附件,接着游戏服务器将邮件正文和邮件附件封装到响应中,将响应发送给终端,这样业务服务器无需解析请求也无需封装响应,只需要根据业务参数执行对应数据库操作再返回操作完毕的业务数据(即邮件正文和邮件附件)即可,极大节约业务服务器的处理资源。In some other embodiments, the business server notifies the mail text and mail attachments obtained in the above step 306-C2 to the mail service API on the game server side in a callback manner, so that the game server can obtain the reply from the business server through the mail service API. Then the game server encapsulates the email body and email attachments into the response and sends the response to the terminal. In this way, the business server does not need to parse the request or encapsulate the response. It only needs to perform the corresponding database operation according to the business parameters and return The business data (that is, the email body and email attachments) after the operation is sufficient, which greatly saves the processing resources of the business server.
需要说明的是,本公开实施例仅以邮件携带附件的情况为例进行说明,若邮件没有携带附件,则在步骤306-C2中仅读取邮件正文无需读取邮件附件,并在步骤701中生成携带邮件正文的响应,即邮件附件是可缺省项,本公开实施例对是否携带邮件附件不进行具体限定。It should be noted that the embodiment of the present disclosure only takes the case of an email carrying an attachment as an example. If the email does not carry an attachment, then in step 306-C2 only the text of the email is read without reading the attachment of the email, and in
(三)邮件发送业务(3) Mail sending business
图8是本公开实施例提供的一种邮件发送业务的处理流程图,如图8所示,以终端侧账号发起的游戏业务请求为邮件发送请求为例,邮件发送请求的处理方法由业务服务器执行,业务服务器可以是一台集成式处理各类非实时业务的服务器,或者是单独部署的邮件业务服务器,其中,业务服务器为计算机设备的示例性说明。Fig. 8 is a processing flow chart of an email sending service provided by an embodiment of the present disclosure. As shown in Fig. 8, taking the game service request initiated by the account on the terminal side as an email sending request as an example, the processing method of the email sending request is determined by the service server For implementation, the service server may be an integrated server that processes various non-real-time services, or a separately deployed mail service server, wherein the service server is an exemplary description of computer equipment.
需要说明的是,这里仅对游戏服务器将邮件发送请求对应的RPC请求发送到业务服务器,业务服务器创建协程以后的处理流程进行说明,即,本公开实施例的方案是在前述实施例中步骤305以后实现的,关于RPC请求如何从游戏服务器发送到业务服务器,以及业务服务器如何创建协程的方式,请参考前述实施例的描述,不再赘述。It should be noted that here only the game server sends the RPC request corresponding to the email sending request to the business server, and the processing flow after the business server creates the coroutine is described, that is, the solution of the embodiment of the present disclosure is the step in the preceding embodiment For the implementation after 305, please refer to the description of the foregoing embodiments for how the RPC request is sent from the game server to the service server, and how the service server creates a coroutine, and will not be repeated here.
在步骤306-D1中,业务服务器通过协程确定邮件发送请求所指示的待发送邮件的邮件类型。In step 306-D1, the service server determines the mail type of the mail to be sent indicated by the mail sending request through the coroutine.
在一些实施例中,用户在终端侧可以编辑待发送邮件,终端在检测到对待发送邮件的发送操作时,发起对该待发送邮件的邮件发送请求,该邮件发送请求中至少携带该待发送邮件,可选地,终端还可以基于登录该终端的账号权限,来生成该待发送邮件的邮件类型,再将邮件类型也封装到邮件发送请求中,即,上述待发送邮件(或者还有邮件类型)会作为业务参数被封装到邮件发送请求中。游戏服务器在接收到邮件发送请求后,解析得到上述业务参数,如果业务参数中携带待发送邮件和邮件类型,则将上述业务参数注入到邮件服务API,由邮件服务API对业务服务器发起RPC请求,RPC请求中携带上述邮件服务API中被注入的业务参数,使得业务服务器在创建协程后,该协程能够通过邮件服务API提供的业务参数,获取到上述待发送邮件和邮件类型;如果业务参数中仅携带待发送邮件不携带邮件类型,游戏服务器可以检测发件人是否为游戏系统或游戏管理员,若是,将邮件类型置为系统邮件,并将待发送邮件和邮件类型一起注入到邮件服务API,若否,将邮件类型置为个人邮件,并将待发送邮件和邮件类型一起注入到邮件服务API,后续流程参考前一方式,不再赘述。In some embodiments, the user can edit the email to be sent on the terminal side. When the terminal detects the sending operation of the email to be sent, it initiates an email sending request for the email to be sent, and the email sending request carries at least the email to be sent , optionally, the terminal can also generate the email type of the email to be sent based on the account authority of the terminal, and then encapsulate the email type into the email sending request, that is, the above email to be sent (or there is also an email type ) will be encapsulated into the email sending request as a business parameter. After the game server receives the email sending request, it analyzes the above business parameters. If the business parameters carry the email to be sent and the email type, inject the above business parameters into the mail service API, and the mail service API initiates an RPC request to the business server. The RPC request carries the business parameters injected in the above-mentioned mail service API, so that after the business server creates a coroutine, the coroutine can obtain the above-mentioned mail to be sent and the mail type through the business parameters provided by the mail service API; if the business parameters Only carry the email to be sent but not the email type. The game server can detect whether the sender is the game system or the game administrator. If so, set the email type to system email, and inject the email to be sent and the email type into the email service API, if not, set the mail type as personal mail, and inject the mail to be sent and the mail type into the mail service API. The subsequent process refers to the previous method and will not be repeated.
需要说明的是,在不同游戏业务逻辑中,还可以规定邮件发送条件,比如终端在发送邮件发起请求以前,还需要检测邮件正文是否超出设定字符数,以避免邮件正文内容过长,检测邮件列表长度是否超过设定长度,以避免单个玩家的邮件数量过多,不再赘述。It should be noted that in different game business logics, email sending conditions can also be specified. For example, before the terminal sends an email to initiate a request, it needs to check whether the email body exceeds the set number of characters to avoid the content of the email body being too long. Whether the length of the list exceeds the set length to avoid too many emails for a single player, so I won’t repeat them here.
通过以上任一种方式,业务服务器都可以直接从邮件服务API中获取到待发送邮件和邮件类型,在邮件类型为个人邮件的情况下,执行下述步骤306-D2;在邮件类型为系统邮件的情况下,执行下述步骤306-D3。Through any of the above methods, the business server can directly obtain the mail to be sent and the mail type from the mail service API. If the mail type is personal mail, perform the following step 306-D2; if the mail type is system mail In the case of , execute the following step 306-D3.
在步骤306-D2中,业务服务器在该邮件类型为个人邮件的情况下,向数据库中该账号的个人邮件集合发起对该待发送邮件的写入操作。In step 306-D2, when the email type is personal email, the service server initiates a write operation of the email to be sent to the personal email collection of the account in the database.
在一些实施例中,在邮件类型为个人邮件的情况下,业务服务器基于账号的账号ID,在邮件数据库中找到该账号的个人邮件集合,创建向个人邮件集合中写入待发送邮件的事务,并通过该事务来发起对该待发送邮件的写入操作。In some embodiments, when the mail type is personal mail, the business server finds the personal mail collection of the account in the mail database based on the account ID of the account, and creates a transaction of writing the mail to be sent in the personal mail collection, And use this transaction to initiate a write operation on the email to be sent.
在步骤306-D3中,业务服务器在该邮件类型为系统邮件的情况下,向数据库的系统邮件集合发起对该待发送邮件的写入操作。In step 306-D3, when the email type is system email, the service server initiates a write operation of the email to be sent to the system email collection of the database.
在一些实施例中,在邮件类型为系统邮件的情况下,业务服务器在邮件数据库中查找到全局的系统邮件集合,创建向系统邮件集合中写入待发送邮件的事务,并通过该事务来发起对该待发送邮件的写入操作。In some embodiments, when the mail type is system mail, the service server finds the global system mail collection in the mail database, creates a transaction to write the mail to be sent in the system mail collection, and initiates The write operation for this pending message.
在步骤306-D1至步骤306-D3中,提供了在非实时业务为邮件发送业务的情况下,通过该协程发起该非实时业务的数据库操作的一种可能实施方式,即,对于游戏用户,能够通过上述步骤306-D1和步骤306-D2,实现对个人邮件的发送操作;对于游戏管理员,能够通过上述步骤306-D1和步骤306-D3,实现对系统邮件的发送操作,这样能够提供对个人邮件或系统邮件的通用接口,或者分别提供对个人邮件的发送接口以及对系统邮件的发送接口,实现邮件发送业务的高可用性。In step 306-D1 to step 306-D3, in the case that the non-real-time service is an email sending service, a possible implementation manner of initiating the database operation of the non-real-time service through the coroutine is provided, that is, for game users , through the above steps 306-D1 and 306-D2, the sending operation of personal mail can be realized; for the game administrator, the sending operation of system mail can be realized through the above step 306-D1 and step 306-D3, so that Provide a common interface for personal email or system email, or provide an interface for sending personal email and an interface for sending system email respectively, so as to achieve high availability of email sending services.
在步骤801中,业务服务器基于该写入操作的操作结果,为该待发送邮件分配邮件序列号。In
在一些实施例中,业务服务器执行完对待发送邮件的写入操作后,在写入操作的操作结果指示事务提交的情况下,代表待发送邮件已经成功写入到对应的邮件集合中并且已经数据落盘,可以对该待发送邮件分配唯一且保持递增的邮件序列号,邮件序列号的编码方式可以是个人邮件和系统邮件分开编码或者统一编码,不再赘述;在写入操作的操作结果指示事务回滚的情况下,直接生成并返回通知邮件发送失败的响应。In some embodiments, after the business server finishes writing the mail to be sent, if the operation result of the write operation indicates that the transaction is committed, it means that the mail to be sent has been successfully written into the corresponding mail collection and the data For sending, you can assign a unique and incremental mail serial number to the email to be sent. The encoding method of the mail serial number can be separate encoding for personal emails and system emails or unified encoding, so I won’t repeat them here; In the case of transaction rollback, directly generate and return a response to notify that the sending of the email failed.
在一些实施例中,在写入操作的操作结果指示事务提交的情况下,业务服务器在对邮件序列号分配完毕后,检测待发送邮件的收件人账号的登录状态,若收件人账号处于游戏离线状态,执行步骤802,若收件人账号处于游戏在线状态,执行步骤803;可选地,若待发送邮件包含多个收件人账号,则检测每个收件人账号的登录状态,对处于游戏离线状态的收件人账号执行步骤802,对处于游戏在线状态的收件人账号执行步骤803。In some embodiments, when the operation result of the write operation indicates that the transaction is committed, the service server detects the login status of the recipient account of the email to be sent after the serial number of the email is allocated. In the offline state of the game, execute
在步骤802中,业务服务器在该待发送邮件的收件人账号处于游戏离线状态的情况下,生成向发件人账号通知邮件发送成功的响应。In
在一些实施例中,若收件人账号处于游戏离线状态,业务服务器可以生成一个ACK消息作为对发件人账号通知邮件发送成功的响应,在收件人账号登录后首次拉取邮件列表时,就会收到这封待发送邮件。可选地,业务服务器在生成上述ACK消息后,由业务服务器直接向终端返回上述ACK消息,可节约通信开销,或者,业务服务器通过服务API,向游戏服务器回传上述ACK消息,以使游戏服务器将上述ACK消息发送给终端,这样能够降低终端的感知性,保证终端对业务服务器无感知,微服务框架对用户侧透明。In some embodiments, if the recipient's account is offline in the game, the service server can generate an ACK message as a response to the sender's account notification email being sent successfully. When the recipient's account is logged in to pull the mailing list for the first time, You will receive this pending email. Optionally, after the service server generates the above ACK message, the service server directly returns the above ACK message to the terminal, which can save communication overhead, or, the service server returns the above ACK message to the game server through the service API, so that the game server The above ACK message is sent to the terminal, which can reduce the perception of the terminal, ensure that the terminal has no perception of the service server, and the microservice framework is transparent to the user side.
在步骤803中,业务服务器在该待发送邮件的收件人账号处于游戏在线状态的情况下,生成向该账号通知邮件发送成功的响应;以及,生成向该收件人账号推送该待发送邮件的响应。In
在一些实施例中,若收件人账号处于游戏在线状态,那么除了通过步骤802同理的方式生成ACK消息作为对发件人账号通知邮件发送成功的响应以外,还需要向收件人账号发送新邮件提醒。In some embodiments, if the recipient account is in the game online state, then in addition to generating an ACK message as a response to the success of sending the sender account notification email in the same way as in
在一些实施例中,通过与前述实施例中步骤402同理的方式,提取待发送邮件的信息摘要,将信息摘要封装到向收件人账号推送该待发送邮件的响应(以下简称为新邮件推送响应)中,接着,通过直接或间接的方式向终端发送该新邮件推送响应,新邮件推送响应的发送方式与步骤802同理,不再赘述。In some embodiments, the information digest of the email to be sent is extracted in the same way as
在另一些实施例中,直接将整封待发送邮件的信息摘要和邮件正文一起封装到上述新邮件推送响应中,本公开实施例对新邮件推送响应中仅携带信息摘要,还是同时携带信息摘要和邮件正文不进行具体限定。In some other embodiments, the information abstract of the entire email to be sent is directly encapsulated together with the email body into the above-mentioned new email push response. In the embodiments of the present disclosure, only the information abstract is carried in the new email push response, or is the information abstract carried at the same time? and the body of the email are not specifically limited.
在上述步骤801至803中,提供了业务服务器生成响应的一种可能实施方式,即,业务服务器侧在收件人账号离线时,仅对发件人账号生成ACK消息指示邮件发送成功,在收件人账号在线时,除了对发件人账号生成ACK消息指示邮件发送成功以外,还对收件人账号生成新邮件推送响应,上述各类响应可由业务服务器直接向终端返回响应,或由业务服务器将响应发送到游戏服务器再由游戏服务器转发到终端。通过对收件人账号的登录状态进行检测,在检测到收件人账号处于游戏在线状态时,还对收件人账号返回新邮件推送响应,这样能够有效避免收件人账号错过新邮件,提醒收件人账号尽快查看新邮件,提升了邮件送达效率和时效性。In the
在上述(一)至(三)中分别介绍了邮件列表拉取业务、邮件详情拉取业务以及邮件发送业务等邮件服务系统所支持各类邮件业务,应理解,上述几类业务仅是对邮件业务的举例,邮件服务系统还支持标记已读、删除邮件、领取附件等其他业务,这些业务的处理流程同理,不再一一枚举。In the above (1) to (3), the various mail services supported by the mail service system, such as mail list pull business, mail detail pull business, and mail sending business, are respectively introduced. It should be understood that the above types of business are only for mail As an example of business, the mail service system also supports other services such as marking read, deleting emails, and receiving attachments. The processing procedures of these services are similar and will not be enumerated one by one.
下面以游戏管理员发起一封系统邮件这一场景为例进行说明,图9是本公开实施例提供的一种邮件发送业务的处理流程,如图9所示:游戏管理员在终端侧输入系统邮件的邮件发送请求;邮件发送请求经由游戏服务器解析后,生成对应的RPC请求到达业务服务器,业务服务器的主线程MailService向邮件数据库Mango申请下一封系统邮件的邮件序列号mailID;邮件数据库Mango向主线程MailService返回邮件序列号mailID;主线程MailService向待发送邮件填充邮件序列号mailID,并将填充了邮件序列号mailID的待发送邮件写入到系统邮件集合中;邮件数据库Mango执行待发送邮件的写入操作,在写入操作执行完毕后返回操作结果;在操作结果指示事务提交的情况下,业务服务器的主线程MailService向游戏服务器的一个或多个逻辑进程Logic广播通知有新的全服系统邮件;逻辑进程Logic会对每个在线玩家都在创建并维护一个对象Avatar,然后通知所有在线玩家各自的对象Avatar,实现对系统邮件的全服播报。The following uses the scenario where the game administrator initiates a system email as an example to illustrate. Figure 9 is a processing flow of an email sending service provided by an embodiment of the disclosure. Email sending request; after the email sending request is parsed by the game server, a corresponding RPC request is generated and reaches the business server, and the main thread MailService of the business server applies to the mail database Mango for the mail serial number mailID of the next system mail; the mail database Mango sends The main thread MailService returns the mail serial number mailID; the main thread MailService fills the mail serial number mailID to the mail to be sent, and writes the mail to be sent filled with the mail serial number mailID into the system mail collection; the mail database Mango executes the The write operation returns the operation result after the write operation is completed; when the operation result indicates that the transaction is committed, the main thread MailService of the business server broadcasts to one or more logic processes of the game server Logic to notify that there is a new full-service system Mail; logic process Logic creates and maintains an object Avatar for each online player, and then notifies all online players of their respective object Avatars to realize full server broadcast of system mail.
为了方便理解逻辑进程Logic和对象Avatar的关系,请参考上图5,在服务器侧可以创建一个或多个逻辑进程Logic,每个逻辑进程Logic上都会对一个或多个在线玩家的对象Avatar提供服务,每当一个在线玩家发起了邮件发送请求时,都会将邮件发送请求先送到所属逻辑进程Logic上的对象Avatar,再由对象Avatar来解析邮件发送请求,并远程调用远端业务服务器上的邮件服务系统500。In order to facilitate the understanding of the relationship between the logical process Logic and the object Avatar, please refer to Figure 5 above. One or more logical processes Logic can be created on the server side, and each logical process Logic will provide services to the object Avatar of one or more online players. , whenever an online player initiates a mail sending request, the mail sending request will be sent to the object Avatar on the logical process Logic, and then the object Avatar will parse the mail sending request and remotely call the mail on the remote business
在上述各个实施例中,详细介绍了服务器后端的邮件服务系统在各类业务上的处理流程,由于邮件服务系统本身就数量级较大,而且对实时性要求不高(通常带有游戏内留言的性质,并不需要实时推送或查看),且邮件服务系统的处理逻辑又相较于游戏主业务逻辑是比较独立的,通过微服务架构实现邮件服务系统的拆分,并将邮件服务系统部署在远端的业务服务器,以使业务服务器来支持邮件功能,能够极大地减轻游戏服务器的用户负载。In each of the above-mentioned embodiments, the processing flow of the mail service system at the back end of the server in various businesses is described in detail. Since the mail service system itself is of a large order of magnitude, and does not have high requirements for real-time performance (usually with messages in the game) nature, does not require real-time push or view), and the processing logic of the mail service system is relatively independent compared with the main business logic of the game. The split of the mail service system is realized through the micro-service architecture, and the mail service system is deployed in The remote business server allows the business server to support the mail function, which can greatly reduce the user load of the game server.
在游戏场景中,除了邮件服务系统以外,还涉及到一类消息服务系统,涉及到提供游戏内IM消息的拉取、发送以及添加好友等消息业务,以下对消息服务系统针对各类消息业务的处理流程分类讨论。In the game scene, in addition to the mail service system, a type of message service system is also involved, which involves providing in-game IM message pull, send and add friends and other message services. The following describes the message service system for various message services. Discussion of processing flow categories.
(四)未读消息拉取业务(4) Unread message pulling business
图10是本公开实施例提供的一种未读消息拉取业务的处理流程图,如图10所示,以终端侧账号发起的游戏业务请求为未读消息拉取请求为例,未读消息拉取请求的处理方法由业务服务器执行,业务服务器可以是一台集成式处理各类非实时业务的服务器,或者是单独部署的消息业务服务器,其中,业务服务器为计算机设备的示例性说明。Fig. 10 is a processing flowchart of an unread message pulling service provided by an embodiment of the present disclosure. As shown in Fig. 10 , taking the game service request initiated by the account on the terminal side as an unread message pulling request as an example, the unread message The processing method of the pull request is executed by a business server, which may be an integrated server for processing various non-real-time businesses, or a message business server deployed separately, wherein the business server is an example of computer equipment.
需要说明的是,这里仅对游戏服务器将未读消息拉取请求对应的RPC请求发送到业务服务器,业务服务器创建协程以后的处理流程进行说明,即,本公开实施例的方案是在前述实施例中步骤305以后实现的,关于RPC请求如何从游戏服务器发送到业务服务器,以及业务服务器如何创建协程的方式,请参考前述实施例的描述,不再赘述。It should be noted that, here only the game server sends the RPC request corresponding to the unread message pull request to the business server, and the processing flow after the business server creates the coroutine is described, that is, the solution of the embodiment of the present disclosure is based on the aforementioned implementation For the realization after step 305 in the example, how to send the RPC request from the game server to the business server, and how the business server creates a coroutine, please refer to the description of the previous embodiment, and will not go into details.
在步骤306-E1中,业务服务器通过协程获取未读消息拉取请求中携带的待查询账号以及该账号和该待查询账号的会话的已读消息中的最大消息标识即最大消息ID。In step 306-E1, the service server acquires the account to be queried carried in the pull request of unread messages and the maximum message identifier in the read messages of the session between the account and the account to be queried, ie the maximum message ID, through the coroutine.
其中,该最大消息ID指示当前账号与待查询账号的会话中的最新已读消息。Wherein, the maximum message ID indicates the latest read message in the session between the current account and the account to be queried.
在一些实施例中,终端侧在发起未读消息拉取请求时,会确定当前账号与待查询账号的会话中的各条已读消息中的最大消息ID,比如,将上述最大消息ID作为业务参数封装到未读消息拉取请求中,游戏服务器在解析到上述业务参数后,将上述业务参数注入到消息服务API,由消息服务API对业务服务器发起RPC请求,RPC请求中携带上述消息服务API中被注入的业务参数,使得业务服务器在创建协程后,该协程能够通过消息服务API提供的业务参数,获取到上述最大消息ID。换言之,业务服务器通过该协程,能够从该未读消息拉取请求中,获取到待查询账号以及最大消息ID。In some embodiments, when the terminal side initiates an unread message pull request, it will determine the maximum message ID of each read message in the session between the current account and the account to be queried, for example, the above-mentioned maximum message ID is used as a service The parameters are encapsulated into the unread message pull request. After the game server parses the above business parameters, it injects the above business parameters into the message service API, and the message service API initiates an RPC request to the business server. The RPC request carries the above message service API The business parameters injected in , so that after the business server creates a coroutine, the coroutine can obtain the above-mentioned maximum message ID through the business parameters provided by the message service API. In other words, the service server can obtain the account number to be queried and the maximum message ID from the unread message pull request through the coroutine.
在步骤306-E2中,业务服务器基于该最大消息ID,向数据库中该账号和该待查询账号的消息集合发起对未读消息的批量读取操作,得到消息ID大于该最大消息ID的多条消息。In step 306-E2, based on the maximum message ID, the business server initiates a batch read operation of unread messages to the message set of the account and the account to be queried in the database, and obtains multiple unread messages whose message ID is greater than the maximum message ID. information.
其中,所述批量读取操作用于读取消息ID大于所述最大消息ID的多条消息。Wherein, the batch read operation is used to read multiple messages whose message IDs are greater than the maximum message ID.
在一些实施例中,本公开实施例涉及的数据库是指消息数据库,消息数据库用于存储所有会话中的已发消息(如,聊天记录),例如,消息数据库可以是Redis存储集群,Redis存储集群是一种Key-Value型数据库,对于高并发业务具有良好的支持,并自带有列表存储格式,与消息业务这种需要查看历史消息的业务需求较为适配。In some embodiments, the database involved in the embodiments of the present disclosure refers to a message database, and the message database is used to store sent messages (such as chat records) in all sessions. For example, the message database can be a Redis storage cluster, and the Redis storage cluster It is a Key-Value database that supports high-concurrency services and has a list storage format, which is more suitable for message services that need to view historical messages.
示意性地,对于Redis消息数据库来说,将每个账号与其他账号的会话中的各条消息记录以一张消息列表的形式存入Redis消息数据库,在消息列表中的每条消息记录被实施为一个字典,字典中可配置有不同的字段,如字典中配置有如下字段:消息发送人、消息内容、发送时间等。Schematically, for the Redis message database, each message record in the conversation between each account and other accounts is stored in the Redis message database in the form of a message list, and each message record in the message list is implemented It is a dictionary. Different fields can be configured in the dictionary. For example, the following fields are configured in the dictionary: message sender, message content, sending time, etc.
由于消息类型可分为私人会话(指两个账号之间的私聊会话)和群组会话(指三个或三个以上账号之间的群聊会话),在Redis消息数据库中,可以对私人会话和群组会话的消息记录以不同频道来存储,在私人会话频道中,将每一对账号之间的私人会话存储成一张私人消息列表,私人消息列表以Key-Value数据结构实现,如基于每一对账号的账号ID来构建Key-Value数据结构的Key(键名),在群组会话频道中,将每一个群组的群组会话存储成一张群组消息列表,群组消息列表以Key-Value数据结构实现,如基于群组ID来构建Key-Value数据结构的Key,这样即使群组内的成员发生变动,也无需对Key进行变更,降低了数据库性能开销。Since message types can be divided into private sessions (referring to private chat sessions between two accounts) and group sessions (referring to group chat sessions between three or more accounts), in the Redis message database, private The message records of conversations and group conversations are stored in different channels. In the private conversation channel, the private conversation between each pair of accounts is stored as a private message list. The private message list is implemented with the Key-Value data structure, such as based on The account ID of each pair of accounts is used to construct the Key (key name) of the Key-Value data structure. In the group conversation channel, the group conversation of each group is stored as a group message list, and the group message list starts with Key-Value data structure implementation, such as building the Key of the Key-Value data structure based on the group ID, so that even if the members in the group change, there is no need to change the Key, which reduces the database performance overhead.
示意性地,对于玩家A和玩家B的私人会话,在Redis消息数据库中,基于玩家A的账号ID-1和玩家B的账号ID-2来构建Key-Value数据结构的Key,比如,先判断出来两个玩家的账号ID在ID字典中的次序,并按照账号ID在ID字典中从前到后的次序来组建得到如下Key:private_chat_between_1_2,这样组建出来的Key,可供玩家A或者玩家B查询会话消息时进行复用,无需对两个玩家备份各自的会话消息,可降低数据库存储开销。Schematically, for a private session between player A and player B, in the Redis message database, the Key-Value data structure Key is constructed based on player A's account ID-1 and player B's account ID-2, for example, first determine Find out the order of the account IDs of the two players in the ID dictionary, and build the following key according to the order of the account IDs in the ID dictionary from front to back: private_chat_between_1_2, the Key formed in this way can be used by player A or player B to query the session Messages are multiplexed, and there is no need to back up the respective session messages of the two players, which can reduce the database storage overhead.
在一些实施例中,在Redis消息数据库中不论是私人消息列表还是群组消息列表,每收录一条新的消息时,业务服务器会为该消息分配一个自增的消息ID,由于消息ID保持递增,这样终端侧只需要记录已读消息的最大消息ID,在消息列表中消息ID大于记录的最大消息ID的全部消息均为终端侧的未读消息,极大简化了未读消息的拉取逻辑。In some embodiments, whether it is a private message list or a group message list in the Redis message database, whenever a new message is included, the service server will assign a self-incrementing message ID to the message. Since the message ID keeps increasing, In this way, the terminal side only needs to record the maximum message ID of the read message, and all messages with a message ID greater than the maximum recorded message ID in the message list are unread messages on the terminal side, which greatly simplifies the logic of pulling unread messages.
在一些实施例中,业务服务器在上述步骤306-E1中获取到待查询账号时,如果待查询账号是个人账号,代表本次请求拉取的是私人会话中的未读消息,如果待查询账号是群组ID,代表本次请求拉取的是群组会话中的未读消息。In some embodiments, when the service server acquires the account to be queried in the above step 306-E1, if the account to be queried is a personal account, it means that the request to pull is the unread message in the private session, if the account to be queried Is the group ID, which means that this request fetches unread messages in the group conversation.
在一些实施例中,对于私人会话中未读消息的拉取请求,可以基于当前账号和待查询账号,确定两账号之间私人会话的Key,并在Redis消息数据库中以确定得到的Key作为索引,查询到对应的Value即私人会话的私人消息列表,该私人消息列表中的消息均按照消息ID从小到大的顺序依次排列,然后,从上述步骤306-E1中获取到的最大消息ID所指示的最新已读消息的下一条消息开始依次向后读取,直到没有新的可读取的消息,即可得到消息ID大于该最大消息ID的全部未读消息。In some embodiments, for the pull request of the unread message in the private session, the Key of the private session between the two accounts can be determined based on the current account and the account to be queried, and the determined Key can be used as an index in the Redis message database , query the corresponding Value, that is, the private message list of the private session, the messages in the private message list are arranged in order of message ID from small to large, and then, as indicated by the largest message ID obtained in the above step 306-E1 The next message of the latest read message starts to be read backwards in sequence until there is no new readable message, and all unread messages whose message ID is greater than the maximum message ID can be obtained.
在一些实施例中,对于群组会话中未读消息的拉取请求,可以基于群组ID,确定群组ID所指示群组会话的Key,并在Redis消息数据库中以确定得到的Key作为索引,查询到对应的Value即群组会话的群组消息列表,该群组消息列表中的消息均按照消息ID从小到大的顺序依次排列,然后,从上述步骤306-E1中获取到的最大消息ID所指示的最新已读消息的下一条消息开始依次向后读取,直到没有新的可读取的消息,即可得到消息ID大于该最大消息ID的全部未读消息。In some embodiments, for a pull request of an unread message in a group session, the Key of the group session indicated by the group ID can be determined based on the group ID, and the determined Key can be used as an index in the Redis message database , the corresponding Value is queried, that is, the group message list of the group conversation. The messages in the group message list are arranged in order of message ID from small to large, and then, the largest message obtained from the above step 306-E1 The next message of the latest read message indicated by the ID starts to be read backwards in turn until there is no new readable message, and all unread messages whose message ID is greater than the maximum message ID can be obtained.
在上述步骤306-E1至步骤306-E2中,提供了业务服务器通过协程发起非实时业务的数据库操作的一种可能实施方式,即,不论是对于私人会话还是群组会话中未读消息的拉取请求,仅需要变更拉取请求中记录的待查询账号,并将会话中的最大消息ID封装到拉取请求,而不需要做其他复杂处理,在这种消息处理架构下,未读消息拉取请求本身携带的数据量很小,极大节约了通信带宽和通信开销。In the above step 306-E1 to step 306-E2, a possible implementation mode for the business server to initiate the database operation of the non-real-time business through the coroutine is provided, that is, whether it is for the unread message in the private session or the group session For a pull request, you only need to change the account to be queried recorded in the pull request, and encapsulate the largest message ID in the session into the pull request without other complicated processing. Under this message processing architecture, unread messages The amount of data carried by the pull request itself is very small, which greatly saves communication bandwidth and communication overhead.
通过以上步骤306-E1至步骤306-E2,能够发起对Redis消息数据库的批量读取操作,这时仍然可执行前述实施例中的步骤307,即在未获取到数据库操作的操作结果时阻塞协程,然后,在获取到数据库操作的操作结果时,若操作结果指示事务提交(而非事务回滚),则执行以下步骤1001-1002:Through the above steps 306-E1 to 306-E2, batch read operations to the Redis message database can be initiated. At this time,
在步骤1001中,业务服务器基于该批量读取操作的操作结果所返回的多条消息,确定未读消息数量。In
在一些实施例中,业务服务器执行完对未读消息的批量读取操作以后,在批量读取操作的操作结果指示事务提交的情况下,能够获取到批量读取到的多条消息(即全部未读消息),统计上述批量读取到的多条消息的数量,得到未读消息数量。In some embodiments, after the business server executes the batch read operation on unread messages, in the case that the operation result of the batch read operation indicates that the transaction is committed, it can obtain the batch read multiple messages (that is, all Unread messages), count the number of multiple messages read in batches above, and obtain the number of unread messages.
在步骤1002中,业务服务器生成携带该多条未读消息和该未读消息数量的响应。In
在一些实施例中,业务服务器将上述步骤1001中获取的未读消息数量以及上述步骤306-E2中批量读取到的全部未读消息均封装到响应中,再将响应直接发送给发起未读消息拉取请求的终端,可降低通信轮次,节约通信开销。In some embodiments, the service server encapsulates the number of unread messages obtained in the
在一些实施例中,业务服务器将上述封装完毕的响应发送给游戏服务器,再由游戏服务器将上述响应发送给终端,这样能够保证终端对后台微服务架构无感知,使得游戏中非实时业务的拆分部署对用户侧透明、无感知。In some embodiments, the business server sends the packaged response to the game server, and then the game server sends the above response to the terminal, which can ensure that the terminal is not aware of the background micro-service architecture, so that the dismantling of non-real-time services in the game The sub-deployment is transparent and imperceptible to the user side.
图11是本公开实施例提供的一种未读消息拉取业务的交互流程图,如图11所示,玩家在终端侧的游戏应用中触发未读消息拉取请求;游戏服务器侧的逻辑进程Logic上维护有该玩家的对象Avatar,通过上述对象Avatar接收终端侧的未读消息拉取请求,并向业务服务器的主线程ChatService发送未读消息拉取请求关联的RPC请求;接着,主线程ChatService向Redis消息数据库发起未读消息的批量读取操作;接着,Redis消息数据库批量读取到消息ID大于RPC请求中携带的已读消息的最大消息ID的全部未读消息,并统计读取到的全部未读消息的未读消息数量,将全部未读消息和未读消息数量作为业务数据返回主线程ChatService;主线程ChatService可以在将业务数据进行json.loads操作,即将Redis消息数据库返回的全部未读消息构成的JSON字符串,通过调用json.loads()方法转化成Python字典,向逻辑进程Logic上的对象Avatar返回Python字典形式的未读消息以及上述未读消息数量;对象Avatar向终端返回Python字典形式的未读消息以及上述未读消息数量。Fig. 11 is an interactive flowchart of an unread message pulling service provided by an embodiment of the present disclosure. As shown in Fig. 11 , the player triggers an unread message pulling request in the game application on the terminal side; the logic process on the game server side Logic maintains the player's object Avatar, receives the unread message pull request on the terminal side through the above object Avatar, and sends the RPC request associated with the unread message pull request to the main thread ChatService of the business server; then, the main thread ChatService Initiate a batch read operation of unread messages to the Redis message database; then, the Redis message database reads in batches all unread messages whose message IDs are greater than the maximum message ID of the read messages carried in the RPC request, and counts the read messages The number of unread messages of all unread messages, return all unread messages and the number of unread messages as business data to the main thread ChatService; the main thread ChatService can perform json.loads operations on business data, that is, all unread messages returned by the Redis message database The JSON string composed of read messages is converted into a Python dictionary by calling the json.loads() method, and the unread messages in the form of a Python dictionary and the number of the above unread messages are returned to the object Avatar on the logical process Logic; the object Avatar returns Python to the terminal A dictionary of unread messages and the number of unread messages mentioned above.
在上述步骤1001-1002中,提供了业务服务器生成响应的一种可能实施方式,即,业务服务器侧生成响应,由业务服务器直接向终端返回响应,或由业务服务器将响应发送到游戏服务器再由游戏服务器转发到终端,由于响应中除了携带全部未读消息以外,还携带了未读消息数量,这一未读消息数量可由终端侧渲染成消息查看界面中的“红点数据”,红点数据是指:以红点代表存在未读消息,并显示未读消息数量的一类UI显示方式,能够方便的提示是否存在未读消息、存在几条未读消息,极大提升了终端侧消息查看界面的信息量和信息密度,有利于提升用户的信息获取效率。In the above steps 1001-1002, a possible implementation manner of generating the response by the business server is provided, that is, the business server side generates the response, and the business server directly returns the response to the terminal, or the business server sends the response to the game server and then the The game server forwards it to the terminal. Since the response carries not only all unread messages but also the number of unread messages, the number of unread messages can be rendered by the terminal side as "red dot data" in the message viewing interface. The red dot data Refers to: a type of UI display method in which the red dot represents the existence of unread messages and displays the number of unread messages. It can conveniently prompt whether there are unread messages and how many unread messages exist, which greatly improves the viewing of messages on the terminal side. The information volume and information density of the interface are conducive to improving the efficiency of users' information acquisition.
在另一些实施例中,业务服务器将上述步骤1001中获取的未读消息数量以及上述步骤306-E2中批量读取到的全部未读消息以回调方式通知到游戏服务器侧的消息服务API,使得游戏服务器能够通过消息服务API,获取到业务服务器回传的未读消息数量和全部未读消息,接着游戏服务器将未读消息数量和全部未读消息封装到响应中,将响应发送给终端,这样业务服务器无需解析请求也无需封装响应,只需要根据业务参数执行对应数据库操作再返回操作完毕的业务数据(即全部未读消息和未读消息数量)即可,极大节约业务服务器的处理资源。In other embodiments, the business server notifies the message service API on the game server side of the number of unread messages obtained in the
在上述实施例中,提供了针对任一私人会话或群组会话,既拉取全部未读消息又拉取未读消息数量(即红点数据)的一种可能实施方式,可选地,终端侧还可以单独发起红点数据拉取请求,即仅拉取各个会话的红点数据,以便于在终端侧消息查看界面中正常显示所有会话的红点数据,但暂不加载每个会话的全部未读消息,只有在检测到用户对某个会话的打开操作时,才会触发对指定会话的未读消息拉取请求,这样能够节约终端与服务器集群间的通信开销,即在显示消息查看界面时无需拉取所有会话的全部未读消息(这很可能数据量极大,占用很多带宽),而是仅在打开某个会话时才拉取当前会话的未读消息,还能够节约终端侧的存储开销。In the above embodiment, a possible implementation manner of pulling all unread messages and the number of unread messages (that is, red dot data) for any private session or group session is provided. Optionally, the terminal The terminal side can also initiate a separate red dot data pull request, that is, only pull the red dot data of each session, so that the red dot data of all sessions can be displayed normally on the message viewing interface on the terminal side, but all session data will not be loaded for now. Unread messages, only when the user's opening operation on a session is detected, the unread message pull request for the specified session will be triggered, which can save the communication overhead between the terminal and the server cluster, that is, when the message viewing interface is displayed It is not necessary to pull all unread messages of all sessions (this is likely to have a huge amount of data and occupy a lot of bandwidth), but only pulls the unread messages of the current session when a certain session is opened, which can also save terminal side storage overhead.
以下,以终端侧单独通过红点数据拉取请求来拉取红点数据为例进行说明。In the following, the terminal side pulls the red dot data through the red dot data pull request alone as an example for illustration.
图12是本公开实施例提供的一种红点数据拉取业务的交互流程图,如图12所示,玩家在终端侧的游戏应用中触发红点数据拉取请求;游戏服务器侧的逻辑进程Logic上维护有该玩家的对象Avatar,通过上述对象Avatar接收终端侧的红点数据拉取请求,并向业务服务器的主线程ChatService发送红点数据拉取请求关联的RPC请求;接着,主线程ChatService向Redis消息数据库发起对红点数据的查询操作;接着,Redis消息数据库统计消息ID大于RPC请求中携带的已读消息的最大消息ID的未读消息数量,将未读消息数量作为红点数据返回主线程ChatService;主线程ChatService向逻辑进程Logic上的对象Avatar返回红点数据;对象Avatar向终端返回红点数据。Fig. 12 is an interactive flowchart of a red dot data pulling service provided by an embodiment of the present disclosure. As shown in Fig. 12, a player triggers a red dot data pull request in a game application on the terminal side; the logic process on the game server side Logic maintains the player's object Avatar, receives the red dot data pull request on the terminal side through the above object Avatar, and sends the RPC request associated with the red dot data pull request to the main thread ChatService of the business server; then, the main thread ChatService Initiate a query operation on the red dot data to the Redis message database; then, the Redis message database counts the number of unread messages whose message ID is greater than the maximum message ID of the read message carried in the RPC request, and returns the number of unread messages as red dot data The main thread ChatService; the main thread ChatService returns the red dot data to the object Avatar on the logic process Logic; the object Avatar returns the red dot data to the terminal.
通过以上方式,对于私人会话中的双方账号,只需要提供不同的最大消息ID,就能够在复用相同的私人消息列表Key-Value数据结构的基础上,拉取到各自正确的红点数据以及未读消息,即,私人会话双方可复用同一份聊天记录来查找各自指定的聊天消息,这样极大节约了业务服务器侧的存储开销。Through the above method, for the accounts of both parties in the private session, only need to provide different maximum message IDs, on the basis of reusing the same private message list Key-Value data structure, the correct red dot data and Unread messages, that is, both parties in a private conversation can reuse the same chat record to find their designated chat messages, which greatly saves the storage overhead on the business server side.
在一些实施例中,业务服务器侧在获取到每个玩家提供的最大消息ID以后,将最新接收到的最大消息ID缓存在Redis消息数据库中,并且最大消息ID会被后续更新的最大消息ID所覆盖,这样方便业务服务器侧执行其他基于已读消息的最大消息ID的业务决策,比如,业务决策包括:在接收到新消息时,通过比较新消息的消息ID与消息接收方缓存的最大消息ID的大小,以判断是否要显示或者更新未读消息和红点数据。In some embodiments, after obtaining the maximum message ID provided by each player, the business server caches the latest received maximum message ID in the Redis message database, and the maximum message ID will be replaced by the maximum message ID of the subsequent update. Coverage, so that the business server side can execute other business decisions based on the maximum message ID of the read message. For example, the business decision includes: when a new message is received, by comparing the message ID of the new message with the maximum message ID cached by the message receiver to determine whether to display or update unread messages and red dot data.
在一些实施例中,对于玩家A来说,在缓存玩家A与玩家B之间私人会话的最大消息ID时,假设玩家A在上述私人会话中已读消息的最大消息ID为3,则可以创建如下哈希结构:基于玩家A的账号ID,生成哈希结构的Key即private_chat_readflag_A,并将哈希结构的Field配置为玩家B的账号ID,再将哈希结构的Value配置为3,这样当业务服务器侧后续接收到更新的最大消息ID时,只需要修改哈希结构的Value即可。通过以上Key-Field-Value三级哈希结构,使得每个玩家与好友列表中所有其他玩家在私人会话中的最大消息ID都能够用一个哈希结构来简洁存储,一方面节约了存储开销,另一方面这种类似于二级索引的哈希结构也极大提升了索引效率。In some embodiments, for player A, when caching the maximum message ID of the private session between player A and player B, assuming that the maximum message ID of the message that player A has read in the above private session is 3, you can create The hash structure is as follows: Based on the account ID of player A, generate the key of the hash structure, namely private_chat_readflag_A, configure the Field of the hash structure as the account ID of player B, and configure the Value of the hash structure to 3, so that the business When the server side subsequently receives the updated maximum message ID, it only needs to modify the Value of the hash structure. Through the above Key-Field-Value three-level hash structure, the largest message ID of each player and all other players in the friend list in the private session can be stored concisely with a hash structure, which saves storage overhead on the one hand, On the other hand, this hash structure similar to the secondary index also greatly improves the indexing efficiency.
(五)消息发送业务(5) Message sending service
图13是本公开实施例提供的一种消息发送业务的处理流程图,如图13所示,以终端侧账号发起的游戏业务请求为消息发送请求为例,消息发送请求的处理方法由业务服务器执行,业务服务器可以是一台集成式处理各类非实时业务的服务器,或者是单独部署的消息业务服务器,其中,业务服务器为计算机设备的示例性说明。Fig. 13 is a processing flow chart of a message sending service provided by an embodiment of the present disclosure. As shown in Fig. 13, taking the game service request initiated by the terminal side account as a message sending request as an example, the processing method of the message sending request is determined by the service server For execution, the service server can be an integrated server that processes various non-real-time services, or a message service server that is deployed separately, wherein the service server is an example of computer equipment.
需要说明的是,这里仅对游戏服务器将消息发送请求对应的RPC请求发送到业务服务器,业务服务器创建协程以后的处理流程进行说明,即,本公开实施例的方案是在前述实施例中步骤305以后实现的,关于RPC请求如何从游戏服务器发送到业务服务器,以及业务服务器如何创建协程的方式,请参考前述实施例的描述,不再赘述。It should be noted that here only the game server sends the RPC request corresponding to the message sending request to the business server, and the processing flow after the business server creates the coroutine is described, that is, the solution of the embodiment of the present disclosure is the step in the preceding embodiment For the implementation after 305, please refer to the description of the foregoing embodiments for how the RPC request is sent from the game server to the service server, and how the service server creates a coroutine, and will not be repeated here.
在步骤306-F1中,业务服务器通过协程确定消息发送请求所指示的待发送消息的消息类型。In step 306-F1, the service server determines the message type of the message to be sent indicated by the message sending request through the coroutine.
在一些实施例中,用户在终端侧可以编辑待发送消息,终端在检测到对待发送消息的发送操作时,发起对该待发送消息的消息发送请求,该消息发送请求中至少携带该待发送消息,可选地,终端还可以该待发送消息所指定的消息接收账号,来确定该待发送消息的消息类型,再将消息类型也封装到消息发送请求中,即,上述待发送消息(或者还有消息类型)会作为业务参数被封装到消息发送请求中。游戏服务器在接收到消息发送请求后,解析得到上述业务参数,如果业务参数中携带待发送消息和消息类型,则将上述业务参数注入到消息服务API,由消息服务API对业务服务器发起RPC请求,RPC请求中携带上述消息服务API中被注入的业务参数,使得业务服务器在创建协程后,该协程能够通过消息服务API提供的业务参数,获取到上述待发送消息和消息类型;如果业务参数中仅携带待发送消息不携带消息类型,游戏服务器可以检测消息接收账号是否为某个账号群组,若是,将消息类型置为群组消息,并将待发送消息和消息类型一起注入到消息服务API,若否,将消息类型置为个人消息,并将待发送消息和消息类型一起注入到消息服务API,后续流程参考前一方式,不再赘述。In some embodiments, the user can edit the message to be sent on the terminal side. When the terminal detects the sending operation of the message to be sent, it initiates a message sending request for the message to be sent, and the message sending request carries at least the message to be sent , optionally, the terminal can also determine the message type of the message to be sent by the message receiving account specified by the message to be sent, and then encapsulate the message type into the message sending request, that is, the above message to be sent (or also There is a message type) will be encapsulated into the message sending request as a business parameter. After receiving the message sending request, the game server parses to obtain the above business parameters. If the business parameters carry the message to be sent and the message type, the above business parameters are injected into the message service API, and the message service API initiates an RPC request to the business server. The RPC request carries the business parameters injected in the above-mentioned message service API, so that after the business server creates a coroutine, the coroutine can obtain the above-mentioned message to be sent and the message type through the business parameters provided by the message service API; if the business parameter Only carry the message to be sent but not the message type. The game server can detect whether the account receiving the message belongs to an account group. If so, set the message type to group message, and inject the message to be sent and the message type into the message service API, if not, set the message type as personal message, and inject the message to be sent together with the message type into the message service API. The subsequent process refers to the previous method and will not be repeated.
需要说明的是,在不同游戏业务逻辑中,还可以规定消息发送条件,比如终端在发送消息发起请求以前,还需要检测消息正文是否超出设定字符数,以避免消息正文内容过长,检测消息中是否包含敏感词,以实现消息合法性校验,不再赘述。It should be noted that in different game business logics, message sending conditions can also be specified. For example, before the terminal sends a message to initiate a request, it needs to detect whether the message body exceeds the set number of characters to avoid the content of the message body being too long. Whether it contains sensitive words or not is used to verify the legitimacy of the message, so I won’t repeat it here.
通过以上任一种方式,业务服务器都可以直接从消息服务API中获取到待发送消息和消息类型,在消息类型为个人消息的情况下,执行下述步骤306-F2;在消息类型为群组消息的情况下,执行下述步骤306-F3。Through any of the above methods, the service server can directly obtain the message to be sent and the message type from the message service API. In the case of a message, the following step 306-F3 is performed.
在步骤306-F2中,业务服务器在该消息类型为个人消息的情况下,向数据库中该账号和消息接收账号的消息集合发起对该待发送消息的写入操作。In step 306-F2, when the message type is a personal message, the service server initiates a write operation of the message to be sent to the message set of the account and message receiving account in the database.
在一些实施例中,在消息类型为个人消息的情况下,业务服务器基于该账号的账号ID和消息接收账号的账号ID,确定在Redis消息数据库中该账号与该消息接收账号之间私人会话的Key,以上述Key作为索引在Redis消息数据库中查询到上述私人会话的私人消息列表,这一私人消息列表即为在Redis数据库中的消息集合的一种示例性说明。接着,创建向私人消息列表插入一条新的待发送消息的事务,并通过该事务来发起对该待发送消息的写入操作,比如,将待发送消息插入到Key-Value私人消息列表的Value(键值)中。In some embodiments, when the message type is a personal message, the service server determines the private session between the account and the message receiving account in the Redis message database based on the account ID of the account and the account ID of the message receiving account. Key, using the above-mentioned Key as an index to query the private message list of the above-mentioned private session in the Redis message database, this private message list is an exemplary description of the message collection in the Redis database. Next, create a transaction that inserts a new message to be sent into the private message list, and initiate a write operation of the message to be sent through this transaction, for example, insert the message to be sent into the Value( key value).
在步骤306-F3中,业务服务器在该消息类型为群组消息的情况下,向数据库中消息接收群组的消息集合发起对该待发送消息的写入操作。In step 306-F3, when the message type is a group message, the service server initiates a write operation of the message to be sent to the message set of the message receiving group in the database.
在一些实施例中,在消息类型为群组消息的情况下,消息接收账号实际上被提供为一个消息接收群组,业务服务器基于消息接收群组的群组ID,确定在Redis消息数据库中该消息接收群组的群组会话的Key,以上述Key作为索引在Redis消息数据库中查询到上述群组会话的群组消息列表,这一群组消息列表即为在Redis数据库中的消息集合的一种示例性说明。接着,创建向群组消息列表插入一条新的待发送消息的事务,并通过该事务来发起对该待发送消息的写入操作,比如,将待发送消息插入到Key-Value群组消息列表的Value中。In some embodiments, when the message type is a group message, the message receiving account is actually provided as a message receiving group, and the service server determines the message receiving group ID in the Redis message database based on the group ID of the message receiving group. The Key of the group session of the message receiving group, the above-mentioned Key is used as an index to query the group message list of the above-mentioned group session in the Redis message database, and this group message list is a part of the message collection in the Redis database An exemplary description. Next, create a transaction that inserts a new message to be sent into the group message list, and use this transaction to initiate a write operation on the message to be sent, for example, insert the message to be sent into the Key-Value group message list Value.
在步骤306-F1至步骤306-F3中,提供了在非实时业务为消息发送业务的情况下,通过该协程发起该非实时业务的数据库操作的一种可能实施方式,即,对于私人会话中新发送的个人消息,能够通过上述步骤306-F1和步骤306-F2,实现向消息接收账号发送个人消息的操作;对于群组会话中新发送的群组消息,能够通过上述步骤306-F1和步骤306-F3,实现在消息接收群组中发送群组消息的操作,这样能够提供对个人消息或群组消息的通用接口,或者分别提供对个人消息的发送接口以及对群组消息的发送接口,实现消息发送业务的高可用性。In step 306-F1 to step 306-F3, in the case that the non-real-time service is a message sending service, a possible implementation manner of initiating the database operation of the non-real-time service through the coroutine is provided, that is, for a private session For the newly sent personal message, the operation of sending a personal message to the message receiving account can be realized through the above steps 306-F1 and 306-F2; for the newly sent group message in the group conversation, the above step 306-F1 can And step 306-F3, realize the operation of sending group messages in the message receiving group, so that a general interface for personal messages or group messages can be provided, or an interface for sending individual messages and sending of group messages can be provided respectively Interface to achieve high availability of message sending services.
在步骤1301中,业务服务器基于该写入操作的操作结果,为该待发送消息分配消息ID,生成向该账号通知消息发送成功的响应。In
在一些实施例中,业务服务器执行完对待发送消息的写入操作后,在写入操作的操作结果指示事务提交的情况下,代表待发送消息已经成功写入到对应的消息集合(私人消息列表或群组消息列表)中并且已经数据落盘,可以对该待发送消息分配唯一且保持递增的消息ID,消息ID的编码方式可以是在自身会话中保持递增或者全服消息均保持递增,即,对每个会话单独保持消息ID递增编码,或者,对全服所有消息统一保持递增编码,接着,生成向该账号通知消息发送成功的响应(如ACK消息),不再赘述;在写入操作的操作结果指示事务回滚的情况下,直接生成并返回通知消息发送失败的响应。In some embodiments, after the business server finishes writing the message to be sent, if the operation result of the write operation indicates that the transaction is committed, it means that the message to be sent has been successfully written into the corresponding message set (private message list or group message list) and the data has been placed on the disk, the message to be sent can be assigned a unique message ID that keeps increasing. The encoding method of the message ID can be kept increasing in its own session or all messages on the server keep increasing, that is , keep the message ID incremental encoding for each session separately, or keep the incremental encoding for all messages in the whole server uniformly, and then generate a response (such as ACK message) to notify the account that the message is sent successfully, which will not be described again; in the write operation If the result of the operation indicates that the transaction is rolled back, it will directly generate and return a response that the sending of the notification message failed.
可选地,业务服务器在生成上述ACK消息后,由业务服务器直接向终端返回上述ACK消息,可节约通信开销,或者,业务服务器通过服务API,向游戏服务器回传上述ACK消息,以使游戏服务器将上述ACK消息发送给终端,这样能够降低终端的感知性,保证终端对业务服务器无感知,微服务框架对用户侧透明。Optionally, after the service server generates the above ACK message, the service server directly returns the above ACK message to the terminal, which can save communication overhead, or, the service server returns the above ACK message to the game server through the service API, so that the game server The above ACK message is sent to the terminal, which can reduce the perception of the terminal, ensure that the terminal has no perception of the service server, and the microservice framework is transparent to the user side.
在一些实施例中,在写入操作的操作结果指示事务提交的情况下,业务服务器在对消息ID分配完毕后,在待发送消息是个人消息的情况下,检测个人消息的消息接收账号的登录状态,若消息接收账号处于游戏离线状态,返回上述生成的ACK消息后退出流程,若消息接收账号处于游戏在线状态,执行步骤1302,以向处于游戏在线状态的消息接收账号生成新消息推送响应;在待发送消息是群组消息的情况下,由于消息接收群组中包含多个成员账号,进入步骤1303,即检测消息接收群组中每个成员账号的登录状态,仅对处于游戏在线状态的在线成员账号额外生成新消息推送响应。其中,新消息推送响应是指向在线的消息接收账号或者消息接收群组中的在线成员账号通知新收到一条消息的响应。In some embodiments, when the operation result of the write operation indicates that the transaction is committed, the service server detects the login of the message receiving account of the personal message after allocating the message ID and in the case that the message to be sent is a personal message state, if the message receiving account is in the offline state of the game, return the ACK message generated above and exit the process, if the message receiving account is in the game online state, execute
在步骤1302中,在待发送消息是个人消息的情况下,业务服务器仅在该个人消息的消息接收账号处于游戏在线状态的情况下,生成向该消息接收账号推送该待发送消息的响应。In
在一些实施例中,在待发送消息是个人消息的情况下,业务服务器对于个人消息的消息接收账号的登录状态进行检测,若消息接收账号处于游戏离线状态,这条新的待发送消息会在消息接收账号登录后首次批量拉取未读消息时下发,不需要进行实时通知;若消息接收账号处于游戏在线状态,那么还需要生成一个向消息接收账号推送待发送消息的响应(以下简称为新消息推送响应),以通知该消息接收账号有一条新的未读消息,相当于实现新消息发布后的实时提醒机制。In some embodiments, when the message to be sent is a personal message, the service server detects the login status of the message receiving account of the personal message. If the message receiving account is offline in the game, the new message to be sent will be in the After the message receiving account logs in, the unread messages are fetched in batches for the first time, and real-time notification is not required; if the message receiving account is online in the game, a response to push the message to be sent to the message receiving account (hereinafter referred to as the new message) needs to be generated. Message Push Response) to notify the message receiving account that there is a new unread message, which is equivalent to realizing the real-time reminder mechanism after the new message is published.
在一些实施例中,将上述待发送消息封装到新消息推送响应中,并通过直接或间接的方式向终端发送该新消息推送响应,新消息推送响应的发送方式与步骤1301中ACK消息的发送方式同理,不再赘述。In some embodiments, the above message to be sent is encapsulated into a new message push response, and the new message push response is sent to the terminal directly or indirectly. The sending method of the new message push response is the same as the sending of the ACK message in
以下,将以玩家向消息接收账号新发送了一条个人消息为例进行说明。Hereinafter, it will be described by taking a new personal message sent by the player to the message receiving account as an example.
图14是本公开实施例提供的一种消息发送业务的交互流程图,如图14所示,玩家在终端侧的游戏应用中触发对个人消息的消息发送请求;游戏服务器侧的逻辑进程Logic上维护有该玩家的对象Avatar,通过上述对象Avatar接收终端侧的消息发送请求,并向业务服务器的主线程ChatService发送消息发送请求关联的RPC请求;接着,主线程ChatService检测到消息类型为个人消息,可对该个人消息的消息内容进行前置检查,如敏感词筛选等,以确保个人消息的合法性;接着,主线程ChatService根据玩家账号的账号ID和消息接收账号的账号ID,确定两个账号之间私人会话的Key,以通过Key查询到Value中记录的私人消息列表,并向Redis消息数据库发起将该个人消息写入私人消息列表的写入操作;Redis消息数据库向主线程ChatService返回写入操作的操作结果;接着,在操作结果指示事务提交的情况下,对写入成功的该条个人消息分配一个新的保持递增的消息ID,主线程ChatService向Redis消息数据库指示,直接将玩家账号对该条个人消息的状态标记为已读状态(如将玩家账号缓存的最大消息ID更新为对个人消息新分配的消息ID);接着,主线程ChatService检测消息接收账号登录状态,若消息接收账号处于在线状态,对该消息接收账号生成新消息推送响应,并将新消息推送响应推送到消息接收账号所登录的其他终端。Fig. 14 is an interactive flow chart of a message sending service provided by an embodiment of the present disclosure. As shown in Fig. 14, a player triggers a message sending request for a personal message in a game application on the terminal side; Maintain the player's object Avatar, receive the message sending request on the terminal side through the above object Avatar, and send the RPC request associated with the message sending request to the main thread ChatService of the business server; then, the main thread ChatService detects that the message type is a personal message, The message content of the personal message can be pre-checked, such as sensitive word screening, etc., to ensure the legitimacy of the personal message; then, the main thread ChatService determines the two accounts according to the account ID of the player account and the account ID of the account receiving the message The Key of the private conversation between them, so as to query the private message list recorded in Value through the Key, and initiate a write operation of writing the personal message to the private message list to the Redis message database; the Redis message database returns the write to the main thread ChatService The operation result of the operation; then, in the case that the operation result indicates that the transaction is submitted, a new message ID that keeps increasing is assigned to the successfully written personal message, and the main thread ChatService instructs the Redis message database to directly link the player account to the The status of this personal message is marked as read (such as updating the maximum message ID cached by the player account to the newly assigned message ID for the personal message); then, the main thread ChatService detects the login status of the message receiving account, if the message receiving account is in In the online state, a new message push response is generated for the message receiving account, and the new message push response is pushed to other terminals logged into the message receiving account.
在步骤1303中,在待发送消息是群组消息的情况下,业务服务器拉取该群组消息的消息接收群组的最新成员列表;仅对该最新成员列表中的在线成员账号,生成向该在线成员账号推送该待发送消息的响应。In
在一些实施例中,在待发送消息是群组消息的情况下,为了避免由于消息接收群组中的成员账号发生变更导致消息推送出错,业务服务器需要拉取到消息接收群组的最新成员列表,并遍历最新成员列表中的所有成员账号的登录状态,对于处于游戏在线状态的每个在线成员账号,基于与步骤1302同理的方式生成对新消息推送响应,对新消息推送响应以单播、组播或多播方式发送到所有在线成员账号登录的终端;对于处于游戏离线状态的各个离线成员账号,这条新的待发送消息会在离线成员账号登录后首次批量拉取未读消息时下发,不需要进行实时通知,无需执行任何后处理。In some embodiments, when the message to be sent is a group message, in order to avoid message push errors due to changes in member accounts in the message receiving group, the service server needs to pull the latest member list of the message receiving group , and traverse the login status of all member accounts in the latest member list, for each online member account in the online state of the game, generate a push response to the new message based on the same method as
在一些实施例中,最新成员列表可以由另一个独立的群组服务API和其通过微服务架构部署的业务服务器来进行提供,或者记录在消息服务系统的业务服务器本地,或者从游戏服务器的主逻辑进程中拉取,这里对最新成员列表的来源不进行具体限定。In some embodiments, the latest member list can be provided by another independent group service API and its business server deployed through the microservice architecture, or recorded locally on the business server of the message service system, or from the main server of the game server The source of the latest member list is not specifically limited here.
以下,将以玩家在消息接收群组中新发送了一条群组消息为例进行说明。Hereinafter, it will be described by taking a new group message sent by a player in the message receiving group as an example.
图15是本公开实施例提供的一种消息发送业务的交互流程图,如图15所示,玩家在终端侧的游戏应用中触发对群组消息的消息发送请求;游戏服务器侧的逻辑进程Logic上维护有该玩家的对象Avatar,通过上述对象Avatar接收终端侧的消息发送请求,并向业务服务器的主线程ChatService发送消息发送请求关联的RPC请求;接着,主线程ChatService检测到消息类型为群组消息,从Redis消息数据库中请求消息接收群组的最新成员列表;Redis消息数据库向主线程ChatService返回消息接收群组的最新成员列表;主线程ChatService检测最新成员列表与本地缓存的成员列表是否不同,如果不同,将最新成员列表覆盖并缓存到本地,接着,将本次待发送的群组消息写入到Redis消息数据库中该消息接收群组的群组消息列表中,即,发送将群组消息写入群组消息列表的写入操作;Redis消息数据库向主线程ChatService返回写入操作的操作结果;在操作结果指示事务提交的情况下,主线程ChatService基于本地更新后的群组成员列表来逐个检测成员账号的登录状态,仅对消息接收群组中的在线成员账号生成新消息推送响应,并将新消息推送响应推送到各个在线成员账号所登录的其他终端。Fig. 15 is an interactive flowchart of a message sending service provided by an embodiment of the present disclosure. As shown in Fig. 15 , the player triggers a message sending request for a group message in the game application on the terminal side; the logic process Logic on the game server side The player's object Avatar is maintained on the Internet, and the above-mentioned object Avatar receives the message sending request on the terminal side, and sends the RPC request associated with the message sending request to the main thread ChatService of the business server; then, the main thread ChatService detects that the message type is a group Message, request the latest member list of the message receiving group from the Redis message database; the Redis message database returns the latest member list of the message receiving group to the main thread ChatService; the main thread ChatService detects whether the latest member list is different from the local cached member list, If it is different, the latest member list is overwritten and cached locally, and then, the group message to be sent this time is written into the group message list of the message receiving group in the Redis message database, that is, the group message is sent The write operation of writing group message list; the Redis message database returns the operation result of the write operation to the main thread ChatService; when the operation result indicates that the transaction is committed, the main thread ChatService performs one by one based on the locally updated group member list. Detect the login status of the member account, generate a new message push response only for the online member account in the message receiving group, and push the new message push response to other terminals logged in by each online member account.
在上述步骤1301至1303中,提供了业务服务器生成响应的一种可能实施方式,即,不论对于个人消息还是对于群组消息,业务服务器侧都仅对在线的消息接收账号或者消息接收群组中的在线成员账号额外生成新消息推送响应,上述ACK消息或新消息推送响应可由业务服务器直接向终端返回响应,或由业务服务器将响应发送到游戏服务器再由游戏服务器转发到终端。通过对消息接收账号或消息接收群组中的成员账号的登录状态进行检测,在检测到消息接收账号或消息接收群组中的成员账号处于游戏在线状态时,还对消息接收账号或在线成员账号返回新消息推送响应,这样能够有效避免消息接收账号或在线成员账号错过新消息,提醒消息接收账号或在线成员账号尽快查看新消息,提升了消息送达效率和时效性。In the
在上述(四)和(五)中分别介绍了未读消息拉取业务、红点数据拉取业务和消息发送业务等消息服务系统所支持各类消息业务,应理解,上述几类业务仅是对消息业务的举例,消息服务系统还支持标记已读、删除消息等其他业务,这些业务的处理流程同理,不再一一枚举。In the above (4) and (5), the various message services supported by the message service system, such as the unread message pull service, the red dot data pull service, and the message send service, are respectively introduced. It should be understood that the above-mentioned types of services are only As an example of the message service, the message service system also supports other services such as marking read and deleting messages. The processing procedures of these services are similar and will not be enumerated one by one.
(六)账号添加业务(6) Account Adding Service
图16是本公开实施例提供的一种账号添加业务的处理流程图,如图16所示,以终端侧账号发起的游戏业务请求为账号添加请求为例,账号添加请求的处理方法由业务服务器执行,业务服务器可以是一台集成式处理各类非实时业务的服务器,或者是单独部署的关系链业务服务器,其中,业务服务器为计算机设备的示例性说明。Fig. 16 is a flow chart of processing an account addition service provided by an embodiment of the present disclosure. As shown in Fig. 16, taking the game service request initiated by the account on the terminal side as an account addition request as an example, the processing method of the account addition request is determined by the service server For execution, the business server can be an integrated server that processes various non-real-time businesses, or a relational chain business server that is deployed separately, wherein the business server is an example of computer equipment.
需要说明的是,这里仅对游戏服务器将账号添加请求对应的RPC请求发送到业务服务器,业务服务器创建协程以后的处理流程进行说明,即,本公开实施例的方案是在前述实施例中步骤305以后实现的,关于RPC请求如何从游戏服务器发送到业务服务器,以及业务服务器如何创建协程的方式,请参考前述实施例的描述,不再赘述。It should be noted that, here only the game server sends the RPC request corresponding to the account addition request to the business server, and the processing flow after the business server creates the coroutine is described, that is, the solution of the embodiment of the present disclosure is the step For the implementation after 305, please refer to the description of the foregoing embodiments for how the RPC request is sent from the game server to the service server, and how the service server creates a coroutine, and will not be repeated here.
在步骤306-G1中,业务服务器通过协程,对发起账号添加请求的账号以及该账号所请求添加的目标账号进行权限验证。In step 306-G1, the business server performs authority verification on the account that initiates the account addition request and the target account that the account requests to add through the coroutine.
其中,该账号添加请求用于申请将目标账号添加到该账号的账号关系链上。Wherein, the account addition request is used to apply for adding the target account to the account relationship chain of the account.
在一些实施例中,用户在终端侧可以发起对目标账号的账号添加请求(如申请加好友),该账号添加请求中至少携带发起方账号的账号ID和接收方账号即目标账号的账号ID,上述发起方账号的账号ID和目标账号的账号ID会作为业务参数被封装到账号添加请求中。游戏服务器在接收到账号添加请求后,解析得到上述业务参数,并将上述业务参数注入到消息服务API,由消息服务API对业务服务器发起RPC请求,RPC请求中携带上述消息服务API中被注入的业务参数,使得业务服务器在创建协程后,该协程能够通过消息服务API提供的业务参数,获取到上述发起方账号的账号ID和目标账号的账号ID。In some embodiments, the user can initiate an account addition request (such as applying to add friends) to the target account on the terminal side, and the account addition request carries at least the account ID of the initiator account and the account ID of the recipient account, that is, the target account. The above account ID of the initiator account and the account ID of the target account will be encapsulated into the account addition request as business parameters. After the game server receives the account addition request, it parses the above business parameters and injects the above business parameters into the message service API. The message service API initiates an RPC request to the business server. The RPC request carries the information injected into the above message service API. Business parameters, so that after the business server creates a coroutine, the coroutine can obtain the account ID of the initiator account and the account ID of the target account through the business parameters provided by the message service API.
在一些实施例中,业务服务器获取到发起方账号的账号ID和目标账号的账号ID之后,可以发起方账号和目标账号进行一系列的权限验证,如:检测发起方账号的好友数量是否到达好友列表上限;检测目标账号是否位于发起方账号的黑名单;检测发起方账号自身申请列表是否超出上限;检测目标账号的好友数量是否到达好友列表上限;检测发起方账号是否位于目标账号的黑名单;检测目标账号的好友申请列表是否超出上限等。上述权限验证的检测逻辑由技术人员按照游戏好友业务需求进行灵活配置。这里的好友是指在账号关系链上具有双向或单向关联关系的一对账号。In some embodiments, after the business server obtains the account ID of the initiator account and the account ID of the target account, it can perform a series of authority verifications on the initiator account and the target account, such as: detecting whether the number of friends of the initiator account has reached the number of friends List upper limit; detect whether the target account is in the blacklist of the initiator account; detect whether the initiator account's own application list exceeds the upper limit; detect whether the number of friends of the target account reaches the upper limit of the friend list; detect whether the initiator account is in the blacklist of the target account; Detect whether the friend request list of the target account exceeds the upper limit, etc. The detection logic of the above permission verification is flexibly configured by technicians according to the business requirements of game friends. The friends here refer to a pair of accounts that have a two-way or one-way relationship on the account relationship chain.
在本公开实施例中,由于采取协程式开发,上述权限验证的检测逻辑如果是串行检测,那么可以在启动一项检测后就阻塞并挂起协程,等待检测结果返回后,如果检测通过则继续启动下一项检测然后阻塞并挂起协程,如果检测未通过可以直接退出检测逻辑,向发起方账号返回通知账号添加失败的响应,这种协程式开发方式,在涉及到的检测逻辑的调用链较长时,整体无需繁琐定义大量的检测函数和回调函数,只需要一次触发整体检测逻辑,并在所有检测逻辑执行完毕后回调一次即可,很利好于业务扩展和维护。In the embodiment of the present disclosure, due to the adoption of coroutine development, if the detection logic of the above-mentioned permission verification is serial detection, then after starting a detection, the coroutine can be blocked and suspended, and after the detection result is returned, if the detection passes Then continue to start the next detection and then block and suspend the coroutine. If the detection fails, you can directly exit the detection logic, and return a response to the initiator account to notify the account of the failure to add. This coroutine development method, in the detection logic involved When the call chain is long, there is no need to define a large number of detection functions and callback functions. It only needs to trigger the overall detection logic once, and call back once after all the detection logic is executed, which is very beneficial to business expansion and maintenance.
业务服务器通过检测逻辑对双方账号权限验证完毕后,若权限验证通过,执行步骤306-G2,若权限验证失败,则退出返回并向发起方账号返回通知账号添加失败的响应。可选地,在响应中还添加了添加失败的原因,即哪项检测未通过,方便用户在解决相关问题后再次提交账号添加申请。After the business server has verified the permissions of both accounts through the detection logic, if the permission verification is passed, execute step 306-G2; if the permission verification fails, exit and return and return a response notifying the account addition failure to the initiator account. Optionally, the reason for the addition failure is also added in the response, that is, which test failed, so that the user can submit the account addition application again after solving related problems.
在步骤306-G2中,业务服务器在权限验证通过后,向数据库发起写入由该发起方账号向该目标账号的账号添加记录的数据库操作。In step 306-G2, after the authority verification is passed, the business server initiates a database operation of writing the record added by the initiator account to the account of the target account to the database.
在一些实施例中,在上述对权限验证的一系列检测逻辑均通过的情况下,才视为权限验证通过,接着,以业务服务器侧可以通过Mango关系数据库来维护各个账号的账号关系链,并支持对账号关系链进行动态变更的维护,除了Mango关系数据库以外,还能以图数据库的方式来存储游戏内社交网络的关系链数据,不再赘述。In some embodiments, the above-mentioned series of detection logics for authority verification are all passed, then the authority verification is deemed to be passed. Then, the business server side can maintain the account relationship chain of each account through the Mango relational database, and Supports the maintenance of dynamic changes to the account relationship chain. In addition to the Mango relationship database, it can also store the relationship chain data of the social network in the game in the form of a graph database, so I won’t repeat it here.
在一些实施例中,业务服务器在对Mango关系数据库中,对每个账号都维护有一个好友申请列表,好友申请列表用于记录有哪些账号对自身发起了账号添加请求。接着,在当前账号添加请求的权限验证通过后,以目标账号的账号ID为索引,查询到目标账号的好友申请列表,并创建向该好友申请列表写入该发起方账号(即发出账号添加请求的账号)的事务,通过该事务来发起写入由该发起方账号向目标账号的账号添加记录的数据库操作,上述数据库操作被实施为向目标账号的好友申请列表中写入发起方账号的写入操作。In some embodiments, the service server maintains a friend request list for each account in the Mango relational database, and the friend request list is used to record which accounts have initiated account addition requests to itself. Then, after the authority verification of the current account addition request is passed, the account ID of the target account is used as an index to query the friend application list of the target account, and create and write the initiator account into the friend application list (that is, send an account addition request. account) transaction, through which the database operation of adding records from the initiator account to the account of the target account is initiated. Enter operation.
在步骤306-G1至步骤306-G2中,提供了在非实时业务为账号添加业务的情况下,通过该协程发起该非实时业务的数据库操作的一种可能实施方式,即,通过在Mango关系数据库中为每个账号维护一个好友申请列表,这样能够将账号关系链的添加操作,简化成向目标账号的好友申请列表写入发起方账号的写入操作,如果涉及到批量添加好友的操作,只需要向一系列账号各自的好友申请列表中均写入发起方账号即可,开发复杂度低且易于实现,这样能够提供对单个添加好友或批量添加好友的通用接口,或者分别提供对单个添加好友的接口以及对批量添加好友的接口,实现账号添加业务的高可用性。In step 306-G1 to step 306-G2, in the case that the non-real-time service adds a service to an account, a possible implementation manner of initiating the database operation of the non-real-time service through the coroutine is provided, that is, through the Mango A friend request list is maintained for each account in the relational database, which simplifies the operation of adding account relationship chains to the write operation of writing the initiator account to the friend request list of the target account. If it involves the operation of adding friends in batches , you only need to write the originator account in the respective friend application lists of a series of accounts. The development complexity is low and easy to implement. This can provide a general interface for adding friends individually or in batches, or provide a separate interface for individual The interface for adding friends and the interface for adding friends in batches to achieve high availability of the account adding business.
在步骤1601中,业务服务器在该操作结果指示对该账号添加记录写入完毕的情况下,生成对该目标账号的账号添加通知响应。In
在一些实施例中,业务服务器执行完向目标账号的好友申请列表写入发起方账号的写入操作后,在写入操作的操作结果指示事务提交的情况下,代表已经将发起方账号写入目标账号的好友申请列表,完成了对本次账号添加记录的写入操作并且已经数据落盘,可以生成向发起方账号通知申请发送成功的响应(如ACK消息),不再赘述;在写入操作的操作结果指示事务回滚的情况下,直接生成并返回通知申请发送失败的响应。In some embodiments, after the service server completes the write operation of writing the initiator account to the friend application list of the target account, if the operation result of the write operation indicates that the transaction is submitted, the representative has written the initiator account The friend application list of the target account has completed the writing operation of the account addition record and the data has been placed on the disk, and can generate a response (such as an ACK message) to notify the initiator account that the application is successfully sent, which will not be described again; after writing If the operation result of the operation indicates that the transaction is rolled back, it will directly generate and return a response notifying that the application has failed to send.
可选地,业务服务器在生成上述ACK消息后,由业务服务器直接向终端返回上述ACK消息,可节约通信开销,或者,业务服务器通过服务API,向游戏服务器回传上述ACK消息,以使游戏服务器将上述ACK消息发送给终端,这样能够降低终端的感知性,保证终端对业务服务器无感知,微服务框架对用户侧透明。Optionally, after the service server generates the above ACK message, the service server directly returns the above ACK message to the terminal, which can save communication overhead, or, the service server returns the above ACK message to the game server through the service API, so that the game server The above ACK message is sent to the terminal, which can reduce the perception of the terminal, ensure that the terminal has no perception of the service server, and the microservice framework is transparent to the user side.
在一些实施例中,业务服务器可以检测目标账号的登录状态,并在目标账号处于游戏离线状态时,目标账号登录后首次拉取好友申请列表时就能够查看到这条新的账号添加请求,无需进行后处理;在目标账号处于游戏在线状态时,可以对目标账号生成账号添加通知响应,并将账号添加通知响应直接或间接推送到目标账号登录的其他终端。其中,账号添加通知响应是指向在线的目标账号通知新收到一条账号添加申请的响应,账号添加通知响应的发送方式与上述ACK消息的发送方式同理,不再赘述。In some embodiments, the service server can detect the login status of the target account, and when the target account is in the offline state of the game, the new account addition request can be viewed when the target account logs in and pulls the friend application list for the first time. Perform post-processing; when the target account is in the online state of the game, an account addition notification response can be generated for the target account, and the account addition notification response can be directly or indirectly pushed to other terminals logged in by the target account. Wherein, the account addition notification response is a response to the online target account notifying that a new account addition application has been received, and the sending method of the account adding notification response is the same as the sending method of the above-mentioned ACK message, and will not be repeated here.
以下,将以玩家A向玩家B发起了账号添加请求为例进行说明。Hereinafter, it will be described by taking that player A initiates an account addition request to player B as an example.
图17是本公开实施例提供的一种账号添加业务的交互流程图,如图17所示,玩家A在终端侧的游戏应用中触发对玩家B所持有的目标账号的账号添加请求;业务服务器侧的主线程FriendService通过游戏服务器接收到账号添加请求所关联的RPC请求,并开启对双方账号的前置检查(即权限验证),如是否超出双方好友数量上限、是否到达申请数量上限、是否被纳入对方黑名单等;在验证通过后,主线程FriendService向Mango关系数据库发起向目标账号的好友申请列表写入玩家A账号的写入操作;Mango关系数据库执行上述写入操作,并向主线程FriendService返回写入操作的操作结果;接着,在操作结果指示事务提交的情况下,一方面,向玩家A登录的终端提示账号添加请求发送成功的响应,另一方面,检测目标账号的登录状态,若目标账号处于在线状态,对该目标账号生成账号添加通知响应,并将账号添加通知响应下发到目标账号所登录的其他终端。Fig. 17 is an interactive flowchart of an account addition service provided by an embodiment of the present disclosure. As shown in Fig. 17, player A triggers an account addition request for the target account held by player B in the game application on the terminal side; The main thread FriendService on the server side receives the RPC request associated with the account addition request through the game server, and starts the pre-check (that is, authorization verification) for the accounts of both parties, such as whether the upper limit of the number of friends of both parties is exceeded, whether the upper limit of the number of applications is reached, whether the Included in the other party’s blacklist, etc.; after the verification is passed, the main thread FriendService initiates a write operation to the Mango relational database to write the friend application list of the target account into the player A’s account; the Mango relational database executes the above write operation, and writes to the main thread FriendService returns the operation result of the write operation; then, when the operation result indicates that the transaction is submitted, on the one hand, it prompts player A to log in to the terminal that the account addition request has been successfully sent; on the other hand, it detects the login status of the target account, If the target account is in an online state, an account addition notification response is generated for the target account, and the account addition notification response is sent to other terminals logged in by the target account.
在上述步骤1601中,提供了业务服务器生成响应的一种可能实施方式,即,在将发起方账号写入到目标账号的好友申请列表后,业务服务器侧对发起方账号返回ACK消息,上述ACK消息可由业务服务器直接向终端返回响应,或由业务服务器将响应发送到游戏服务器再由游戏服务器转发到终端。进一步地,通过对目标账号的登录状态进行检测,在检测到目标账号处于游戏在线状态时,还对目标账号返回账号添加通知响应,这样能够有效避免目标账号错过上述账号添加申请,提醒目标账号尽快查看并处理上述账号添加申请,提升了业务请求的送达效率和时效性。In the
可以看出,在邮件服务系统、消息服务系统、关系链服务系统中,经常会涉及到针对某一账号群组进行群发邮件,或者在某一账号群组内发送群组消息,或对某一组账号批量发起账号添加请求这类涉及到群组的业务,但由于群组内成员并非是一成不变的,可能涉及到旧成员退出或者新成员加入,因此,可以由游戏服务器的主逻辑进程来动态维护群组成员列表,其他业务在必要时向主逻辑进程来交互,或者,由不同业务服务器各自动态维护群组成员列表,并定期进行群组成员列表的同步,而在本公开实施例中,还涉及到另一种动态维护群组成员列表的方式,即,再单独拆分出来一个群组服务API并以微服务架构方式部署用于提供群组服务的业务服务器,可以是单独一台群组业务服务器,或者是分布式架构的CDN服务器集群,不再限定。It can be seen that in the mail service system, message service system, and relationship chain service system, it often involves mass sending of emails for a certain account group, or sending group messages within a certain account group, or sending messages to a certain account group. Group accounts initiate account addition requests in batches, which involves group business, but since the members in the group are not static, it may involve the exit of old members or the joining of new members. Therefore, the main logic process of the game server can dynamically Maintain the list of group members, and other services interact with the main logic process when necessary, or, different service servers dynamically maintain the list of group members, and periodically synchronize the list of group members. In the embodiment of the present disclosure, It also involves another way to dynamically maintain the list of group members, that is, separate a group service API and deploy a business server for providing group services in a microservice architecture, which can be a single group Group business servers, or CDN server clusters with a distributed architecture, are no longer limited.
对于群组服务系统(GroupService)来说,可以专用于维护各类临时或非临时的账号群组的最新成员列表,如账号群组包括:游戏联盟、游戏公会、临时小队、副本队伍等,群组服务API则用于支持对账号群组的创建、解散、成员加入、成员退出等一系列业务需求提供接口支持。对于账号群组来说,成员账号的登录状态(游戏在线或游戏离线)不会影响到账号群组内部的成员关系,因此,通过单独部署一个群组服务API和其配套的业务服务器来维护每个账号群组的最新成员列表,这样能够方便其他如邮件业务或者消息业务来调用群组服务API,即可拉取到指定群组的最新成员列表,而无需邮件业务服务器或消息业务服务器来计算或维护最新成员列表,由于对最新成员列表的维护迁移到了外部的群组服务系统,可以加快群聊消息拉取、群聊红点数据拉取、群发邮件、批量添加好友等交叉业务的响应速率。示意性地,群组服务系统中的群组关系数据库为Redis存储集群,以Key-Value数据结构的方式来记录各个账号群组的最新成员列表,比如,以账号群组的群组ID作为Key,以账号群组的最新成员列表作为Value,以此来维护群组成员关系。For the group service system (GroupService), it can be dedicated to maintaining the latest member lists of various temporary or non-temporary account groups, such as account groups include: game alliances, game guilds, temporary teams, dungeon teams, etc., group The group service API is used to support a series of business requirements such as account group creation, dissolution, member joining, and member exit. For account groups, the login status of member accounts (game online or game offline) will not affect the membership relationship within the account group. Therefore, a group service API and its supporting business server are separately deployed to maintain each The latest member list of an account group, which can facilitate others such as mail business or message business to call the group service API, and then pull the latest member list of the specified group, without the need for mail business server or message business server to calculate. Or maintain the latest member list. Since the maintenance of the latest member list is migrated to the external group service system, it can speed up the response rate of cross-services such as group chat message pull, group chat red dot data pull, group email, and batch addition of friends. . Schematically, the group relationship database in the group service system is a Redis storage cluster, which records the latest member list of each account group in the form of Key-Value data structure, for example, the group ID of the account group is used as the Key , using the latest member list of the account group as the Value to maintain the group membership.
图18是本公开实施例提供的一种群组服务系统的业务流程图,如图18所示,当群组成员发生变更(如旧成员退出、新成员加入等)时,终端侧将对群组成员变更的群组变更请求,通过游戏服务器将其RPC请求发送到业务服务器的主线程GroupService上;主线程GroupService基于RPC请求,获取到对目标群组的群组成员的变更操作,并指示Redis群组关系数据库对目标群组的最新成员列表执行对应的变更操作;Redis群组关系数据库向主线程GroupService返回变更操作的操作结果,即可实现动态维护最新成员列表。Fig. 18 is a business flow chart of a group service system provided by an embodiment of the present disclosure. As shown in Fig. 18, when group members change (such as old members quitting, new members joining, etc.), the terminal side will The group change request for group member change sends its RPC request to the main thread GroupService of the business server through the game server; the main thread GroupService obtains the change operation of the group member of the target group based on the RPC request, and instructs Redis The group relational database executes the corresponding change operation on the latest member list of the target group; the Redis group relational database returns the operation result of the change operation to the main thread GroupService, so that the latest member list can be dynamically maintained.
在上述各个实施例中,详细介绍了服务器后端的邮件服务系统、消息服务系统以及群组服务系统在各类业务上的处理流程,由于这些服务系统均对实时性要求不高,且处理逻辑又相较于游戏主业务逻辑是比较独立的,通过微服务架构实现以上几类服务系统的拆分,并将拆分出来的服务系统部署在远端的业务服务器,以使业务服务器来支持各自的业务功能,能够极大地减轻游戏服务器的用户负载,并且,后续对某类业务进行升级或迭代时,可以单独修改其所在业务服务器的代码逻辑,而不会影响到游戏主业务逻辑或其他无关业务逻辑的正常运行,简化了游戏后端开发难度,且提升了游戏应用的可扩展性。而且,由于避免了将所有业务集中在游戏服务器这种整体式架构的开发模式,也就有效规避了故障级联的问题,防止单个业务模块不可用而阻塞所有业务进展,而且由于拆分出来部署的各类服务系统具有一定的独立性,因此可方便地迁移到其他游戏产品中,具有极高的可移植性。In each of the above-mentioned embodiments, the processing flow of the mail service system, the message service system and the group service system on the backend of the server are introduced in detail. Since these service systems do not have high requirements for real-time performance, and the processing logic Compared with the main business logic of the game, which is relatively independent, the split of the above types of service systems is realized through the micro-service architecture, and the split service systems are deployed on remote business servers, so that the business servers can support their respective Business functions can greatly reduce the user load of the game server, and when a certain type of business is upgraded or iterated, the code logic of the business server where it is located can be independently modified without affecting the game's main business logic or other irrelevant businesses The normal operation of logic simplifies the difficulty of game back-end development and improves the scalability of game applications. Moreover, since it avoids the development mode of integrating all businesses in the overall architecture of the game server, it also effectively avoids the problem of cascading faults, prevents the unavailability of a single business module from blocking all business progress, and because it is split and deployed The various service systems of the game have a certain degree of independence, so they can be easily migrated to other game products, and have extremely high portability.
图19是根据本公开实施例示出的一种游戏业务请求的处理装置的逻辑结构框图。参照图19,该装置包括确定单元1901、查询单元1902和发送单元1903。Fig. 19 is a logical structural block diagram of an apparatus for processing a game service request according to an embodiment of the present disclosure. Referring to FIG. 19 , the device includes a determining
确定单元1901,被配置为执行响应于账号的游戏业务请求,确定该游戏业务请求的业务类型,该业务类型指示该游戏业务请求所关联的游戏业务的时效属性;The determining
该确定单元1901,还被配置为执行在该业务类型指示该游戏业务为非实时业务的情况下,确定该非实时业务相匹配的服务接口;The determining
查询单元1902,被配置为执行从服务注册中心中查询用于提供该服务接口的业务服务器的地址,该服务注册中心用于记录各类接口的业务服务器的地址;The
发送单元1903,被配置为执行基于该服务接口,向该地址发送远程过程调用RPC请求,该RPC请求用于指示该业务服务器向该账号提供对该游戏业务的响应。The sending
本公开实施例提供的装置,通过对于请求非实时业务的游戏业务请求,由于实时性要求不高,无需游戏服务器本地进行实时处理,由此在服务注册中心中查询到专用于处理该非实时业务的服务API,再通过该服务API对远程的业务服务器进行RPC远程调用,这样能够将涉及到非实时业务的用户负载从游戏服务器迁移到业务服务器中,优化了游戏服务器的资源配置,且由于针对非实时业务的迭代和更新仅需要修改业务服务器中的代码逻辑,必要时修改服务API,不涉及到对游戏的主业务逻辑打补丁,降低了开发复杂度、提升了游戏开发效率,并且不同类型的非实时业务可单独部署在不同业务服务器中,使得某些业务功能阻塞时,不会影响到其他业务功能的正常使用,且也不会影响到游戏的主业务逻辑,极大提升了游戏可用性。The device provided by the embodiment of the present disclosure, through the game service request requesting non-real-time service, because the real-time requirements are not high, there is no need for the game server to perform real-time processing locally, so the service registration center can be found to be dedicated to processing the non-real-time service. service API, and then make RPC remote call to the remote business server through the service API, so that the user load related to non-real-time business can be migrated from the game server to the business server, and the resource configuration of the game server is optimized. The iteration and update of non-real-time business only needs to modify the code logic in the business server, and modify the service API if necessary, which does not involve patching the main business logic of the game, which reduces the development complexity and improves the game development efficiency. The non-real-time business can be deployed separately in different business servers, so that when some business functions are blocked, it will not affect the normal use of other business functions, and will not affect the main business logic of the game, which greatly improves the usability of the game .
在一些实施例中,该查询单元1902被配置为执行:In some embodiments, the
从该服务注册中心中,查询用于提供该服务接口的地址集合;From the service registry, query the set of addresses used to provide the service interface;
从该地址集合中,查询与该账号地理距离最近的业务服务器的地址。From the address set, query the address of the business server with the closest geographic distance to the account.
在一些实施例中,基于图19的装置组成,该装置还包括:In some embodiments, based on the composition of the device in Figure 19, the device further includes:
创建单元,被配置为执行通过该业务服务器响应于该RPC请求,创建该非实时业务的协程;A creating unit configured to execute a coroutine for creating the non-real-time service in response to the RPC request through the service server;
发起单元,被配置为执行通过该协程发起该非实时业务的数据库操作;an initiating unit configured to execute the database operation of initiating the non-real-time service through the coroutine;
阻塞单元,被配置为执行在获取到对该数据库操作的操作结果前,阻塞并挂起该协程;The blocking unit is configured to block and suspend the coroutine before obtaining the operation result of the database operation;
返回单元,被配置为执行在获取到对该数据库操作的操作结果后,返回基于该操作结果生成的响应。The returning unit is configured to, after obtaining the operation result of the database operation, return a response generated based on the operation result.
在一些实施例中,该游戏业务请求为邮件列表拉取请求;该发起单元被配置为执行:In some embodiments, the game service request is a mailing list pull request; the initiating unit is configured to perform:
通过该协程,从该邮件列表拉取请求中,获取该账号的已拉取邮件中的最大个人邮件序列号和最大系统邮件序列号;Through this coroutine, obtain the maximum personal email sequence number and the maximum system email sequence number in the pulled emails of the account from the mailing list pull request;
基于该最大个人邮件序列号,向数据库中该账号的个人邮件集合发起对个人邮件的批量读取操作,该批量读取操作用于读取邮件序列号大于该最大个人邮件序列号的多封个人邮件;Based on the maximum personal email serial number, initiate a batch read operation of personal emails to the personal email collection of the account in the database. The batch read operation is used to read multiple personal emails whose email serial numbers are greater than the maximum personal email serial number mail;
基于该最大系统邮件序列号,向数据库的系统邮件集合发起对系统邮件的批量读取操作,该批量读取操作用于读取邮件序列号大于该最大系统邮件序列号的多封系统邮件。Based on the maximum system mail serial number, a batch read operation of system mail is initiated to the system mail collection of the database, and the batch read operation is used to read multiple system mails whose mail serial numbers are greater than the maximum system mail serial number.
在一些实施例中,该游戏业务请求为邮件列表拉取请求;该发起单元被配置为执行:In some embodiments, the game service request is a mailing list pull request; the initiating unit is configured to perform:
通过该协程获取该邮件列表拉取请求中携带的该账号的已拉取邮件中的最大邮件序列号;Use this coroutine to obtain the maximum email sequence number in the pulled emails of the account carried in the mailing list pull request;
基于该最大邮件序列号,向数据库的系统邮件集合发起对系统邮件的批量读取操作,该批量读取操作用于读取邮件序列号大于该最大邮件序列号的多封系统邮件;Based on the maximum mail sequence number, a batch read operation of system mail is initiated to the system mail collection of the database, and the batch read operation is used to read multiple system mails whose mail sequence numbers are greater than the maximum mail sequence number;
将该多封系统邮件存入该数据库中该账号的个人邮件集合;storing the plurality of system emails in the personal email collection of the account in the database;
基于该最大邮件序列号,向该个人邮件集合发起对邮件的批量读取操作,该批量读取操作用于读取邮件序列号大于该最大邮件序列号的多封邮件。Based on the maximum mail sequence number, a batch read operation of mails is initiated to the personal mail collection, and the batch read operation is used to read a plurality of mails whose mail sequence numbers are greater than the maximum mail sequence number.
在一些实施例中,基于图19的装置组成,该装置还包括生成单元,被配置为执行:In some embodiments, based on the composition of the apparatus in FIG. 19 , the apparatus further includes a generation unit configured to execute:
基于该批量读取操作的操作结果所返回的多封邮件,确定邮件未读数量;Determine the number of unread emails based on the multiple emails returned by the operation result of the batch read operation;
提取该多封邮件的信息摘要,该信息摘要用于提供以下至少一项:邮件类型、邮件标题、发件人信息、邮件时间戳以及是否含有附件;Extracting information summaries of the plurality of emails, where the information summaries are used to provide at least one of the following: email type, email title, sender information, email timestamp and whether it contains attachments;
生成携带该信息摘要和该邮件未读数量的响应。A response is generated with a digest of the message and an unread count for the message.
在一些实施例中,基于图19的装置组成,该装置还包括分批处理单元,被配置为执行:In some embodiments, based on the apparatus composition of FIG. 19 , the apparatus further includes a batch processing unit configured to perform:
在同一时间段内累计接收到的多个邮件列表拉取请求的数量超过请求量阈值的情况下,通过该业务服务器缓存该多个邮件列表拉取请求关联的多个RPC请求到消息队列中;When the number of multiple mailing list pull requests received in the same time period exceeds the request volume threshold, the service server caches multiple RPC requests associated with the multiple mailing list pull requests into the message queue;
在该消息队列中,合并同一发起账号多次发送的相同邮件列表拉取请求关联的RPC请求,对该发起账号配置请求次数变量;In the message queue, merge the RPC requests associated with the same mailing list pull request sent multiple times by the same initiating account, and configure the request times variable for the initiating account;
基于该请求次数变量,对该消息队列中的各个RPC请求进行重排序;Reordering each RPC request in the message queue based on the request times variable;
每间隔目标时长,分批处理重排序后的消息队列中处于当前批次的至少一个RPC请求。At least one RPC request in the current batch in the reordered message queue is processed in batches at each target time interval.
在一些实施例中,该游戏业务请求为邮件详情拉取请求;该发起单元被配置为执行:In some embodiments, the game service request is a pull request for email details; the initiating unit is configured to perform:
通过该协程确定该邮件详情拉取请求所请求拉取的邮件类型和邮件序列号;Determine the email type and email serial number requested by the email details pull request through this coroutine;
向数据库中该邮件类型所指示的邮件集合,发起对该邮件序列号所指示的邮件的读取操作,该读取操作用于读取该邮件的邮件正文,并在该邮件携带附件的情况下还读取该附件。Initiate a read operation of the mail indicated by the serial number of the mail to the collection of mail indicated by the mail type in the database. The read operation is used to read the mail body of the mail, and if the mail carries attachments, Also read the attachment.
在一些实施例中,该游戏业务请求为邮件发送请求;该发起单元被配置为执行:In some embodiments, the game service request is an email sending request; the initiating unit is configured to perform:
通过该协程确定该邮件发送请求所指示的待发送邮件的邮件类型;Determine the mail type of the mail to be sent indicated by the mail sending request through the coroutine;
在该邮件类型为个人邮件的情况下,向数据库中该账号的个人邮件集合发起对该待发送邮件的写入操作;In the case that the email type is a personal email, initiate a write operation to the email to be sent to the personal email collection of the account in the database;
在该邮件类型为系统邮件的情况下,向数据库的系统邮件集合发起对该待发送邮件的写入操作。In the case that the mail type is a system mail, a write operation of the mail to be sent is initiated to the system mail collection of the database.
在一些实施例中,基于图19的装置组成,该装置还包括生成单元,被配置为执行:In some embodiments, based on the composition of the apparatus in FIG. 19 , the apparatus further includes a generation unit configured to execute:
基于该写入操作的操作结果,为该待发送邮件分配邮件序列号;Based on the operation result of the write operation, assign a mail serial number to the mail to be sent;
在该待发送邮件的收件人账号处于游戏离线状态的情况下,生成向该账号通知邮件发送成功的响应;When the recipient account of the email to be sent is offline in the game, generate a response to notify the account that the email is sent successfully;
在该待发送邮件的收件人账号处于游戏在线状态的情况下,生成向该账号通知邮件发送成功的响应;以及,生成向该收件人账号推送该待发送邮件的响应。When the recipient account of the email to be sent is in the game online state, generate a response to notify the account that the email is successfully sent; and generate a response to push the email to the recipient account.
在一些实施例中,该游戏业务请求为未读消息拉取请求;该发起单元被配置为执行:In some embodiments, the game service request is an unread message pull request; the initiating unit is configured to perform:
通过该协程,从该未读消息拉取请求中获取待查询账号以及最大消息标识,该最大消息标识指示该账号和该待查询账号的会话中的最新已读消息;Through the coroutine, the account to be queried and the maximum message ID are obtained from the unread message pull request, and the maximum message ID indicates the latest read message in the session between the account and the account to be queried;
基于该最大消息标识,向数据库中该账号和该待查询账号的消息集合发起对未读消息的批量读取操作,该批量读取操作用于读取消息标识大于该最大消息标识的多条消息。Based on the maximum message identifier, initiate a batch read operation of unread messages to the message set of the account and the account to be queried in the database, and the batch read operation is used to read multiple messages whose message identifier is greater than the maximum message identifier .
在一些实施例中,基于图19的装置组成,该装置还包括生成单元,被配置为执行:In some embodiments, based on the composition of the apparatus in FIG. 19 , the apparatus further includes a generating unit configured to execute:
基于该批量读取操作的操作结果所返回的多条消息,确定未读消息数量;Determine the number of unread messages based on the multiple messages returned by the operation result of the batch read operation;
生成携带该多条未读消息和该未读消息数量的响应。A response carrying the plurality of unread messages and the number of unread messages is generated.
在一些实施例中,该游戏业务请求为消息发送请求;该发起单元被配置为执行:In some embodiments, the game service request is a message sending request; the initiating unit is configured to perform:
通过该协程确定该消息发送请求所指示的待发送消息的消息类型;Determine the message type of the message to be sent indicated by the message sending request through the coroutine;
在该消息类型为个人消息的情况下,向数据库中该账号和消息接收账号的消息集合发起对该待发送消息的写入操作;In the case that the message type is a personal message, initiate a write operation of the message to be sent to the message set of the account and the message receiving account in the database;
在该消息类型为群组消息的情况下,向数据库中消息接收群组的消息集合发起对该待发送消息的写入操作。In the case that the message type is a group message, a write operation of the message to be sent is initiated to the message collection of the message receiving group in the database.
在一些实施例中,基于图19的装置组成,该装置还包括生成单元,被配置为执行:In some embodiments, based on the composition of the apparatus in FIG. 19 , the apparatus further includes a generating unit configured to execute:
基于该写入操作的操作结果,为该待发送消息分配消息标识,生成向该账号通知消息发送成功的响应;Based on the operation result of the write operation, assign a message identifier to the message to be sent, and generate a response to notify the account that the message is successfully sent;
对于该个人消息,仅在该消息接收账号处于游戏在线状态的情况下,生成向该消息接收账号推送该待发送消息的响应;For the personal message, only when the message receiving account is in the online state of the game, generate a response to push the message to be sent to the message receiving account;
对于该群组消息,拉取该消息接收群组的最新成员列表;仅对该最新成员列表中的在线成员账号,生成向该在线成员账号推送该待发送消息的响应。For the group message, the latest member list of the message receiving group is pulled; only for the online member account in the latest member list, a response of pushing the message to be sent to the online member account is generated.
在一些实施例中,该游戏业务请求为账号添加请求,该账号添加请求用于申请将目标账号添加到该账号的账号关系链上;该发起单元被配置为执行:In some embodiments, the game service request is an account addition request, and the account addition request is used to apply for adding the target account to the account relationship chain of the account; the initiating unit is configured to execute:
通过该协程,对该账号进行权限验证;Through this coroutine, verify the authority of the account;
在验证通过后,向数据库发起写入由该账号向该目标账号的账号添加记录的数据库操作;After the verification is passed, initiate a database operation to write the record added by the account to the account of the target account to the database;
基于图19的装置组成,该装置还包括生成单元,被配置为执行:Based on the device composition of Figure 19, the device also includes a generating unit configured to perform:
在该操作结果指示对该账号添加记录写入完毕的情况下,生成对该目标账号的账号添加通知响应。When the operation result indicates that the account addition record has been written, an account addition notification response to the target account is generated.
关于上述实施例中的装置,其中各个单元执行操作的具体方式已经在有关该游戏业务请求的处理方法的实施例中进行了详细描述,此处将不做详细阐述说明。With regard to the apparatus in the above embodiments, the specific manner in which each unit executes operations has been described in detail in the embodiment of the game service request processing method, and will not be described in detail here.
图20是本公开实施例提供的一种计算机设备的结构示意图,该计算机设备2000可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上处理器(CentralProcessing Units,CPU)2001和一个或一个以上的存储器2002,其中,该存储器2002中存储有至少一条程序代码,该至少一条程序代码由该处理器2001加载并执行以实现上述各个实施例提供的游戏业务请求的处理方法。当然,该计算机设备2000还可以具有有线或无线网络接口、键盘以及输入输出接口等部件,以便进行输入输出,该计算机设备2000还可以包括其他用于实现设备功能的部件,在此不做赘述。FIG. 20 is a schematic structural diagram of a computer device provided by an embodiment of the present disclosure. The
在示例性实施例中,还提供了一种包括至少一条指令的计算机可读存储介质,例如包括至少一条指令的存储器,上述至少一条指令可由计算机设备中的处理器执行以完成上述实施例中的游戏业务请求的处理方法。可选地,上述计算机可读存储介质可以是非临时性计算机可读存储介质,例如,该非临时性计算机可读存储介质可以包括ROM(Read-OnlyMemory,只读存储器)、RAM(Random-Access Memory,随机存取存储器)、CD-ROM(CompactDisc Read-Only Memory,只读光盘)、磁带、软盘和光数据存储设备等。In an exemplary embodiment, there is also provided a computer-readable storage medium including at least one instruction, such as a memory including at least one instruction, and the at least one instruction can be executed by a processor in a computer device to complete the above-mentioned embodiment. The processing method of the game service request. Optionally, the above-mentioned computer-readable storage medium may be a non-transitory computer-readable storage medium, for example, the non-transitory computer-readable storage medium may include ROM (Read-Only Memory, Read Only Memory), RAM (Random-Access Memory , random access memory), CD-ROM (CompactDisc Read-Only Memory, CD-ROM), magnetic tape, floppy disk and optical data storage devices, etc.
在示例性实施例中,还提供了一种计算机程序产品,包括一条或多条指令,该一条或多条指令可以由计算机设备的处理器执行,以完成上述各个实施例提供的游戏业务请求的处理方法。In an exemplary embodiment, a computer program product is also provided, including one or more instructions, which can be executed by a processor of a computer device, so as to complete the game service request provided by each of the above embodiments. Approach.
本领域技术人员在考虑说明书及实践这里公开的发明后,将容易想到本公开的其它实施方案。本公开旨在涵盖本公开的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本公开的一般性原理并包括本公开未公开的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本公开的真正范围和精神由下面的权利要求指出。Other embodiments of the present disclosure will be readily apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. The present disclosure is intended to cover any modification, use or adaptation of the present disclosure. These modifications, uses or adaptations follow the general principles of the present disclosure and include common knowledge or conventional technical means in the technical field not disclosed in the present disclosure. . The specification and examples are to be considered exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
应当理解的是,本公开并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本公开的范围仅由所附的权利要求来限制。It should be understood that the present disclosure is not limited to the precise constructions which have been described above and shown in the drawings, and various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims (18)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211632392.4A CN115920371A (en) | 2022-12-19 | 2022-12-19 | Game service request processing method, device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211632392.4A CN115920371A (en) | 2022-12-19 | 2022-12-19 | Game service request processing method, device, computer equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115920371A true CN115920371A (en) | 2023-04-07 |
Family
ID=86652433
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211632392.4A Pending CN115920371A (en) | 2022-12-19 | 2022-12-19 | Game service request processing method, device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115920371A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117931382A (en) * | 2024-01-30 | 2024-04-26 | 天津大学 | Transaction guarantee method for server-oriented non-perception calculation |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1522013A (en) * | 2003-01-03 | 2004-08-18 | System and method for improved synchronization between server and client | |
CN109831523A (en) * | 2019-03-11 | 2019-05-31 | 上海六感科技有限公司 | The method at game server framework and game server customer in response end |
CN110247984A (en) * | 2019-06-27 | 2019-09-17 | 腾讯科技(深圳)有限公司 | Method for processing business, device and storage medium |
CN112328410A (en) * | 2020-11-04 | 2021-02-05 | 网易(杭州)网络有限公司 | Method, device, equipment and storage medium for realizing remote procedure call |
CN114153625A (en) * | 2021-10-26 | 2022-03-08 | 杭州电魂网络科技股份有限公司 | Method, system, device and medium for developing game system based on Golang development framework |
-
2022
- 2022-12-19 CN CN202211632392.4A patent/CN115920371A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1522013A (en) * | 2003-01-03 | 2004-08-18 | System and method for improved synchronization between server and client | |
CN109831523A (en) * | 2019-03-11 | 2019-05-31 | 上海六感科技有限公司 | The method at game server framework and game server customer in response end |
CN110247984A (en) * | 2019-06-27 | 2019-09-17 | 腾讯科技(深圳)有限公司 | Method for processing business, device and storage medium |
CN112328410A (en) * | 2020-11-04 | 2021-02-05 | 网易(杭州)网络有限公司 | Method, device, equipment and storage medium for realizing remote procedure call |
CN114153625A (en) * | 2021-10-26 | 2022-03-08 | 杭州电魂网络科技股份有限公司 | Method, system, device and medium for developing game system based on Golang development framework |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117931382A (en) * | 2024-01-30 | 2024-04-26 | 天津大学 | Transaction guarantee method for server-oriented non-perception calculation |
CN117931382B (en) * | 2024-01-30 | 2024-08-20 | 天津大学 | A transaction assurance method for server-aware computing |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
KR100545874B1 (en) | User's log information management method and system using location server belonging to a plurality of groups | |
US9686329B2 (en) | Method and apparatus for displaying webcast rooms | |
CN102104600B (en) | Distributed pluggable game server platform and cooperative working method thereof | |
CN112245904B (en) | Method, system, storage medium and computer device for supporting cross-service game | |
CN111314714B (en) | Game live broadcast method and device | |
US20220214998A1 (en) | Method and apparatus for versioning cloud network configuration | |
CN112988013B (en) | Information interaction method and device and storage medium | |
WO2015081907A1 (en) | Role object management method, device, and server | |
CN109936593A (en) | A method and system for message distribution | |
CN119182787A (en) | Information processing device, data synchronization program, data synchronization system, terminal device, and virtual space management providing device | |
CN109189502A (en) | A kind of message treatment method and relevant device based on instant messaging public platform | |
CN103618732B (en) | Execution flow of App engine structure of PaaS and Erlang | |
CN113797526B (en) | A data processing method, device, equipment and medium | |
CN111130986A (en) | Message sending method, device, equipment and storage medium | |
CN108449612A (en) | Method, device, system, storage medium and computer equipment for distributing resources | |
CN115920371A (en) | Game service request processing method, device, computer equipment and storage medium | |
CN105991553A (en) | Message server and communication method | |
CN112861091B (en) | Login method, login device, electronic equipment and storage medium | |
CN105681291A (en) | Method and system for realizing unified authentication of multiple clients | |
CN107479982B (en) | data synchronization method and terminal | |
CN116896549A (en) | Service deployment method and device, storage medium and electronic device | |
CN111600858B (en) | Application login method, device and system | |
CN118802997A (en) | Method, device, equipment and storage medium for running background services of network applications | |
CN114768259A (en) | Event management method, apparatus, computer-readable storage medium, and computer device | |
CN116800736A (en) | Cross-cloud data processing method and device, public cloud equipment, medium and program product |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |